1 From 010b0c57e748440eb1ceb3d977875f2488d2b4ce 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>
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 | 3 ++-
27 libdwfl/dwfl_error.c | 4 +++-
28 libdwfl/dwfl_module_getdwarf.c | 1 +
29 libdwfl/find-debuginfo.c | 2 +-
30 libdwfl/libdwfl_crc32_file.c | 9 +++++++++
31 libdwfl/linux-kernel-modules.c | 1 +
32 libebl/eblopenbackend.c | 2 +-
33 libelf/elf.h | 8 ++++++--
35 libelf/libelfP.h | 1 +
36 src/addr2line.c | 2 +-
42 src/findtextrel.c | 2 +-
52 tests/addrscopes.c | 2 +-
53 tests/allregs.c | 2 +-
54 tests/backtrace-data.c | 2 +-
55 tests/backtrace-dwarf.c | 2 +-
56 tests/backtrace.c | 2 +-
57 tests/buildid.c | 2 +-
58 tests/debugaltlink.c | 2 +-
59 tests/debuglink.c | 2 +-
60 tests/deleted.c | 2 +-
61 tests/dwfl-addr-sect.c | 2 +-
62 tests/dwfl-bug-addr-overflow.c | 2 +-
63 tests/dwfl-bug-fd-leak.c | 2 +-
64 tests/dwfl-bug-getmodules.c | 2 +-
65 tests/dwfl-report-elf-align.c | 2 +-
66 tests/dwfllines.c | 2 +-
67 tests/dwflmodtest.c | 2 +-
68 tests/dwflsyms.c | 2 +-
69 tests/early-offscn.c | 2 +-
71 tests/find-prologues.c | 2 +-
72 tests/funcretval.c | 2 +-
73 tests/funcscopes.c | 2 +-
74 tests/getsrc_die.c | 2 +-
75 tests/line2addr.c | 2 +-
76 tests/low_high_pc.c | 2 +-
77 tests/md5-sha1-test.c | 2 +-
78 tests/rdwrmmap.c | 2 +-
80 tests/sectiondump.c | 2 +-
81 tests/varlocs.c | 2 +-
82 tests/vdsosyms.c | 2 +-
83 69 files changed, 95 insertions(+), 64 deletions(-)
85 diff --git a/Makefile.am b/Makefile.am
86 index 2ff444e..41f77df 100644
89 @@ -28,7 +28,7 @@ pkginclude_HEADERS = version.h
91 # Add doc back when we have some real content.
92 SUBDIRS = config m4 lib libelf libebl libdwelf libdwfl libdw libcpu libasm \
93 - backends src po tests
96 EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \
97 COPYING COPYING-GPLV2 COPYING-LGPLV3
98 diff --git a/lib/color.c b/lib/color.c
99 index f62389d..a2a84b4 100644
116 /* Prototype for option handler. */
117 static error_t parse_opt (int key, char *arg, struct argp_state *state);
118 diff --git a/lib/fixedsizehash.h b/lib/fixedsizehash.h
119 index dac2a5f..43016fc 100644
120 --- a/lib/fixedsizehash.h
121 +++ b/lib/fixedsizehash.h
126 -#include <sys/cdefs.h>
130 diff --git a/lib/system.h b/lib/system.h
131 index 9203335..1a60131 100644
136 # error "Unknown byte order"
138 +#ifndef TEMP_FAILURE_RETRY
139 +#define TEMP_FAILURE_RETRY(expression) \
141 + ({ long int __result; \
142 + do __result = (long int) (expression); \
143 + while (__result == -1L && errno == EINTR); \
147 +#define error(status, errno, ...) err(status, __VA_ARGS__)
150 #define MAX(m, n) ((m) < (n) ? (n) : (m))
151 diff --git a/lib/xmalloc.c b/lib/xmalloc.c
152 index 0cde384..217b054 100644
164 diff --git a/libasm/asm_end.c b/libasm/asm_end.c
165 index ced24f5..4ad918c 100644
166 --- a/libasm/asm_end.c
167 +++ b/libasm/asm_end.c
177 diff --git a/libasm/asm_newscn.c b/libasm/asm_newscn.c
178 index ddbb25d..74a598d 100644
179 --- a/libasm/asm_newscn.c
180 +++ b/libasm/asm_newscn.c
190 diff --git a/libcpu/i386_gendis.c b/libcpu/i386_gendis.c
191 index aae5eae..6d76016 100644
192 --- a/libcpu/i386_gendis.c
193 +++ b/libcpu/i386_gendis.c
203 diff --git a/libcpu/i386_lex.c b/libcpu/i386_lex.c
204 index ba5f4aa..b1e4191 100644
205 --- a/libcpu/i386_lex.c
206 +++ b/libcpu/i386_lex.c
207 @@ -577,7 +577,7 @@ char *i386_text;
216 diff --git a/libcpu/i386_parse.c b/libcpu/i386_parse.c
217 index ef1ac35..48f2e64 100644
218 --- a/libcpu/i386_parse.c
219 +++ b/libcpu/i386_parse.c
226 #include <inttypes.h>
229 diff --git a/libdw/Makefile.am b/libdw/Makefile.am
230 index ff8c291..89e792a 100644
231 --- a/libdw/Makefile.am
232 +++ b/libdw/Makefile.am
233 @@ -105,7 +105,8 @@ am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
234 libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \
235 ../libdwfl/libdwfl_pic.a ../libebl/libebl.a
236 libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
237 -libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS)
239 +libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) $(fts_LDADD)
241 libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
242 # The rpath is necessary for libebl because its $ORIGIN use will
243 diff --git a/libdw/libdw_alloc.c b/libdw/libdw_alloc.c
244 index 28a8cf6..29aeb3f 100644
245 --- a/libdw/libdw_alloc.c
246 +++ b/libdw/libdw_alloc.c
256 diff --git a/libdwfl/dwfl_build_id_find_elf.c b/libdwfl/dwfl_build_id_find_elf.c
257 index ee0c164..b06ab59 100644
258 --- a/libdwfl/dwfl_build_id_find_elf.c
259 +++ b/libdwfl/dwfl_build_id_find_elf.c
263 #include "libdwflP.h"
265 #include <inttypes.h>
268 @@ -99,7 +100,7 @@ __libdwfl_open_by_build_id (Dwfl_Module *mod, bool debug, char **file_name,
270 if (*file_name != NULL)
272 - *file_name = canonicalize_file_name (name);
273 + *file_name = realpath (name, NULL);
274 if (*file_name == NULL)
277 diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
278 index 7bcf61c..c345797 100644
279 --- a/libdwfl/dwfl_error.c
280 +++ b/libdwfl/dwfl_error.c
281 @@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error)
283 dwfl_errmsg (int error)
285 + static __thread char s[64] = "";
286 if (error == 0 || error == -1)
288 int last_error = global_error;
289 @@ -154,7 +155,8 @@ dwfl_errmsg (int error)
290 switch (error &~ 0xffff)
292 case OTHER_ERROR (ERRNO):
293 - return strerror_r (error & 0xffff, "bad", 0);
294 + strerror_r (error & 0xffff, s, sizeof(s));
296 case OTHER_ERROR (LIBELF):
297 return elf_errmsg (error & 0xffff);
298 case OTHER_ERROR (LIBDW):
299 diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
300 index 9775ace..511c4a6 100644
301 --- a/libdwfl/dwfl_module_getdwarf.c
302 +++ b/libdwfl/dwfl_module_getdwarf.c
308 #include "../libdw/libdwP.h" /* DWARF_E_* values are here. */
309 #include "../libelf/libelfP.h"
311 diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c
312 index 6d5a42a..9267788 100644
313 --- a/libdwfl/find-debuginfo.c
314 +++ b/libdwfl/find-debuginfo.c
315 @@ -389,7 +389,7 @@ dwfl_standard_find_debuginfo (Dwfl_Module *mod,
316 /* If FILE_NAME is a symlink, the debug file might be associated
317 with the symlink target name instead. */
319 - char *canon = canonicalize_file_name (file_name);
320 + char *canon = realpath (file_name, NULL);
321 if (canon != NULL && strcmp (file_name, canon))
322 fd = find_debuginfo_in_path (mod, canon,
323 debuglink_file, debuglink_crc,
324 diff --git a/libdwfl/libdwfl_crc32_file.c b/libdwfl/libdwfl_crc32_file.c
325 index f849128..6f0aca1 100644
326 --- a/libdwfl/libdwfl_crc32_file.c
327 +++ b/libdwfl/libdwfl_crc32_file.c
332 +#ifndef TEMP_FAILURE_RETRY
333 +#define TEMP_FAILURE_RETRY(expression) \
335 + ({ long int __result; \
336 + do __result = (long int) (expression); \
337 + while (__result == -1L && errno == EINTR); \
341 #define crc32_file attribute_hidden __libdwfl_crc32_file
342 #define crc32 __libdwfl_crc32
343 #include <libdwflP.h>
344 diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
345 index 9d0fef2..9fc09b8 100644
346 --- a/libdwfl/linux-kernel-modules.c
347 +++ b/libdwfl/linux-kernel-modules.c
351 #include "libdwflP.h"
353 #include <inttypes.h>
356 diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
357 index 5371396..2e66dfd 100644
358 --- a/libebl/eblopenbackend.c
359 +++ b/libebl/eblopenbackend.c
369 diff --git a/libelf/elf.h b/libelf/elf.h
370 index 5cf2b93..990b3af 100644
375 #include <features.h>
382 /* Standard ELF types. */
384 @@ -3705,6 +3707,8 @@ enum
385 #define R_BPF_NONE 0 /* No reloc */
386 #define R_BPF_MAP_FD 1 /* Map fd to pointer */
394 diff --git a/libelf/libelf.h b/libelf/libelf.h
395 index 547c0f5..dd78799 100644
396 --- a/libelf/libelf.h
397 +++ b/libelf/libelf.h
404 #include <sys/types.h>
406 diff --git a/libelf/libelfP.h b/libelf/libelfP.h
407 index 7ee6625..5840899 100644
408 --- a/libelf/libelfP.h
409 +++ b/libelf/libelfP.h
418 diff --git a/src/addr2line.c b/src/addr2line.c
419 index ba414a7..04b7116 100644
420 --- a/src/addr2line.c
421 +++ b/src/addr2line.c
429 #include <inttypes.h>
431 diff --git a/src/ar.c b/src/ar.c
432 index ec32cee..4efd729 100644
444 diff --git a/src/arlib.c b/src/arlib.c
445 index e0839aa..1143658 100644
455 #include <inttypes.h>
457 diff --git a/src/arlib2.c b/src/arlib2.c
458 index 553fc57..46443d0 100644
470 diff --git a/src/elfcmp.c b/src/elfcmp.c
471 index 5046420..cff183f 100644
483 diff --git a/src/elflint.c b/src/elflint.c
484 index 51e53c2..da0b0dc 100644
489 #include <byteswap.h>
495 #include <inttypes.h>
496 diff --git a/src/findtextrel.c b/src/findtextrel.c
497 index 8f1e239..71463af 100644
498 --- a/src/findtextrel.c
499 +++ b/src/findtextrel.c
509 diff --git a/src/nm.c b/src/nm.c
510 index 969c6d3..3113c04 100644
521 #include <inttypes.h>
522 diff --git a/src/objdump.c b/src/objdump.c
523 index 860cfac..61e67bf 100644
533 #include <inttypes.h>
535 diff --git a/src/ranlib.c b/src/ranlib.c
536 index cc0ee23..ae851e4 100644
548 diff --git a/src/readelf.c b/src/readelf.c
549 index 346eccd..c831aa8 100644
560 #include <inttypes.h>
561 diff --git a/src/size.c b/src/size.c
562 index ad8dbcb..fd83be0 100644
573 #include <inttypes.h>
574 diff --git a/src/stack.c b/src/stack.c
575 index 6f2ff69..6da0243 100644
585 #include <inttypes.h>
587 diff --git a/src/strings.c b/src/strings.c
588 index d214356..76cb26b 100644
599 #include <inttypes.h>
600 diff --git a/src/strip.c b/src/strip.c
601 index c7830ec..0d7f148 100644
606 #include <byteswap.h>
613 diff --git a/src/unstrip.c b/src/unstrip.c
614 index 5074909..3d4f952 100644
626 diff --git a/tests/addrscopes.c b/tests/addrscopes.c
627 index 791569f..54f4311 100644
628 --- a/tests/addrscopes.c
629 +++ b/tests/addrscopes.c
631 #include <stdio_ext.h>
639 diff --git a/tests/allregs.c b/tests/allregs.c
640 index 286f7e3..c9de089 100644
641 --- a/tests/allregs.c
642 +++ b/tests/allregs.c
652 diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c
653 index a387d8f..955c27d 100644
654 --- a/tests/backtrace-data.c
655 +++ b/tests/backtrace-data.c
664 #if defined(__x86_64__) && defined(__linux__)
665 diff --git a/tests/backtrace-dwarf.c b/tests/backtrace-dwarf.c
666 index 2dc8a9a..24ca7fb 100644
667 --- a/tests/backtrace-dwarf.c
668 +++ b/tests/backtrace-dwarf.c
670 #include <stdio_ext.h>
676 #include <sys/types.h>
677 #include <sys/wait.h>
678 diff --git a/tests/backtrace.c b/tests/backtrace.c
679 index 21abe8a..d733248 100644
680 --- a/tests/backtrace.c
681 +++ b/tests/backtrace.c
691 diff --git a/tests/buildid.c b/tests/buildid.c
692 index 87c1877..2953e6b 100644
693 --- a/tests/buildid.c
694 +++ b/tests/buildid.c
696 #include ELFUTILS_HEADER(elf)
697 #include ELFUTILS_HEADER(dwelf)
703 #include <sys/types.h>
704 diff --git a/tests/debugaltlink.c b/tests/debugaltlink.c
705 index 6d97d50..ee7e559 100644
706 --- a/tests/debugaltlink.c
707 +++ b/tests/debugaltlink.c
709 #include ELFUTILS_HEADER(dw)
710 #include ELFUTILS_HEADER(dwelf)
716 #include <sys/types.h>
717 diff --git a/tests/debuglink.c b/tests/debuglink.c
718 index 935d102..741cb81 100644
719 --- a/tests/debuglink.c
720 +++ b/tests/debuglink.c
723 #include ELFUTILS_HEADER(dwelf)
729 #include <sys/types.h>
730 diff --git a/tests/deleted.c b/tests/deleted.c
731 index 6be35bc..0190711 100644
732 --- a/tests/deleted.c
733 +++ b/tests/deleted.c
742 #include <sys/prctl.h>
743 diff --git a/tests/dwfl-addr-sect.c b/tests/dwfl-addr-sect.c
744 index 21e470a..1ea1e3b 100644
745 --- a/tests/dwfl-addr-sect.c
746 +++ b/tests/dwfl-addr-sect.c
748 #include <stdio_ext.h>
755 #include ELFUTILS_HEADER(dwfl)
756 diff --git a/tests/dwfl-bug-addr-overflow.c b/tests/dwfl-bug-addr-overflow.c
757 index aa8030e..02c8bef 100644
758 --- a/tests/dwfl-bug-addr-overflow.c
759 +++ b/tests/dwfl-bug-addr-overflow.c
761 #include <inttypes.h>
763 #include <stdio_ext.h>
767 #include ELFUTILS_HEADER(dwfl)
769 diff --git a/tests/dwfl-bug-fd-leak.c b/tests/dwfl-bug-fd-leak.c
770 index 689cdd7..5973da3 100644
771 --- a/tests/dwfl-bug-fd-leak.c
772 +++ b/tests/dwfl-bug-fd-leak.c
782 diff --git a/tests/dwfl-bug-getmodules.c b/tests/dwfl-bug-getmodules.c
783 index 1ee989f..fd62e65 100644
784 --- a/tests/dwfl-bug-getmodules.c
785 +++ b/tests/dwfl-bug-getmodules.c
788 #include ELFUTILS_HEADER(dwfl)
793 static const Dwfl_Callbacks callbacks =
795 diff --git a/tests/dwfl-report-elf-align.c b/tests/dwfl-report-elf-align.c
796 index a4e97d3..f471587 100644
797 --- a/tests/dwfl-report-elf-align.c
798 +++ b/tests/dwfl-report-elf-align.c
800 #include <inttypes.h>
802 #include <stdio_ext.h>
808 diff --git a/tests/dwfllines.c b/tests/dwfllines.c
809 index 90379dd..cbdf6c4 100644
810 --- a/tests/dwfllines.c
811 +++ b/tests/dwfllines.c
820 main (int argc, char *argv[])
821 diff --git a/tests/dwflmodtest.c b/tests/dwflmodtest.c
822 index 0027f96..e68d3bc 100644
823 --- a/tests/dwflmodtest.c
824 +++ b/tests/dwflmodtest.c
826 #include <stdio_ext.h>
833 #include ELFUTILS_HEADER(dwfl)
834 diff --git a/tests/dwflsyms.c b/tests/dwflsyms.c
835 index 49ac334..cf07830 100644
836 --- a/tests/dwflsyms.c
837 +++ b/tests/dwflsyms.c
840 #include <stdio_ext.h>
847 diff --git a/tests/early-offscn.c b/tests/early-offscn.c
848 index 924cb9e..6f60d5a 100644
849 --- a/tests/early-offscn.c
850 +++ b/tests/early-offscn.c
860 diff --git a/tests/ecp.c b/tests/ecp.c
861 index 38a6859..743cea5 100644
873 diff --git a/tests/find-prologues.c b/tests/find-prologues.c
874 index ba8ae37..76f5f04 100644
875 --- a/tests/find-prologues.c
876 +++ b/tests/find-prologues.c
878 #include <stdio_ext.h>
886 diff --git a/tests/funcretval.c b/tests/funcretval.c
887 index 8d19d11..c8aaa93 100644
888 --- a/tests/funcretval.c
889 +++ b/tests/funcretval.c
891 #include <stdio_ext.h>
899 diff --git a/tests/funcscopes.c b/tests/funcscopes.c
900 index 9c90185..dbccb89 100644
901 --- a/tests/funcscopes.c
902 +++ b/tests/funcscopes.c
904 #include <stdio_ext.h>
912 diff --git a/tests/getsrc_die.c b/tests/getsrc_die.c
913 index 055aede..9c394dd 100644
914 --- a/tests/getsrc_die.c
915 +++ b/tests/getsrc_die.c
923 #include <inttypes.h>
925 diff --git a/tests/line2addr.c b/tests/line2addr.c
926 index e0d65d3..9bf0023 100644
927 --- a/tests/line2addr.c
928 +++ b/tests/line2addr.c
938 diff --git a/tests/low_high_pc.c b/tests/low_high_pc.c
939 index d0f4302..8da4fbd 100644
940 --- a/tests/low_high_pc.c
941 +++ b/tests/low_high_pc.c
943 #include <stdio_ext.h>
951 diff --git a/tests/md5-sha1-test.c b/tests/md5-sha1-test.c
952 index d50355e..3c41f40 100644
953 --- a/tests/md5-sha1-test.c
954 +++ b/tests/md5-sha1-test.c
964 diff --git a/tests/rdwrmmap.c b/tests/rdwrmmap.c
965 index 6f027df..1ce5e6e 100644
966 --- a/tests/rdwrmmap.c
967 +++ b/tests/rdwrmmap.c
977 diff --git a/tests/saridx.c b/tests/saridx.c
978 index 8a450d8..b387801 100644
990 diff --git a/tests/sectiondump.c b/tests/sectiondump.c
991 index 3033fed..8e888db 100644
992 --- a/tests/sectiondump.c
993 +++ b/tests/sectiondump.c
1002 #include <inttypes.h>
1003 diff --git a/tests/varlocs.c b/tests/varlocs.c
1004 index c3fba89..e043ea2 100644
1005 --- a/tests/varlocs.c
1006 +++ b/tests/varlocs.c
1014 #include <sys/types.h>
1015 #include <sys/stat.h>
1016 diff --git a/tests/vdsosyms.c b/tests/vdsosyms.c
1017 index b876c10..afb2823 100644
1018 --- a/tests/vdsosyms.c
1019 +++ b/tests/vdsosyms.c
1026 #include <inttypes.h>