1 From 207be05c44da5c4c31179a34660e176145ff8d4b Mon Sep 17 00:00:00 2001
2 From: Khem Raj <raj.khem@gmail.com>
3 Date: Mon, 2 Jul 2018 09:52:23 +0800
4 Subject: [PATCH] build: Provide alternatives for glibc assumptions helps
7 Upstream-Status: Pending
8 Signed-off-by: Khem Raj <raj.khem@gmail.com>
12 Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
16 lib/fixedsizehash.h | 1 -
17 lib/system.h | 10 ++++++++++
19 libasm/asm_end.c | 2 +-
20 libasm/asm_newscn.c | 2 +-
21 libcpu/i386_gendis.c | 2 +-
22 libcpu/i386_lex.c | 2 +-
23 libcpu/i386_parse.c | 2 +-
24 libdw/Makefile.am | 3 ++-
25 libdw/libdw_alloc.c | 2 +-
26 libdwfl/dwfl_build_id_find_elf.c | 1 +
27 libdwfl/dwfl_error.c | 4 +++-
28 libdwfl/dwfl_module_getdwarf.c | 1 +
29 libdwfl/libdwfl_crc32_file.c | 9 +++++++++
30 libdwfl/linux-kernel-modules.c | 1 +
31 libebl/eblopenbackend.c | 2 +-
32 libelf/elf.h | 8 ++++++--
34 libelf/libelfP.h | 1 +
35 src/addr2line.c | 2 +-
41 src/findtextrel.c | 2 +-
51 tests/addrscopes.c | 2 +-
52 tests/allregs.c | 2 +-
53 tests/backtrace-data.c | 2 +-
54 tests/backtrace-dwarf.c | 2 +-
55 tests/backtrace.c | 2 +-
56 tests/buildid.c | 2 +-
57 tests/debugaltlink.c | 2 +-
58 tests/debuglink.c | 2 +-
59 tests/deleted.c | 2 +-
60 tests/dwfl-addr-sect.c | 2 +-
61 tests/dwfl-bug-addr-overflow.c | 2 +-
62 tests/dwfl-bug-fd-leak.c | 2 +-
63 tests/dwfl-bug-getmodules.c | 2 +-
64 tests/dwfl-report-elf-align.c | 2 +-
65 tests/dwfllines.c | 2 +-
66 tests/dwflmodtest.c | 2 +-
67 tests/dwflsyms.c | 2 +-
68 tests/early-offscn.c | 2 +-
70 tests/find-prologues.c | 2 +-
71 tests/funcretval.c | 2 +-
72 tests/funcscopes.c | 2 +-
73 tests/getsrc_die.c | 2 +-
74 tests/line2addr.c | 2 +-
75 tests/low_high_pc.c | 2 +-
76 tests/rdwrmmap.c | 2 +-
78 tests/sectiondump.c | 2 +-
79 tests/varlocs.c | 2 +-
80 tests/vdsosyms.c | 2 +-
81 67 files changed, 92 insertions(+), 61 deletions(-)
83 diff --git a/Makefile.am b/Makefile.am
84 index 2ff444e..41f77df 100644
87 @@ -28,7 +28,7 @@ pkginclude_HEADERS = version.h
89 # Add doc back when we have some real content.
90 SUBDIRS = config m4 lib libelf libebl libdwelf libdwfl libdw libcpu libasm \
91 - backends src po tests
94 EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \
95 COPYING COPYING-GPLV2 COPYING-LGPLV3
96 diff --git a/lib/color.c b/lib/color.c
97 index f62389d..a2a84b4 100644
114 /* Prototype for option handler. */
115 static error_t parse_opt (int key, char *arg, struct argp_state *state);
116 diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h
117 index dac2a5f..43016fc 100644
118 --- a/lib/fixedsizehash.h
119 +++ b/lib/fixedsizehash.h
124 -#include <sys/cdefs.h>
128 diff --git a/lib/system.h b/lib/system.h
129 index 9203335..1a60131 100644
134 # error "Unknown byte order"
136 +#ifndef TEMP_FAILURE_RETRY
137 +#define TEMP_FAILURE_RETRY(expression) \
139 + ({ long int __result; \
140 + do __result = (long int) (expression); \
141 + while (__result == -1L && errno == EINTR); \
145 +#define error(status, errno, ...) err(status, __VA_ARGS__)
148 #define MAX(m, n) ((m) < (n) ? (n) : (m))
149 diff --git a/lib/xmalloc.c b/lib/xmalloc.c
150 index 0cde384..217b054 100644
162 diff --git a/libasm/asm_end.c b/libasm/asm_end.c
163 index ced24f5..4ad918c 100644
164 --- a/libasm/asm_end.c
165 +++ b/libasm/asm_end.c
175 diff --git a/libasm/asm_newscn.c b/libasm/asm_newscn.c
176 index ddbb25d..74a598d 100644
177 --- a/libasm/asm_newscn.c
178 +++ b/libasm/asm_newscn.c
188 diff --git a/libcpu/i386_gendis.c b/libcpu/i386_gendis.c
189 index aae5eae..6d76016 100644
190 --- a/libcpu/i386_gendis.c
191 +++ b/libcpu/i386_gendis.c
201 diff --git a/libcpu/i386_lex.c b/libcpu/i386_lex.c
202 index facdf71..f13842f 100644
203 --- a/libcpu/i386_lex.c
204 +++ b/libcpu/i386_lex.c
205 @@ -571,7 +571,7 @@ char *i386_text;
214 diff --git a/libcpu/i386_parse.c b/libcpu/i386_parse.c
215 index 3c5058a..bf402d6 100644
216 --- a/libcpu/i386_parse.c
217 +++ b/libcpu/i386_parse.c
224 #include <inttypes.h>
227 diff --git a/libdw/Makefile.am b/libdw/Makefile.am
228 index 41df4f3..e6b275f 100644
229 --- a/libdw/Makefile.am
230 +++ b/libdw/Makefile.am
231 @@ -107,7 +107,8 @@ am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
232 libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \
233 ../libdwfl/libdwfl_pic.a ../libebl/libebl.a
234 libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
235 -libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS)
237 +libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) $(fts_LDADD)
239 libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
240 # The rpath is necessary for libebl because its $ORIGIN use will
241 diff --git a/libdw/libdw_alloc.c b/libdw/libdw_alloc.c
242 index d6af23a..deb724c 100644
243 --- a/libdw/libdw_alloc.c
244 +++ b/libdw/libdw_alloc.c
254 diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c
255 index cc6c3f6..b06ab59 100644
256 --- a/libdwfl/dwfl_build_id_find_elf.c
257 +++ b/libdwfl/dwfl_build_id_find_elf.c
261 #include "libdwflP.h"
263 #include <inttypes.h>
266 diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
267 index 7bcf61c..c345797 100644
268 --- a/libdwfl/dwfl_error.c
269 +++ b/libdwfl/dwfl_error.c
270 @@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error)
272 dwfl_errmsg (int error)
274 + static __thread char s[64] = "";
275 if (error == 0 || error == -1)
277 int last_error = global_error;
278 @@ -154,7 +155,8 @@ dwfl_errmsg (int error)
279 switch (error &~ 0xffff)
281 case OTHER_ERROR (ERRNO):
282 - return strerror_r (error & 0xffff, "bad", 0);
283 + strerror_r (error & 0xffff, s, sizeof(s));
285 case OTHER_ERROR (LIBELF):
286 return elf_errmsg (error & 0xffff);
287 case OTHER_ERROR (LIBDW):
288 diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
289 index af6838a..c079d6a 100644
290 --- a/libdwfl/dwfl_module_getdwarf.c
291 +++ b/libdwfl/dwfl_module_getdwarf.c
297 #include "../libdw/libdwP.h" /* DWARF_E_* values are here. */
298 #include "../libelf/libelfP.h"
300 diff --git a/libdwfl/libdwfl_crc32_file.c b/libdwfl/libdwfl_crc32_file.c
301 index f849128..6f0aca1 100644
302 --- a/libdwfl/libdwfl_crc32_file.c
303 +++ b/libdwfl/libdwfl_crc32_file.c
308 +#ifndef TEMP_FAILURE_RETRY
309 +#define TEMP_FAILURE_RETRY(expression) \
311 + ({ long int __result; \
312 + do __result = (long int) (expression); \
313 + while (__result == -1L && errno == EINTR); \
317 #define crc32_file attribute_hidden __libdwfl_crc32_file
318 #define crc32 __libdwfl_crc32
319 #include <libdwflP.h>
320 diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
321 index 9d0fef2..9fc09b8 100644
322 --- a/libdwfl/linux-kernel-modules.c
323 +++ b/libdwfl/linux-kernel-modules.c
327 #include "libdwflP.h"
329 #include <inttypes.h>
332 diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
333 index 8b063f4..9bdeead 100644
334 --- a/libebl/eblopenbackend.c
335 +++ b/libebl/eblopenbackend.c
345 diff --git a/libelf/elf.h b/libelf/elf.h
346 index f774898..be277d0 100644
351 #include <features.h>
358 /* Standard ELF types. */
360 @@ -3912,6 +3914,8 @@ enum
361 #define R_METAG_TLS_LE_HI16 60
362 #define R_METAG_TLS_LE_LO16 61
370 diff --git a/libelf/libelf.h b/libelf/libelf.h
371 index 547c0f5..dd78799 100644
372 --- a/libelf/libelf.h
373 +++ b/libelf/libelf.h
380 #include <sys/types.h>
382 diff --git a/libelf/libelfP.h b/libelf/libelfP.h
383 index ca805ac..47f25c2 100644
384 --- a/libelf/libelfP.h
385 +++ b/libelf/libelfP.h
394 diff --git a/src/addr2line.c b/src/addr2line.c
395 index 5acafa0..a4920b3 100644
396 --- a/src/addr2line.c
397 +++ b/src/addr2line.c
405 #include <inttypes.h>
407 diff --git a/src/ar.c b/src/ar.c
408 index 818115b..2166f1b 100644
420 diff --git a/src/arlib.c b/src/arlib.c
421 index e0839aa..1143658 100644
431 #include <inttypes.h>
433 diff --git a/src/arlib2.c b/src/arlib2.c
434 index 553fc57..46443d0 100644
446 diff --git a/src/elfcmp.c b/src/elfcmp.c
447 index 5046420..cff183f 100644
459 diff --git a/src/elflint.c b/src/elflint.c
460 index 0a26d97..e45fb39 100644
465 #include <byteswap.h>
471 #include <inttypes.h>
472 diff --git a/src/findtextrel.c b/src/findtextrel.c
473 index 8f1e239..71463af 100644
474 --- a/src/findtextrel.c
475 +++ b/src/findtextrel.c
485 diff --git a/src/nm.c b/src/nm.c
486 index 969c6d3..3113c04 100644
497 #include <inttypes.h>
498 diff --git a/src/objdump.c b/src/objdump.c
499 index 0dd9a6a..9c8bf14 100644
509 #include <inttypes.h>
511 diff --git a/src/ranlib.c b/src/ranlib.c
512 index cc0ee23..ae851e4 100644
524 diff --git a/src/readelf.c b/src/readelf.c
525 index f185897..6623e93 100644
536 #include <inttypes.h>
537 diff --git a/src/size.c b/src/size.c
538 index ad8dbcb..fd83be0 100644
549 #include <inttypes.h>
550 diff --git a/src/stack.c b/src/stack.c
551 index 52ae3a8..0fda285 100644
561 #include <inttypes.h>
563 diff --git a/src/strings.c b/src/strings.c
564 index 03d0f13..5c311cb 100644
575 #include <inttypes.h>
576 diff --git a/src/strip.c b/src/strip.c
577 index 773ed54..ff05f46 100644
582 #include <byteswap.h>
589 diff --git a/src/unstrip.c b/src/unstrip.c
590 index f368e69..5ca83d0 100644
602 diff --git a/tests/addrscopes.c b/tests/addrscopes.c
603 index 791569f..54f4311 100644
604 --- a/tests/addrscopes.c
605 +++ b/tests/addrscopes.c
607 #include <stdio_ext.h>
615 diff --git a/tests/allregs.c b/tests/allregs.c
616 index 286f7e3..c9de089 100644
617 --- a/tests/allregs.c
618 +++ b/tests/allregs.c
628 diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c
629 index a387d8f..955c27d 100644
630 --- a/tests/backtrace-data.c
631 +++ b/tests/backtrace-data.c
640 #if defined(__x86_64__) && defined(__linux__)
641 diff --git a/tests/backtrace-dwarf.c b/tests/backtrace-dwarf.c
642 index 7ff826c..246650b 100644
643 --- a/tests/backtrace-dwarf.c
644 +++ b/tests/backtrace-dwarf.c
646 #include <stdio_ext.h>
652 #include <sys/types.h>
653 #include ELFUTILS_HEADER(dwfl)
654 diff --git a/tests/backtrace.c b/tests/backtrace.c
655 index f5dd761..a93a8f0 100644
656 --- a/tests/backtrace.c
657 +++ b/tests/backtrace.c
667 diff --git a/tests/buildid.c b/tests/buildid.c
668 index 87c1877..2953e6b 100644
669 --- a/tests/buildid.c
670 +++ b/tests/buildid.c
672 #include ELFUTILS_HEADER(elf)
673 #include ELFUTILS_HEADER(dwelf)
679 #include <sys/types.h>
680 diff --git a/tests/debugaltlink.c b/tests/debugaltlink.c
681 index 6d97d50..ee7e559 100644
682 --- a/tests/debugaltlink.c
683 +++ b/tests/debugaltlink.c
685 #include ELFUTILS_HEADER(dw)
686 #include ELFUTILS_HEADER(dwelf)
692 #include <sys/types.h>
693 diff --git a/tests/debuglink.c b/tests/debuglink.c
694 index 935d102..741cb81 100644
695 --- a/tests/debuglink.c
696 +++ b/tests/debuglink.c
699 #include ELFUTILS_HEADER(dwelf)
705 #include <sys/types.h>
706 diff --git a/tests/deleted.c b/tests/deleted.c
707 index 6be35bc..0190711 100644
708 --- a/tests/deleted.c
709 +++ b/tests/deleted.c
718 #include <sys/prctl.h>
719 diff --git a/tests/dwfl-addr-sect.c b/tests/dwfl-addr-sect.c
720 index 21e470a..1ea1e3b 100644
721 --- a/tests/dwfl-addr-sect.c
722 +++ b/tests/dwfl-addr-sect.c
724 #include <stdio_ext.h>
731 #include ELFUTILS_HEADER(dwfl)
732 diff --git a/tests/dwfl-bug-addr-overflow.c b/tests/dwfl-bug-addr-overflow.c
733 index aa8030e..02c8bef 100644
734 --- a/tests/dwfl-bug-addr-overflow.c
735 +++ b/tests/dwfl-bug-addr-overflow.c
737 #include <inttypes.h>
739 #include <stdio_ext.h>
743 #include ELFUTILS_HEADER(dwfl)
745 diff --git a/tests/dwfl-bug-fd-leak.c b/tests/dwfl-bug-fd-leak.c
746 index 689cdd7..5973da3 100644
747 --- a/tests/dwfl-bug-fd-leak.c
748 +++ b/tests/dwfl-bug-fd-leak.c
758 diff --git a/tests/dwfl-bug-getmodules.c b/tests/dwfl-bug-getmodules.c
759 index 1ee989f..fd62e65 100644
760 --- a/tests/dwfl-bug-getmodules.c
761 +++ b/tests/dwfl-bug-getmodules.c
764 #include ELFUTILS_HEADER(dwfl)
769 static const Dwfl_Callbacks callbacks =
771 diff --git a/tests/dwfl-report-elf-align.c b/tests/dwfl-report-elf-align.c
772 index a4e97d3..f471587 100644
773 --- a/tests/dwfl-report-elf-align.c
774 +++ b/tests/dwfl-report-elf-align.c
776 #include <inttypes.h>
778 #include <stdio_ext.h>
784 diff --git a/tests/dwfllines.c b/tests/dwfllines.c
785 index 90379dd..cbdf6c4 100644
786 --- a/tests/dwfllines.c
787 +++ b/tests/dwfllines.c
796 main (int argc, char *argv[])
797 diff --git a/tests/dwflmodtest.c b/tests/dwflmodtest.c
798 index 0027f96..e68d3bc 100644
799 --- a/tests/dwflmodtest.c
800 +++ b/tests/dwflmodtest.c
802 #include <stdio_ext.h>
809 #include ELFUTILS_HEADER(dwfl)
810 diff --git a/tests/dwflsyms.c b/tests/dwflsyms.c
811 index 49ac334..cf07830 100644
812 --- a/tests/dwflsyms.c
813 +++ b/tests/dwflsyms.c
816 #include <stdio_ext.h>
823 diff --git a/tests/early-offscn.c b/tests/early-offscn.c
824 index 924cb9e..6f60d5a 100644
825 --- a/tests/early-offscn.c
826 +++ b/tests/early-offscn.c
836 diff --git a/tests/ecp.c b/tests/ecp.c
837 index 38a6859..743cea5 100644
849 diff --git a/tests/find-prologues.c b/tests/find-prologues.c
850 index ba8ae37..76f5f04 100644
851 --- a/tests/find-prologues.c
852 +++ b/tests/find-prologues.c
854 #include <stdio_ext.h>
862 diff --git a/tests/funcretval.c b/tests/funcretval.c
863 index 8d19d11..c8aaa93 100644
864 --- a/tests/funcretval.c
865 +++ b/tests/funcretval.c
867 #include <stdio_ext.h>
875 diff --git a/tests/funcscopes.c b/tests/funcscopes.c
876 index 9c90185..dbccb89 100644
877 --- a/tests/funcscopes.c
878 +++ b/tests/funcscopes.c
880 #include <stdio_ext.h>
888 diff --git a/tests/getsrc_die.c b/tests/getsrc_die.c
889 index 055aede..9c394dd 100644
890 --- a/tests/getsrc_die.c
891 +++ b/tests/getsrc_die.c
899 #include <inttypes.h>
901 diff --git a/tests/line2addr.c b/tests/line2addr.c
902 index e0d65d3..9bf0023 100644
903 --- a/tests/line2addr.c
904 +++ b/tests/line2addr.c
914 diff --git a/tests/low_high_pc.c b/tests/low_high_pc.c
915 index 5c6b343..fa0c158 100644
916 --- a/tests/low_high_pc.c
917 +++ b/tests/low_high_pc.c
919 #include <stdio_ext.h>
927 diff --git a/tests/rdwrmmap.c b/tests/rdwrmmap.c
928 index 6f027df..1ce5e6e 100644
929 --- a/tests/rdwrmmap.c
930 +++ b/tests/rdwrmmap.c
940 diff --git a/tests/saridx.c b/tests/saridx.c
941 index 8a450d8..b387801 100644
953 diff --git a/tests/sectiondump.c b/tests/sectiondump.c
954 index 3033fed..8e888db 100644
955 --- a/tests/sectiondump.c
956 +++ b/tests/sectiondump.c
965 #include <inttypes.h>
966 diff --git a/tests/varlocs.c b/tests/varlocs.c
967 index f4a711c..1d89a61 100644
968 --- a/tests/varlocs.c
969 +++ b/tests/varlocs.c
977 #include <sys/types.h>
978 #include <sys/stat.h>
979 diff --git a/tests/vdsosyms.c b/tests/vdsosyms.c
980 index b876c10..afb2823 100644
981 --- a/tests/vdsosyms.c
982 +++ b/tests/vdsosyms.c
989 #include <inttypes.h>