1 From ef0981744669149a00dd0439a54dac30de7b56a7 Mon Sep 17 00:00:00 2001
2 From: Khem Raj <raj.khem@gmail.com>
3 Date: Wed, 16 Aug 2017 10:06:26 +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>
17 lib/fixedsizehash.h | 1 -
18 lib/system.h | 10 ++++++++++
20 libasm/asm_end.c | 2 +-
21 libasm/asm_newscn.c | 2 +-
22 libcpu/i386_gendis.c | 2 +-
23 libcpu/i386_lex.c | 2 +-
24 libcpu/i386_parse.c | 2 +-
25 libdw/Makefile.am | 3 ++-
26 libdw/libdw_alloc.c | 2 +-
27 libdwfl/dwfl_build_id_find_elf.c | 3 ++-
28 libdwfl/dwfl_error.c | 4 +++-
29 libdwfl/dwfl_module_getdwarf.c | 1 +
30 libdwfl/find-debuginfo.c | 2 +-
31 libdwfl/libdwfl_crc32_file.c | 9 +++++++++
32 libdwfl/linux-kernel-modules.c | 1 +
33 libebl/eblopenbackend.c | 2 +-
34 libelf/elf.h | 8 ++++++--
36 libelf/libelfP.h | 1 +
37 src/addr2line.c | 2 +-
43 src/findtextrel.c | 2 +-
53 tests/addrscopes.c | 2 +-
54 tests/allregs.c | 2 +-
55 tests/backtrace-data.c | 2 +-
56 tests/backtrace-dwarf.c | 2 +-
57 tests/backtrace.c | 2 +-
58 tests/buildid.c | 2 +-
59 tests/debugaltlink.c | 2 +-
60 tests/debuglink.c | 2 +-
61 tests/deleted.c | 2 +-
62 tests/dwfl-addr-sect.c | 2 +-
63 tests/dwfl-bug-addr-overflow.c | 2 +-
64 tests/dwfl-bug-fd-leak.c | 2 +-
65 tests/dwfl-bug-getmodules.c | 2 +-
66 tests/dwfl-report-elf-align.c | 2 +-
67 tests/dwfllines.c | 2 +-
68 tests/dwflmodtest.c | 2 +-
69 tests/dwflsyms.c | 2 +-
70 tests/early-offscn.c | 2 +-
72 tests/find-prologues.c | 2 +-
73 tests/funcretval.c | 2 +-
74 tests/funcscopes.c | 2 +-
75 tests/getsrc_die.c | 2 +-
76 tests/line2addr.c | 2 +-
77 tests/low_high_pc.c | 2 +-
78 tests/md5-sha1-test.c | 2 +-
79 tests/rdwrmmap.c | 2 +-
81 tests/sectiondump.c | 2 +-
82 tests/varlocs.c | 2 +-
83 tests/vdsosyms.c | 2 +-
84 69 files changed, 95 insertions(+), 64 deletions(-)
86 diff --git a/Makefile.am b/Makefile.am
87 index 2ff444e7..41f77df8 100644
90 @@ -28,7 +28,7 @@ pkginclude_HEADERS = version.h
92 # Add doc back when we have some real content.
93 SUBDIRS = config m4 lib libelf libebl libdwelf libdwfl libdw libcpu libasm \
94 - backends src po tests
97 EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \
98 COPYING COPYING-GPLV2 COPYING-LGPLV3
99 diff --git a/lib/color.c b/lib/color.c
100 index f62389d5..a2a84b46 100644
117 /* Prototype for option handler. */
118 static error_t parse_opt (int key, char *arg, struct argp_state *state);
119 diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h
120 index dac2a5f5..43016fc3 100644
121 --- a/lib/fixedsizehash.h
122 +++ b/lib/fixedsizehash.h
127 -#include <sys/cdefs.h>
131 diff --git a/lib/system.h b/lib/system.h
132 index 92033355..1a601319 100644
137 # error "Unknown byte order"
139 +#ifndef TEMP_FAILURE_RETRY
140 +#define TEMP_FAILURE_RETRY(expression) \
142 + ({ long int __result; \
143 + do __result = (long int) (expression); \
144 + while (__result == -1L && errno == EINTR); \
148 +#define error(status, errno, ...) err(status, __VA_ARGS__)
151 #define MAX(m, n) ((m) < (n) ? (n) : (m))
152 diff --git a/lib/xmalloc.c b/lib/xmalloc.c
153 index 0cde384f..217b0541 100644
165 diff --git a/libasm/asm_end.c b/libasm/asm_end.c
166 index ced24f50..4ad918c4 100644
167 --- a/libasm/asm_end.c
168 +++ b/libasm/asm_end.c
178 diff --git a/libasm/asm_newscn.c b/libasm/asm_newscn.c
179 index ddbb25df..74a598d9 100644
180 --- a/libasm/asm_newscn.c
181 +++ b/libasm/asm_newscn.c
191 diff --git a/libcpu/i386_gendis.c b/libcpu/i386_gendis.c
192 index aae5eae6..6d760165 100644
193 --- a/libcpu/i386_gendis.c
194 +++ b/libcpu/i386_gendis.c
204 diff --git a/libcpu/i386_lex.c b/libcpu/i386_lex.c
205 index ba5f4aa5..b1e41916 100644
206 --- a/libcpu/i386_lex.c
207 +++ b/libcpu/i386_lex.c
208 @@ -577,7 +577,7 @@ char *i386_text;
217 diff --git a/libcpu/i386_parse.c b/libcpu/i386_parse.c
218 index 6fa7ce3d..bb270061 100644
219 --- a/libcpu/i386_parse.c
220 +++ b/libcpu/i386_parse.c
227 #include <inttypes.h>
230 diff --git a/libdw/Makefile.am b/libdw/Makefile.am
231 index ff8c291e..89e792aa 100644
232 --- a/libdw/Makefile.am
233 +++ b/libdw/Makefile.am
234 @@ -105,7 +105,8 @@ am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
235 libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \
236 ../libdwfl/libdwfl_pic.a ../libebl/libebl.a
237 libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
238 -libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS)
240 +libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) $(fts_LDADD)
242 libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
243 # The rpath is necessary for libebl because its $ORIGIN use will
244 diff --git a/libdw/libdw_alloc.c b/libdw/libdw_alloc.c
245 index 28a8cf6e..29aeb3f7 100644
246 --- a/libdw/libdw_alloc.c
247 +++ b/libdw/libdw_alloc.c
257 diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c
258 index ee0c1646..b06ab596 100644
259 --- a/libdwfl/dwfl_build_id_find_elf.c
260 +++ b/libdwfl/dwfl_build_id_find_elf.c
264 #include "libdwflP.h"
266 #include <inttypes.h>
269 @@ -99,7 +100,7 @@ __libdwfl_open_by_build_id (Dwfl_Module *mod, bool debug, char **file_name,
271 if (*file_name != NULL)
273 - *file_name = canonicalize_file_name (name);
274 + *file_name = realpath (name, NULL);
275 if (*file_name == NULL)
278 diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
279 index 7bcf61cc..c345797a 100644
280 --- a/libdwfl/dwfl_error.c
281 +++ b/libdwfl/dwfl_error.c
282 @@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error)
284 dwfl_errmsg (int error)
286 + static __thread char s[64] = "";
287 if (error == 0 || error == -1)
289 int last_error = global_error;
290 @@ -154,7 +155,8 @@ dwfl_errmsg (int error)
291 switch (error &~ 0xffff)
293 case OTHER_ERROR (ERRNO):
294 - return strerror_r (error & 0xffff, "bad", 0);
295 + strerror_r (error & 0xffff, s, sizeof(s));
297 case OTHER_ERROR (LIBELF):
298 return elf_errmsg (error & 0xffff);
299 case OTHER_ERROR (LIBDW):
300 diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
301 index 9775aced..511c4a6a 100644
302 --- a/libdwfl/dwfl_module_getdwarf.c
303 +++ b/libdwfl/dwfl_module_getdwarf.c
309 #include "../libdw/libdwP.h" /* DWARF_E_* values are here. */
310 #include "../libelf/libelfP.h"
312 diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c
313 index 6d5a42a6..9267788d 100644
314 --- a/libdwfl/find-debuginfo.c
315 +++ b/libdwfl/find-debuginfo.c
316 @@ -389,7 +389,7 @@ dwfl_standard_find_debuginfo (Dwfl_Module *mod,
317 /* If FILE_NAME is a symlink, the debug file might be associated
318 with the symlink target name instead. */
320 - char *canon = canonicalize_file_name (file_name);
321 + char *canon = realpath (file_name, NULL);
322 if (canon != NULL && strcmp (file_name, canon))
323 fd = find_debuginfo_in_path (mod, canon,
324 debuglink_file, debuglink_crc,
325 diff --git a/libdwfl/libdwfl_crc32_file.c b/libdwfl/libdwfl_crc32_file.c
326 index f849128d..6f0aca1b 100644
327 --- a/libdwfl/libdwfl_crc32_file.c
328 +++ b/libdwfl/libdwfl_crc32_file.c
333 +#ifndef TEMP_FAILURE_RETRY
334 +#define TEMP_FAILURE_RETRY(expression) \
336 + ({ long int __result; \
337 + do __result = (long int) (expression); \
338 + while (__result == -1L && errno == EINTR); \
342 #define crc32_file attribute_hidden __libdwfl_crc32_file
343 #define crc32 __libdwfl_crc32
344 #include <libdwflP.h>
345 diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
346 index 9d0fef2c..9fc09b88 100644
347 --- a/libdwfl/linux-kernel-modules.c
348 +++ b/libdwfl/linux-kernel-modules.c
352 #include "libdwflP.h"
354 #include <inttypes.h>
357 diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
358 index 53713963..2e66dfdd 100644
359 --- a/libebl/eblopenbackend.c
360 +++ b/libebl/eblopenbackend.c
370 diff --git a/libelf/elf.h b/libelf/elf.h
371 index 5cf2b934..990b3afb 100644
376 #include <features.h>
383 /* Standard ELF types. */
385 @@ -3705,6 +3707,8 @@ enum
386 #define R_BPF_NONE 0 /* No reloc */
387 #define R_BPF_MAP_FD 1 /* Map fd to pointer */
395 diff --git a/libelf/libelf.h b/libelf/libelf.h
396 index 547c0f50..dd78799e 100644
397 --- a/libelf/libelf.h
398 +++ b/libelf/libelf.h
405 #include <sys/types.h>
407 diff --git a/libelf/libelfP.h b/libelf/libelfP.h
408 index 7ee6625a..58408997 100644
409 --- a/libelf/libelfP.h
410 +++ b/libelf/libelfP.h
419 diff --git a/src/addr2line.c b/src/addr2line.c
420 index 444ee52c..9596fa67 100644
421 --- a/src/addr2line.c
422 +++ b/src/addr2line.c
430 #include <inttypes.h>
432 diff --git a/src/ar.c b/src/ar.c
433 index ec32cee5..4efd729c 100644
445 diff --git a/src/arlib.c b/src/arlib.c
446 index e0839aab..1143658f 100644
456 #include <inttypes.h>
458 diff --git a/src/arlib2.c b/src/arlib2.c
459 index 553fc57b..46443d0e 100644
471 diff --git a/src/elfcmp.c b/src/elfcmp.c
472 index 50464207..cff183fa 100644
484 diff --git a/src/elflint.c b/src/elflint.c
485 index df1b3a03..67d8d134 100644
490 #include <byteswap.h>
496 #include <inttypes.h>
497 diff --git a/src/findtextrel.c b/src/findtextrel.c
498 index 8f1e239a..71463af3 100644
499 --- a/src/findtextrel.c
500 +++ b/src/findtextrel.c
510 diff --git a/src/nm.c b/src/nm.c
511 index 969c6d35..3113c04c 100644
522 #include <inttypes.h>
523 diff --git a/src/objdump.c b/src/objdump.c
524 index 0dd9a6aa..9c8bf149 100644
534 #include <inttypes.h>
536 diff --git a/src/ranlib.c b/src/ranlib.c
537 index cc0ee233..ae851e40 100644
549 diff --git a/src/readelf.c b/src/readelf.c
550 index 6a27e7e0..4759a965 100644
561 #include <inttypes.h>
562 diff --git a/src/size.c b/src/size.c
563 index ad8dbcbb..fd83be06 100644
574 #include <inttypes.h>
575 diff --git a/src/stack.c b/src/stack.c
576 index 6f2ff69f..6da0243d 100644
586 #include <inttypes.h>
588 diff --git a/src/strings.c b/src/strings.c
589 index 03d0f133..5c311cbd 100644
600 #include <inttypes.h>
601 diff --git a/src/strip.c b/src/strip.c
602 index c7830ec6..0d7f148d 100644
607 #include <byteswap.h>
614 diff --git a/src/unstrip.c b/src/unstrip.c
615 index 50749093..3d4f9525 100644
627 diff --git a/tests/addrscopes.c b/tests/addrscopes.c
628 index 791569f5..54f4311b 100644
629 --- a/tests/addrscopes.c
630 +++ b/tests/addrscopes.c
632 #include <stdio_ext.h>
640 diff --git a/tests/allregs.c b/tests/allregs.c
641 index 286f7e3c..c9de0897 100644
642 --- a/tests/allregs.c
643 +++ b/tests/allregs.c
653 diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c
654 index a387d8ff..955c27d1 100644
655 --- a/tests/backtrace-data.c
656 +++ b/tests/backtrace-data.c
665 #if defined(__x86_64__) && defined(__linux__)
666 diff --git a/tests/backtrace-dwarf.c b/tests/backtrace-dwarf.c
667 index 2dc8a9a2..24ca7fb0 100644
668 --- a/tests/backtrace-dwarf.c
669 +++ b/tests/backtrace-dwarf.c
671 #include <stdio_ext.h>
677 #include <sys/types.h>
678 #include <sys/wait.h>
679 diff --git a/tests/backtrace.c b/tests/backtrace.c
680 index f5dd761f..a93a8f03 100644
681 --- a/tests/backtrace.c
682 +++ b/tests/backtrace.c
692 diff --git a/tests/buildid.c b/tests/buildid.c
693 index 87c18773..2953e6bb 100644
694 --- a/tests/buildid.c
695 +++ b/tests/buildid.c
697 #include ELFUTILS_HEADER(elf)
698 #include ELFUTILS_HEADER(dwelf)
704 #include <sys/types.h>
705 diff --git a/tests/debugaltlink.c b/tests/debugaltlink.c
706 index 6d97d500..ee7e559e 100644
707 --- a/tests/debugaltlink.c
708 +++ b/tests/debugaltlink.c
710 #include ELFUTILS_HEADER(dw)
711 #include ELFUTILS_HEADER(dwelf)
717 #include <sys/types.h>
718 diff --git a/tests/debuglink.c b/tests/debuglink.c
719 index 935d1029..741cb814 100644
720 --- a/tests/debuglink.c
721 +++ b/tests/debuglink.c
724 #include ELFUTILS_HEADER(dwelf)
730 #include <sys/types.h>
731 diff --git a/tests/deleted.c b/tests/deleted.c
732 index 6be35bc2..01907113 100644
733 --- a/tests/deleted.c
734 +++ b/tests/deleted.c
743 #include <sys/prctl.h>
744 diff --git a/tests/dwfl-addr-sect.c b/tests/dwfl-addr-sect.c
745 index 21e470a3..1ea1e3b2 100644
746 --- a/tests/dwfl-addr-sect.c
747 +++ b/tests/dwfl-addr-sect.c
749 #include <stdio_ext.h>
756 #include ELFUTILS_HEADER(dwfl)
757 diff --git a/tests/dwfl-bug-addr-overflow.c b/tests/dwfl-bug-addr-overflow.c
758 index aa8030e1..02c8bef9 100644
759 --- a/tests/dwfl-bug-addr-overflow.c
760 +++ b/tests/dwfl-bug-addr-overflow.c
762 #include <inttypes.h>
764 #include <stdio_ext.h>
768 #include ELFUTILS_HEADER(dwfl)
770 diff --git a/tests/dwfl-bug-fd-leak.c b/tests/dwfl-bug-fd-leak.c
771 index 689cdd79..5973da39 100644
772 --- a/tests/dwfl-bug-fd-leak.c
773 +++ b/tests/dwfl-bug-fd-leak.c
783 diff --git a/tests/dwfl-bug-getmodules.c b/tests/dwfl-bug-getmodules.c
784 index 1ee989f8..fd62e653 100644
785 --- a/tests/dwfl-bug-getmodules.c
786 +++ b/tests/dwfl-bug-getmodules.c
789 #include ELFUTILS_HEADER(dwfl)
794 static const Dwfl_Callbacks callbacks =
796 diff --git a/tests/dwfl-report-elf-align.c b/tests/dwfl-report-elf-align.c
797 index a4e97d3c..f471587c 100644
798 --- a/tests/dwfl-report-elf-align.c
799 +++ b/tests/dwfl-report-elf-align.c
801 #include <inttypes.h>
803 #include <stdio_ext.h>
809 diff --git a/tests/dwfllines.c b/tests/dwfllines.c
810 index 90379dd2..cbdf6c4c 100644
811 --- a/tests/dwfllines.c
812 +++ b/tests/dwfllines.c
821 main (int argc, char *argv[])
822 diff --git a/tests/dwflmodtest.c b/tests/dwflmodtest.c
823 index 0027f96b..e68d3bca 100644
824 --- a/tests/dwflmodtest.c
825 +++ b/tests/dwflmodtest.c
827 #include <stdio_ext.h>
834 #include ELFUTILS_HEADER(dwfl)
835 diff --git a/tests/dwflsyms.c b/tests/dwflsyms.c
836 index 49ac3346..cf078301 100644
837 --- a/tests/dwflsyms.c
838 +++ b/tests/dwflsyms.c
841 #include <stdio_ext.h>
848 diff --git a/tests/early-offscn.c b/tests/early-offscn.c
849 index 924cb9ef..6f60d5a3 100644
850 --- a/tests/early-offscn.c
851 +++ b/tests/early-offscn.c
861 diff --git a/tests/ecp.c b/tests/ecp.c
862 index 38a6859e..743cea5d 100644
874 diff --git a/tests/find-prologues.c b/tests/find-prologues.c
875 index ba8ae371..76f5f047 100644
876 --- a/tests/find-prologues.c
877 +++ b/tests/find-prologues.c
879 #include <stdio_ext.h>
887 diff --git a/tests/funcretval.c b/tests/funcretval.c
888 index 8d19d117..c8aaa93d 100644
889 --- a/tests/funcretval.c
890 +++ b/tests/funcretval.c
892 #include <stdio_ext.h>
900 diff --git a/tests/funcscopes.c b/tests/funcscopes.c
901 index 9c901858..dbccb89e 100644
902 --- a/tests/funcscopes.c
903 +++ b/tests/funcscopes.c
905 #include <stdio_ext.h>
913 diff --git a/tests/getsrc_die.c b/tests/getsrc_die.c
914 index 055aede0..9c394dd0 100644
915 --- a/tests/getsrc_die.c
916 +++ b/tests/getsrc_die.c
924 #include <inttypes.h>
926 diff --git a/tests/line2addr.c b/tests/line2addr.c
927 index e0d65d3d..9bf0023b 100644
928 --- a/tests/line2addr.c
929 +++ b/tests/line2addr.c
939 diff --git a/tests/low_high_pc.c b/tests/low_high_pc.c
940 index d0f43023..8da4fbdf 100644
941 --- a/tests/low_high_pc.c
942 +++ b/tests/low_high_pc.c
944 #include <stdio_ext.h>
952 diff --git a/tests/md5-sha1-test.c b/tests/md5-sha1-test.c
953 index d50355e9..3c41f40b 100644
954 --- a/tests/md5-sha1-test.c
955 +++ b/tests/md5-sha1-test.c
965 diff --git a/tests/rdwrmmap.c b/tests/rdwrmmap.c
966 index 6f027dfe..1ce5e6ed 100644
967 --- a/tests/rdwrmmap.c
968 +++ b/tests/rdwrmmap.c
978 diff --git a/tests/saridx.c b/tests/saridx.c
979 index 8a450d82..b3878013 100644
991 diff --git a/tests/sectiondump.c b/tests/sectiondump.c
992 index 3033fedc..8e888db3 100644
993 --- a/tests/sectiondump.c
994 +++ b/tests/sectiondump.c
1003 #include <inttypes.h>
1004 diff --git a/tests/varlocs.c b/tests/varlocs.c
1005 index c3fba89e..e043ea2c 100644
1006 --- a/tests/varlocs.c
1007 +++ b/tests/varlocs.c
1015 #include <sys/types.h>
1016 #include <sys/stat.h>
1017 diff --git a/tests/vdsosyms.c b/tests/vdsosyms.c
1018 index b876c10b..afb28232 100644
1019 --- a/tests/vdsosyms.c
1020 +++ b/tests/vdsosyms.c
1027 #include <inttypes.h>