blob: a0ff07d397430e0b2f4983ceb092cfe1f0d40283 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001Rebase to 1.162
2
3Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
4---
5 ChangeLog | 30 +++++++++++++++++++++
6 backends/ChangeLog | 12 +++++++++
7 backends/Makefile.am | 2 +-
8 config/ChangeLog | 4 +++
9 config/eu.am | 14 +++++++---
10 configure.ac | 61 +++++++++++++++++++++++++++++++++++++++++--
11 lib/ChangeLog | 8 ++++++
12 lib/eu-config.h | 10 +++++++
13 libasm/ChangeLog | 5 ++++
14 libcpu/ChangeLog | 8 ++++++
15 libcpu/i386_disasm.c | 1 +
16 libdw/ChangeLog | 13 +++++++++
17 libdw/dwarf_begin_elf.c | 8 ++++++
18 libdw/libdw.h | 2 +-
19 libdwfl/ChangeLog | 20 ++++++++++++++
20 libdwfl/linux-core-attach.c | 29 ++++++++++++++++++++
21 libdwfl/linux-pid-attach.c | 14 ++++++++++
22 libebl/ChangeLog | 5 ++++
23 libelf/ChangeLog | 10 +++++++
24 libelf/common.h | 4 +--
25 libelf/gnuhash_xlate.h | 6 +++--
26 src/ChangeLog | 30 +++++++++++++++++++++
27 src/Makefile.am | 5 ++++
28 src/addr2line.c | 4 +--
29 src/findtextrel.c | 6 ++++-
30 src/ld.h | 2 ++
31 src/readelf.c | 15 +++++++----
32 src/strings.c | 11 ++++++++
33 src/strip.c | 6 +++++
34 tests/ChangeLog | 14 ++++++++++
35 tests/Makefile.am | 1 +
36 tests/backtrace.c | 1 +
37 tests/line2addr.c | 2 +-
38 33 files changed, 343 insertions(+), 20 deletions(-)
39
40diff --git a/ChangeLog b/ChangeLog
41index d829783..89bfd24 100644
42--- a/ChangeLog
43+++ b/ChangeLog
44@@ -253,6 +253,8 @@
45
46 2012-01-24 Mark Wielaard <mjw@redhat.com>
47
48+ * configure.ac: Wrap AC_COMPILE_IFELSE sources in AC_LANG_SOURCE.
49+
50 * COPYING: Fix address. Updated version from gnulib.
51
52 2012-01-23 Mark Wielaard <mjw@redhat.com>
53@@ -271,6 +273,9 @@
54
55 2011-10-08 Mike Frysinger <vapier@gentoo.org>
56
57+ * configure.ac (--disable-werror): Handle it, controlling BUILD_WERROR
58+ automake option.
59+
60 * configure.ac: Fix use of AC_ARG_ENABLE to handle $enableval correctly.
61
62 2011-10-02 Ulrich Drepper <drepper@gmail.com>
63@@ -292,6 +297,10 @@
64
65 * configure.ac (LOCALEDIR, DATADIRNAME): Removed.
66
67+2009-11-22 Roland McGrath <roland@redhat.com>
68+
69+ * configure.ac: Use sed and expr instead of modern bash extensions.
70+
71 2009-09-21 Ulrich Drepper <drepper@redhat.com>
72
73 * configure.ac: Update for more modern autoconf.
74@@ -300,6 +309,10 @@
75
76 * configure.ac (zip_LIBS): Check for liblzma too.
77
78+2009-08-17 Roland McGrath <roland@redhat.com>
79+
80+ * configure.ac: Check for -fgnu89-inline; add it to WEXTRA if it works.
81+
82 2009-04-19 Roland McGrath <roland@redhat.com>
83
84 * configure.ac (eu_version): Round down here, not in version.h macros.
85@@ -311,6 +324,8 @@
86
87 2009-01-23 Roland McGrath <roland@redhat.com>
88
89+ * configure.ac: Check for __builtin_popcount.
90+
91 * configure.ac (zlib check): Check for gzdirect, need zlib >= 1.2.2.3.
92
93 * configure.ac (__thread check): Use AC_LINK_IFELSE, in case of
94@@ -391,6 +406,10 @@
95 * configure.ac: Add dummy automake conditional to get dependencies
96 for non-generic linker right. See src/Makefile.am.
97
98+2005-11-22 Roland McGrath <roland@redhat.com>
99+
100+ * configure.ac: Check for --as-needed linker option.
101+
102 2005-11-18 Roland McGrath <roland@redhat.com>
103
104 * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): New variable.
105@@ -438,6 +457,17 @@
106 * Makefile.am (all_SUBDIRS): Add libdwfl.
107 * configure.ac: Write libdwfl/Makefile.
108
109+2005-05-31 Roland McGrath <roland@redhat.com>
110+
111+ * configure.ac (WEXTRA): Check for -Wextra and set this substitution.
112+
113+ * configure.ac: Check for struct stat st_?tim members.
114+ * src/strip.c (process_file): Use st_?time if st_?tim are not there.
115+
116+ * configure.ac: Check for futimes function.
117+ * src/strip.c (handle_elf) [! HAVE_FUTIMES]: Use utimes instead.
118+ (handle_ar) [! HAVE_FUTIMES]: Likewise.
119+
120 2005-05-19 Roland McGrath <roland@redhat.com>
121
122 * configure.ac [AH_BOTTOM] (INTDECL, _INTDECL): New macros.
123diff --git a/backends/ChangeLog b/backends/ChangeLog
124index fe61d9c..9599623 100644
125--- a/backends/ChangeLog
126+++ b/backends/ChangeLog
127@@ -498,6 +498,10 @@
128 * ppc_attrs.c (ppc_check_object_attribute): Handle tag
129 GNU_Power_ABI_Struct_Return.
130
131+2009-01-23 Roland McGrath <roland@redhat.com>
132+
133+ * Makefile.am (libebl_%.so): Use $(LD_AS_NEEDED).
134+
135 2008-10-04 Ulrich Drepper <drepper@redhat.com>
136
137 * i386_reloc.def: Fix entries for TLS_GOTDESC, TLS_DESC_CALL, and
138@@ -825,6 +829,11 @@
139 * sparc_init.c: Likewise.
140 * x86_64_init.c: Likewise.
141
142+2005-11-22 Roland McGrath <roland@redhat.com>
143+
144+ * Makefile.am (LD_AS_NEEDED): New variable, substituted by configure.
145+ (libebl_%.so rule): Use it in place of -Wl,--as-needed.
146+
147 2005-11-19 Roland McGrath <roland@redhat.com>
148
149 * ppc64_reloc.def: REL30 -> ADDR30.
150@@ -847,6 +856,9 @@
151 * Makefile.am (uninstall): Don't try to remove $(pkgincludedir).
152 (CLEANFILES): Add libebl_$(m).so.
153
154+ * Makefile.am (WEXTRA): New variable, substituted by configure.
155+ (AM_CFLAGS): Use it in place of -Wextra.
156+
157 * ppc_reloc.def: Update bits per Alan Modra <amodra@bigpond.net.au>.
158 * ppc64_reloc.def: Likewise.
159
160diff --git a/backends/Makefile.am b/backends/Makefile.am
161index 21d7bd2..fe920c9 100644
162--- a/backends/Makefile.am
163+++ b/backends/Makefile.am
164@@ -119,7 +119,7 @@ libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw)
165 $(LINK) -shared -o $(@:.map=.so) \
166 -Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \
167 -Wl,--version-script,$(@:.so=.map) \
168- -Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw)
169+ -Wl,-z,defs $(LD_AS_NEEDED) $(libelf) $(libdw)
170 @$(textrel_check)
171
172 libebl_i386.so: $(cpu_i386)
173diff --git a/config/ChangeLog b/config/ChangeLog
174index 64b58e1..63b3e90 100644
175--- a/config/ChangeLog
176+++ b/config/ChangeLog
177@@ -106,6 +106,10 @@
178
179 * known-dwarf.awk: Use gawk.
180
181+2011-10-08 Mike Frysinger <vapier@gentoo.org>
182+
183+ * eu.am [BUILD_WERROR]: Conditionalize -Werror use on this.
184+
185 2010-07-02 Ulrich Drepper <drepper@redhat.com>
186
187 * elfutils.spec.in: Add more BuildRequires.
188diff --git a/config/eu.am b/config/eu.am
189index 70d32de..65af085 100644
190--- a/config/eu.am
191+++ b/config/eu.am
192@@ -1,6 +1,6 @@
193 ## Common automake fragments for elfutils subdirectory makefiles.
194 ##
195-## Copyright (C) 2010, 2014 Red Hat, Inc.
196+## Copyright (C) 2010-2011, 2014 Red Hat, Inc.
197 ##
198 ## This file is part of elfutils.
199 ##
200@@ -29,6 +29,9 @@
201 ## not, see <http://www.gnu.org/licenses/>.
202 ##
203
204+WEXTRA = @WEXTRA@
205+LD_AS_NEEDED = @LD_AS_NEEDED@
206+
207 DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"'
208 AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I..
209
210@@ -38,12 +41,17 @@ STACK_USAGE_WARNING=-Wstack-usage=262144
211 else
212 STACK_USAGE_WARNING=
213 endif
214-AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
215+AM_CFLAGS = -std=gnu99 -Wall -Wshadow \
216 $(if $($(*F)_no_Werror),,-Werror) \
217- $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
218+ $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \
219+ $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \
220 $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
221 $($(*F)_CFLAGS)
222
223+if BUILD_WERROR
224+AM_CFLAGS += $(if $($(*F)_no_Werror),,-Werror)
225+endif
226+
227 COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE))
228
229 DEFS.os = -DPIC -DSHARED
230diff --git a/configure.ac b/configure.ac
231index bc9ff56..27a1ef3 100644
232--- a/configure.ac
233+++ b/configure.ac
234@@ -106,6 +106,55 @@ CFLAGS="$old_CFLAGS"])
235 AS_IF([test "x$ac_cv_c99" != xyes],
236 AC_MSG_ERROR([gcc with GNU99 support required]))
237
238+AC_CACHE_CHECK([for -Wextra option to $CC], ac_cv_cc_wextra, [dnl
239+old_CFLAGS="$CFLAGS"
240+CFLAGS="$CFLAGS -Wextra"
241+AC_COMPILE_IFELSE([AC_LANG_SOURCE([void foo (void) { }])],
242+ ac_cv_cc_wextra=yes, ac_cv_cc_wextra=no)
243+CFLAGS="$old_CFLAGS"])
244+AC_SUBST(WEXTRA)
245+AS_IF([test "x$ac_cv_cc_wextra" = xyes], [WEXTRA=-Wextra], [WEXTRA=-W])
246+
247+AC_CACHE_CHECK([for -fgnu89-inline option to $CC], ac_cv_cc_gnu89_inline, [dnl
248+old_CFLAGS="$CFLAGS"
249+CFLAGS="$CFLAGS -fgnu89-inline -Werror"
250+AC_COMPILE_IFELSE([AC_LANG_SOURCE([
251+void foo (void)
252+{
253+ inline void bar (void) {}
254+ bar ();
255+}
256+extern inline void baz (void) {}
257+])], ac_cv_cc_gnu89_inline=yes, ac_cv_cc_gnu89_inline=no)
258+CFLAGS="$old_CFLAGS"])
259+AS_IF([test "x$ac_cv_cc_gnu89_inline" = xyes],
260+ [WEXTRA="${WEXTRA:+$WEXTRA }-fgnu89-inline"])
261+
262+AC_CACHE_CHECK([for --as-needed linker option],
263+ ac_cv_as_needed, [dnl
264+cat > conftest.c <<EOF
265+int main (void) { return 0; }
266+EOF
267+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
268+ -fPIC -shared -o conftest.so conftest.c
269+ -Wl,--as-needed 1>&AS_MESSAGE_LOG_FD])
270+then
271+ ac_cv_as_needed=yes
272+else
273+ ac_cv_as_needed=no
274+fi
275+rm -f conftest*])
276+AS_IF([test "x$ac_cv_as_needed" = xyes],
277+ [LD_AS_NEEDED=-Wl,--as-needed], [LD_AS_NEEDED=])
278+AC_SUBST(LD_AS_NEEDED)
279+
280+AC_CACHE_CHECK([for __builtin_popcount], ac_cv_popcount, [dnl
281+AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[exit (__builtin_popcount (127));]])],
282+ ac_cv_popcount=yes, ac_cv_popcount=no)])
283+AS_IF([test "x$ac_cv_popcount" = xyes],
284+ [AC_DEFINE([HAVE_BUILTIN_POPCOUNT], [1], [Have __builtin_popcount.])])
285+
286+
287 AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl
288 # Use the same flags that we use for our DSOs, so the test is representative.
289 # Some old compiler/linker/libc combinations fail some ways and not others.
290@@ -122,7 +171,10 @@ static __thread int a; int foo (int b) { return a + b; }]],
291 CFLAGS="$save_CFLAGS"
292 LDFLAGS="$save_LDFLAGS"])
293 AS_IF([test "x$ac_cv_tls" != xyes],
294- AC_MSG_ERROR([__thread support required]))
295+ [AS_IF([test "$use_locks" = yes],
296+ [AC_MSG_ERROR([--enable-thread-safety requires __thread support])],
297+ [AC_DEFINE([__thread], [/* empty: no multi-thread support */],
298+ [Stubbed out if missing compiler support.])])])
299
300 dnl This test must come as early as possible after the compiler configuration
301 dnl tests, because the choice of the file model can (in principle) affect
302@@ -224,6 +276,11 @@ AM_CONDITIONAL(USE_VALGRIND, test "$use_valgrind" = yes)
303 AM_CONDITIONAL(BUILD_STATIC, [dnl
304 test "$use_gprof" = yes -o "$use_gcov" = yes])
305
306+AC_ARG_ENABLE([werror],
307+AS_HELP_STRING([--disable-werror],[do not build with -Werror]),
308+ [enable_werror=$enableval], [enable_werror=yes])
309+AM_CONDITIONAL(BUILD_WERROR, test "$enable_werror" = yes)
310+
311 AC_ARG_ENABLE([tests-rpath],
312 AS_HELP_STRING([--enable-tests-rpath],[build $ORIGIN-using rpath into tests]),
313 [tests_use_rpath=$enableval], [tests_use_rpath=no])
314@@ -388,7 +445,7 @@ case "$eu_version" in
315 esac
316
317 # Round up to the next release API (x.y) version.
318-eu_version=$(( (eu_version + 999) / 1000 ))
319+eu_version=`expr \( $eu_version + 999 \) / 1000`
320
321 dnl Unique ID for this build.
322 MODVERSION="Build for ${LIBEBL_SUBDIR} ${eu_version} ${ac_cv_build}"
323diff --git a/lib/ChangeLog b/lib/ChangeLog
324index d04bf17..720c98d 100644
325--- a/lib/ChangeLog
326+++ b/lib/ChangeLog
327@@ -73,6 +73,9 @@
328
329 2009-01-23 Roland McGrath <roland@redhat.com>
330
331+ * eu-config.h [! HAVE_BUILTIN_POPCOUNT]
332+ (__builtin_popcount): New inline function.
333+
334 * eu-config.h: Add multiple inclusion protection.
335
336 2009-01-17 Ulrich Drepper <drepper@redhat.com>
337@@ -129,6 +132,11 @@
338 * Makefile.am (libeu_a_SOURCES): Add it.
339 * system.h: Declare crc32_file.
340
341+2005-02-07 Roland McGrath <roland@redhat.com>
342+
343+ * Makefile.am (WEXTRA): New variable, substituted by configure.
344+ (AM_CFLAGS): Use it in place of -Wextra.
345+
346 2005-04-30 Ulrich Drepper <drepper@redhat.com>
347
348 * Makefile.am: Use -ffunction-sections for xmalloc.c.
349diff --git a/lib/eu-config.h b/lib/eu-config.h
350index 400cdc6..872f6bc 100644
351--- a/lib/eu-config.h
352+++ b/lib/eu-config.h
353@@ -163,6 +163,16 @@ asm (".section predict_data, \"aw\"; .previous\n"
354 /* This macro is used by the tests conditionalize for standalone building. */
355 #define ELFUTILS_HEADER(name) <lib##name.h>
356
357+#ifndef HAVE_BUILTIN_POPCOUNT
358+# define __builtin_popcount hakmem_popcount
359+static inline unsigned int __attribute__ ((unused))
360+hakmem_popcount (unsigned int x)
361+{
362+ /* HAKMEM 169 */
363+ unsigned int n = x - ((x >> 1) & 033333333333) - ((x >> 2) & 011111111111);
364+ return ((n + (n >> 3)) & 030707070707) % 63;
365+}
366+#endif /* HAVE_BUILTIN_POPCOUNT */
367
368 #ifdef SYMBOL_VERSIONING
369 # define OLD_VERSION(name, version) \
370diff --git a/libasm/ChangeLog b/libasm/ChangeLog
371index 9b25af9..32b9fd0 100644
372--- a/libasm/ChangeLog
373+++ b/libasm/ChangeLog
374@@ -87,6 +87,11 @@
375 * asm_error.c: Add new error ASM_E_IOERROR.
376 * libasmP.h: Add ASM_E_IOERROR definition.
377
378+2005-05-31 Roland McGrath <roland@redhat.com>
379+
380+ * Makefile.am (WEXTRA): New variable, substituted by configure.
381+ (AM_CFLAGS): Use it in place of -Wextra.
382+
383 2005-02-15 Ulrich Drepper <drepper@redhat.com>
384
385 * Makefile.am (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2.
386diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog
387index a20f440..5ea23b7 100644
388--- a/libcpu/ChangeLog
389+++ b/libcpu/ChangeLog
390@@ -51,6 +51,9 @@
391
392 2009-01-23 Roland McGrath <roland@redhat.com>
393
394+ * i386_disasm.c (i386_disasm): Add abort after assert-constant for old
395+ compilers that don't realize it's noreturn.
396+
397 * Makefile.am (i386_parse_CFLAGS): Use quotes around command
398 substitution that can produce leading whitespace.
399
400@@ -380,6 +383,11 @@
401 * defs/i386.doc: New file.
402 * defs/x86_64: New file.
403
404+2005-04-04 Roland McGrath <roland@redhat.com>
405+
406+ * Makefile.am (WEXTRA): New variable, substituted by configure.
407+ (AM_CFLAGS): Use it instead of -Wextra.
408+
409 2005-02-15 Ulrich Drepper <drepper@redhat.com>
410
411 * Makefile (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2.
412diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c
413index 832241f..c7a0df0 100644
414--- a/libcpu/i386_disasm.c
415+++ b/libcpu/i386_disasm.c
416@@ -822,6 +822,7 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
417
418 default:
419 assert (! "INVALID not handled");
420+ abort ();
421 }
422 }
423 else
424diff --git a/libdw/ChangeLog b/libdw/ChangeLog
425index 487e34a..06c737b 100644
426--- a/libdw/ChangeLog
427+++ b/libdw/ChangeLog
428@@ -889,6 +889,10 @@
429
430 * Makefile.am (known-dwarf.h): Run gawk on config/known-dwarf.awk.
431
432+2011-07-20 Mark Wielaard <mjw@redhat.com>
433+
434+ * dwarf_begin_elf.c: Add fallback for be64toh if not defined.
435+
436 2011-07-14 Mark Wielaard <mjw@redhat.com>
437
438 * libdw.h (dwarf_offdie): Fix documentation to mention .debug_info.
439@@ -1248,6 +1252,10 @@
440
441 * dwarf_hasattr_integrate.c: Integrate DW_AT_specification too.
442
443+2009-08-17 Roland McGrath <roland@redhat.com>
444+
445+ * libdw.h: Disable extern inlines for GCC 4.2.
446+
447 2009-08-10 Roland McGrath <roland@redhat.com>
448
449 * dwarf_getscopevar.c: Use dwarf_diename.
450@@ -2016,6 +2024,11 @@
451
452 2005-05-31 Roland McGrath <roland@redhat.com>
453
454+ * Makefile.am (WEXTRA): New variable, substituted by configure.
455+ (AM_CFLAGS): Use it in place of -Wextra.
456+
457+2005-05-31 Roland McGrath <roland@redhat.com>
458+
459 * dwarf_formref_die.c (dwarf_formref_die): Add CU header offset to
460 formref offset.
461
462diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
463index 4e0d590..a6616a1 100644
464--- a/libdw/dwarf_begin_elf.c
465+++ b/libdw/dwarf_begin_elf.c
466@@ -47,6 +47,14 @@
467 #if USE_ZLIB
468 # include <endian.h>
469 # define crc32 loser_crc32
470+# ifndef be64toh
471+# include <byteswap.h>
472+# if __BYTE_ORDER == __LITTLE_ENDIAN
473+# define be64toh(x) bswap_64 (x)
474+# else
475+# define be64toh(x) (x)
476+# endif
477+# endif
478 # include <zlib.h>
479 # undef crc32
480 #endif
481diff --git a/libdw/libdw.h b/libdw/libdw.h
482index 473e1a2..5a511cd 100644
483--- a/libdw/libdw.h
484+++ b/libdw/libdw.h
485@@ -1004,7 +1004,7 @@ extern Dwarf_OOM dwarf_new_oom_handler (Dwarf *dbg, Dwarf_OOM handler);
486
487
488 /* Inline optimizations. */
489-#ifdef __OPTIMIZE__
490+#if defined __OPTIMIZE__ && !(__GNUC__ == 4 && __GNUC_MINOR__ == 2)
491 /* Return attribute code of given attribute. */
492 __libdw_extern_inline unsigned int
493 dwarf_whatattr (Dwarf_Attribute *attr)
494diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
495index a5253e2..59abfac 100644
496--- a/libdwfl/ChangeLog
497+++ b/libdwfl/ChangeLog
498@@ -704,6 +704,21 @@
499 (dwfl_module_addrsym) (i_to_symfile): New function.
500 (dwfl_module_addrsym) (search_table): Use it.
501
502+2013-11-09 Jan Kratochvil <jan.kratochvil@redhat.com>
503+
504+ Older OS compatibility bits.
505+ * linux-core-attach.c (be64toh, le64toh, be32toh, le32toh): Provide
506+ fallbacks if not defined by system.
507+
508+2013-11-09 Jan Kratochvil <jan.kratochvil@redhat.com>
509+
510+ Handle T-stopped detach for old kernels.
511+ * linux-pid-attach.c (struct pid_arg): New field stopped.
512+ (ptrace_attach): New parameter stoppedp. Set it appropriately.
513+ (pid_set_initial_registers): Pass the new field.
514+ (pid_thread_detach): Handle the case of STOPPED for old kernels.
515+ (__libdwfl_attach_state_for_pid): Initialize STOPPED.
516+
517 2013-11-07 Jan Kratochvil <jan.kratochvil@redhat.com>
518 Mark Wielaard <mjw@redhat.com>
519
520@@ -2469,6 +2484,11 @@
521
522 2005-07-21 Roland McGrath <roland@redhat.com>
523
524+ * Makefile.am (WEXTRA): New variable, substituted by configure.
525+ (AM_CFLAGS): Use it in place of -Wextra.
526+
527+2005-07-21 Roland McGrath <roland@redhat.com>
528+
529 * Makefile.am (noinst_HEADERS): Add loc2c.c.
530
531 * test2.c (main): Check sscanf result to quiet warning.
532diff --git a/libdwfl/linux-core-attach.c b/libdwfl/linux-core-attach.c
533index 5a7b3b3..d05ac7e 100644
534--- a/libdwfl/linux-core-attach.c
535+++ b/libdwfl/linux-core-attach.c
536@@ -29,6 +29,35 @@
537 #include "libdwflP.h"
538 #include <fcntl.h>
539 #include "system.h"
540+#include <endian.h>
541+#include <byteswap.h>
542+#if __BYTE_ORDER == __LITTLE_ENDIAN
543+# ifndef be64toh
544+# define be64toh(x) bswap_64 (x)
545+# endif
546+# ifndef le64toh
547+# define le64toh(x) (x)
548+# endif
549+# ifndef be32toh
550+# define be32toh(x) bswap_32 (x)
551+# endif
552+# ifndef le32toh
553+# define le32toh(x) (x)
554+# endif
555+#else
556+# ifndef be64toh
557+# define be64toh(x) (x)
558+# endif
559+# ifndef le64toh
560+# define le64toh(x) bswap_64 (x)
561+# endif
562+# ifndef be32toh
563+# define be32toh(x) (x)
564+# endif
565+# ifndef le32toh
566+# define le32toh(x) bswap_32 (x)
567+# endif
568+#endif
569
570 #include "../libdw/memory-access.h"
571
572diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c
573index ae71702..076b2c3 100644
574--- a/libdwfl/linux-pid-attach.c
575+++ b/libdwfl/linux-pid-attach.c
576@@ -255,6 +255,11 @@ void
577 internal_function
578 __libdwfl_ptrace_detach (pid_t tid, bool tid_was_stopped)
579 {
580+ // Older kernels (tested kernel-2.6.18-348.12.1.el5.x86_64) need special
581+ // handling of the detachment to keep the process State: T (stopped).
582+ if (tid_was_stopped)
583+ syscall (__NR_tkill, tid, SIGSTOP);
584+
585 /* This handling is needed only on older Linux kernels such as
586 2.6.32-358.23.2.el6.ppc64. Later kernels such as
587 3.11.7-200.fc19.x86_64 remember the T (stopped) state
588@@ -262,6 +267,15 @@ __libdwfl_ptrace_detach (pid_t tid, bool tid_was_stopped)
589 PTRACE_DETACH. */
590 ptrace (PTRACE_DETACH, tid, NULL,
591 (void *) (intptr_t) (tid_was_stopped ? SIGSTOP : 0));
592+
593+ if (tid_was_stopped)
594+ {
595+ // Wait till the SIGSTOP settles down.
596+ int i;
597+ for (i = 0; i < 100000; i++)
598+ if (linux_proc_pid_is_stopped (tid))
599+ break;
600+ }
601 }
602
603 static void
604diff --git a/libebl/ChangeLog b/libebl/ChangeLog
605index 51ae60f..aee0217 100644
606--- a/libebl/ChangeLog
607+++ b/libebl/ChangeLog
608@@ -780,6 +780,11 @@
609 * Makefile.am (libebl_*_so_SOURCES): Set to $(*_SRCS) so dependency
610 tracking works right.
611
612+2005-05-31 Roland McGrath <roland@redhat.com>
613+
614+ * Makefile.am (WEXTRA): New variable, substituted by configure.
615+ (AM_CFLAGS): Use it in place of -Wextra.
616+
617 2005-05-21 Ulrich Drepper <drepper@redhat.com>
618
619 * libebl_x86_64.map: Add x86_64_core_note.
620diff --git a/libelf/ChangeLog b/libelf/ChangeLog
621index 30017cd..9ca9c73 100644
622--- a/libelf/ChangeLog
623+++ b/libelf/ChangeLog
624@@ -398,6 +398,11 @@
625
626 * elf-knowledge.h (SECTION_STRIP_P): Remove < SHT_NUM check.
627
628+2011-03-10 Roland McGrath <roland@redhat.com>
629+
630+ * gnuhash_xlate.h (elf_cvt_gnuhash): Avoid post-increment in bswap_32
631+ argument, since some implementations are buggy macros.
632+
633 2011-02-26 Mark Wielaard <mjw@redhat.com>
634
635 * elf_end.c (elf_end): Call rwlock_unlock before rwlock_fini.
636@@ -1075,6 +1080,11 @@
637
638 * elf.h: Update from glibc.
639
640+2005-05-31 Roland McGrath <roland@redhat.com>
641+
642+ * Makefile.am (WEXTRA): New variable, substituted by configure.
643+ (AM_CFLAGS): Use it in place of -Wextra.
644+
645 2005-05-08 Roland McGrath <roland@redhat.com>
646
647 * elf_begin.c (read_file) [_MUDFLAP]: Don't use mmap for now.
648diff --git a/libelf/common.h b/libelf/common.h
649index 744f1bb..185ea59 100644
650--- a/libelf/common.h
651+++ b/libelf/common.h
652@@ -139,7 +139,7 @@ libelf_release_all (Elf *elf)
653 (Var) = (sizeof (Var) == 1 \
654 ? (unsigned char) (Var) \
655 : (sizeof (Var) == 2 \
656- ? bswap_16 (Var) \
657+ ? (unsigned short int) bswap_16 (Var) \
658 : (sizeof (Var) == 4 \
659 ? bswap_32 (Var) \
660 : bswap_64 (Var))))
661@@ -148,7 +148,7 @@ libelf_release_all (Elf *elf)
662 (Dst) = (sizeof (Var) == 1 \
663 ? (unsigned char) (Var) \
664 : (sizeof (Var) == 2 \
665- ? bswap_16 (Var) \
666+ ? (unsigned short int) bswap_16 (Var) \
667 : (sizeof (Var) == 4 \
668 ? bswap_32 (Var) \
669 : bswap_64 (Var))))
670diff --git a/libelf/gnuhash_xlate.h b/libelf/gnuhash_xlate.h
671index 04d9ca1..3e25936 100644
672--- a/libelf/gnuhash_xlate.h
673+++ b/libelf/gnuhash_xlate.h
674@@ -1,5 +1,5 @@
675 /* Conversion functions for versioning information.
676- Copyright (C) 2006, 2007 Red Hat, Inc.
677+ Copyright (C) 2006-2011 Red Hat, Inc.
678 This file is part of elfutils.
679 Written by Ulrich Drepper <drepper@redhat.com>, 2006.
680
681@@ -69,7 +69,9 @@ elf_cvt_gnuhash (void *dest, const void *src, size_t len, int encode)
682 dest32 = (Elf32_Word *) &dest64[bitmask_words];
683 while (len >= 4)
684 {
685- *dest32++ = bswap_32 (*src32++);
686+ *dest32 = bswap_32 (*src32);
687+ ++dest32;
688+ ++src32;
689 len -= 4;
690 }
691 }
692diff --git a/src/ChangeLog b/src/ChangeLog
693index 15e6fae..78535c8 100644
694--- a/src/ChangeLog
695+++ b/src/ChangeLog
696@@ -1598,8 +1598,16 @@
697 * readelf.c (attr_callback): Use print_block only when we don't use
698 print_ops.
699
700+2009-08-17 Roland McGrath <roland@redhat.com>
701+
702+ * ld.h: Disable extern inlines for GCC 4.2.
703+
704 2009-08-14 Roland McGrath <roland@redhat.com>
705
706+ * strings.c (read_block): Conditionalize posix_fadvise use
707+ on [POSIX_FADV_SEQUENTIAL].
708+ From Petr Salinger <Petr.Salinger@seznam.cz>.
709+
710 * ar.c (do_oper_extract): Use pathconf instead of statfs.
711
712 2009-08-01 Ulrich Drepper <drepper@redhat.com>
713@@ -1763,6 +1771,8 @@
714 * readelf.c (print_debug_frame_section): Use t instead of j formats
715 for ptrdiff_t OFFSET.
716
717+ * addr2line.c (handle_address): Use %a instead of %m for compatibility.
718+
719 2009-01-21 Ulrich Drepper <drepper@redhat.com>
720
721 * elflint.c (check_program_header): Fix typo in .eh_frame_hdr section
722@@ -1946,6 +1956,11 @@
723 that matches its PT_LOAD's p_flags &~ PF_W. On sparc, PF_X really
724 is valid in RELRO.
725
726+2008-03-01 Roland McGrath <roland@redhat.com>
727+
728+ * readelf.c (dump_archive_index): Tweak portability hack
729+ to match [__GNUC__ < 4] too.
730+
731 2008-02-29 Roland McGrath <roland@redhat.com>
732
733 * readelf.c (print_attributes): Add a cast.
734@@ -2197,6 +2212,8 @@
735
736 * readelf.c (hex_dump): Fix rounding error in whitespace calculation.
737
738+ * Makefile.am (readelf_no_Werror): New variable.
739+
740 2007-10-15 Roland McGrath <roland@redhat.com>
741
742 * make-debug-archive.in: New file.
743@@ -2636,6 +2653,10 @@
744 * elflint.c (valid_e_machine): Add EM_ALPHA.
745 Reported by Christian Aichinger <Greek0@gmx.net>.
746
747+ * strings.c (map_file): Define POSIX_MADV_SEQUENTIAL to
748+ MADV_SEQUENTIAL if undefined. Don't call posix_madvise
749+ if neither is defined.
750+
751 2006-08-08 Ulrich Drepper <drepper@redhat.com>
752
753 * elflint.c (check_dynamic): Don't require DT_HASH for DT_SYMTAB.
754@@ -2712,6 +2733,10 @@
755 * Makefile.am: Add hacks to create dependency files for non-generic
756 linker.
757
758+2006-04-05 Roland McGrath <roland@redhat.com>
759+
760+ * strings.c (MAP_POPULATE): Define to 0 if undefined.
761+
762 2006-06-12 Ulrich Drepper <drepper@redhat.com>
763
764 * ldgeneric.c (ld_generic_generate_sections): Don't create .interp
765@@ -3060,6 +3085,11 @@
766 * readelf.c (print_debug_loc_section): Fix indentation for larger
767 address size.
768
769+2005-05-31 Roland McGrath <roland@redhat.com>
770+
771+ * Makefile.am (WEXTRA): New variable, substituted by configure.
772+ (AM_CFLAGS): Use it in place of -Wextra.
773+
774 2005-05-30 Roland McGrath <roland@redhat.com>
775
776 * readelf.c (print_debug_line_section): Print section offset of each
777diff --git a/src/Makefile.am b/src/Makefile.am
778index dbac3eb..9028aa1 100644
779--- a/src/Makefile.am
780+++ b/src/Makefile.am
781@@ -90,6 +90,11 @@ endif
782 ldgeneric_no_Wunused = yes
783 ldgeneric_no_Wstack_usage = yes
784
785+# Buggy old compilers or libc headers.
786+readelf_no_Werror = yes
787+strings_no_Werror = yes
788+addr2line_no_Wformat = yes
789+
790 # Bad, bad stack usage...
791 readelf_no_Wstack_usage = yes
792 nm_no_Wstack_usage = yes
793diff --git a/src/addr2line.c b/src/addr2line.c
794index 0ce854f..d2d0c8c 100644
795--- a/src/addr2line.c
796+++ b/src/addr2line.c
797@@ -622,10 +622,10 @@ handle_address (const char *string, Dwfl *dwfl)
798 bool parsed = false;
799 int i, j;
800 char *name = NULL;
801- if (sscanf (string, "(%m[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2
802+ if (sscanf (string, "(%a[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2
803 && string[i] == '\0')
804 parsed = adjust_to_section (name, &addr, dwfl);
805- switch (sscanf (string, "%m[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j))
806+ switch (sscanf (string, "%a[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j))
807 {
808 default:
809 break;
810diff --git a/src/findtextrel.c b/src/findtextrel.c
811index 264a06b..d7de202 100644
812--- a/src/findtextrel.c
813+++ b/src/findtextrel.c
814@@ -502,7 +502,11 @@ ptrcompare (const void *p1, const void *p2)
815
816
817 static void
818-check_rel (size_t nsegments, struct segments segments[nsegments],
819+check_rel (size_t nsegments, struct segments segments[
820+#if __GNUC__ >= 4
821+ nsegments
822+#endif
823+ ],
824 GElf_Addr addr, Elf *elf, Elf_Scn *symscn, Dwarf *dw,
825 const char *fname, bool more_than_one, void **knownsrcs)
826 {
827diff --git a/src/ld.h b/src/ld.h
828index 29f4031..8695c31 100644
829--- a/src/ld.h
830+++ b/src/ld.h
831@@ -1114,6 +1114,7 @@ extern bool dynamically_linked_p (void);
832
833 /* Checked whether the symbol is undefined and referenced from a DSO. */
834 extern bool linked_from_dso_p (struct scninfo *scninfo, size_t symidx);
835+#if defined __OPTIMIZE__ && !(__GNUC__ == 4 && __GNUC_MINOR__ == 2)
836 #ifdef __GNUC_STDC_INLINE__
837 __attribute__ ((__gnu_inline__))
838 #endif
839@@ -1131,5 +1132,6 @@ linked_from_dso_p (struct scninfo *scninfo, size_t symidx)
840
841 return sym->defined && sym->in_dso;
842 }
843+#endif /* Optimizing and not GCC 4.2. */
844
845 #endif /* ld.h */
846diff --git a/src/readelf.c b/src/readelf.c
847index b4cb3a8..606d220 100644
848--- a/src/readelf.c
849+++ b/src/readelf.c
850@@ -4364,10 +4364,12 @@ listptr_base (struct listptr *p)
851 return base;
852 }
853
854+static const char *listptr_name;
855+
856 static int
857-compare_listptr (const void *a, const void *b, void *arg)
858+compare_listptr (const void *a, const void *b)
859 {
860- const char *name = arg;
861+ const char *const name = listptr_name;
862 struct listptr *p1 = (void *) a;
863 struct listptr *p2 = (void *) b;
864
865@@ -4463,8 +4465,11 @@ static void
866 sort_listptr (struct listptr_table *table, const char *name)
867 {
868 if (table->n > 0)
869- qsort_r (table->table, table->n, sizeof table->table[0],
870- &compare_listptr, (void *) name);
871+ {
872+ listptr_name = name;
873+ qsort (table->table, table->n, sizeof table->table[0],
874+ &compare_listptr);
875+ }
876 }
877
878 static bool
879@@ -9561,7 +9566,7 @@ dump_archive_index (Elf *elf, const char *fname)
880 if (unlikely (elf_rand (elf, as_off) == 0)
881 || unlikely ((subelf = elf_begin (-1, ELF_C_READ_MMAP, elf))
882 == NULL))
883-#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7)
884+#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7) || __GNUC__ < 4
885 while (1)
886 #endif
887 error (EXIT_FAILURE, 0,
888diff --git a/src/strings.c b/src/strings.c
889index b2bce7b..fe0ab6c 100644
890--- a/src/strings.c
891+++ b/src/strings.c
892@@ -43,6 +43,10 @@
893
894 #include <system.h>
895
896+#ifndef MAP_POPULATE
897+# define MAP_POPULATE 0
898+#endif
899+
900
901 /* Prototypes of local functions. */
902 static int read_fd (int fd, const char *fname, off64_t fdlen);
903@@ -489,8 +493,13 @@ map_file (int fd, off64_t start_off, off64_t fdlen, size_t *map_sizep)
904 fd, start_off);
905 if (mem != MAP_FAILED)
906 {
907+#if !defined POSIX_MADV_SEQUENTIAL && defined MADV_SEQUENTIAL
908+# define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
909+#endif
910+#ifdef POSIX_MADV_SEQUENTIAL
911 /* We will go through the mapping sequentially. */
912 (void) posix_madvise (mem, map_size, POSIX_MADV_SEQUENTIAL);
913+#endif
914 break;
915 }
916 if (errno != EINVAL && errno != ENOMEM)
917@@ -581,9 +590,11 @@ read_block (int fd, const char *fname, off64_t fdlen, off64_t from, off64_t to)
918 elfmap_off = from & ~(ps - 1);
919 elfmap_base = elfmap = map_file (fd, elfmap_off, fdlen, &elfmap_size);
920
921+#ifdef POSIX_FADV_SEQUENTIAL
922 if (unlikely (elfmap == MAP_FAILED))
923 /* Let the kernel know we are going to read everything in sequence. */
924 (void) posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
925+#endif
926 }
927
928 if (unlikely (elfmap == MAP_FAILED))
929diff --git a/src/strip.c b/src/strip.c
930index 5e69334..8bd1790 100644
931--- a/src/strip.c
932+++ b/src/strip.c
933@@ -44,6 +44,12 @@
934 #include <libebl.h>
935 #include <system.h>
936
937+#ifdef HAVE_FUTIMES
938+# define FUTIMES(fd, fname, tvp) futimes (fd, tvp)
939+#else
940+# define FUTIMES(fd, fname, tvp) utimes (fname, tvp)
941+#endif
942+
943 typedef uint8_t GElf_Byte;
944
945 /* Name and version of program. */
946diff --git a/tests/ChangeLog b/tests/ChangeLog
947index 19878ac..6815028 100644
948--- a/tests/ChangeLog
949+++ b/tests/ChangeLog
950@@ -609,6 +609,13 @@
951
952 2013-12-02 Jan Kratochvil <jan.kratochvil@redhat.com>
953
954+ Handle T-stopped detach for old kernels.
955+ * backtrace.c: Include sys/syscall.h.
956+ (linux_proc_pid_is_stopped): New function.
957+ (ptrace_detach_stopped): Handle old kernels.
958+
959+2013-12-02 Jan Kratochvil <jan.kratochvil@redhat.com>
960+
961 * Makefile.am (check_PROGRAMS): Add backtrace, backtrace-child,
962 backtrace-data and backtrace-dwarf.
963 (BUILT_SOURCES, clean-local, backtrace-child-biarch): New.
964@@ -1473,6 +1480,8 @@
965
966 2008-01-21 Roland McGrath <roland@redhat.com>
967
968+ * line2addr.c (main): Revert last change.
969+
970 * testfile45.S.bz2: Add tests for cltq, cqto.
971 * testfile45.expect.bz2: Adjust.
972
973@@ -2181,6 +2190,11 @@
974 * Makefile.am (TESTS): Add run-elflint-test.sh.
975 (EXTRA_DIST): Add run-elflint-test.sh and testfile18.bz2.
976
977+2005-05-31 Roland McGrath <roland@redhat.com>
978+
979+ * Makefile.am (WEXTRA): New variable, substituted by configure.
980+ (AM_CFLAGS): Use it in place of -Wextra.
981+
982 2005-05-24 Ulrich Drepper <drepper@redhat.com>
983
984 * get-files.c (main): Use correct format specifier.
985diff --git a/tests/Makefile.am b/tests/Makefile.am
986index 425f8cd..69760a4 100644
987--- a/tests/Makefile.am
988+++ b/tests/Makefile.am
989@@ -382,6 +382,7 @@ get_lines_LDADD = $(libdw) $(libelf)
990 get_files_LDADD = $(libdw) $(libelf)
991 get_aranges_LDADD = $(libdw) $(libelf)
992 allfcts_LDADD = $(libdw) $(libelf)
993+line2addr_no_Wformat = yes
994 line2addr_LDADD = $(libdw) $(argp_LDADD)
995 addrscopes_LDADD = $(libdw) $(argp_LDADD)
996 funcscopes_LDADD = $(libdw) $(argp_LDADD)
997diff --git a/tests/backtrace.c b/tests/backtrace.c
998index abd56ab..6a7c661 100644
999--- a/tests/backtrace.c
1000+++ b/tests/backtrace.c
1001@@ -36,6 +36,7 @@
1002 #include <fcntl.h>
1003 #include <string.h>
1004 #include <argp.h>
1005+#include <sys/syscall.h>
1006 #include ELFUTILS_HEADER(dwfl)
1007
1008 #ifndef __linux__
1009diff --git a/tests/line2addr.c b/tests/line2addr.c
1010index e0d65d3..7c171b9 100644
1011--- a/tests/line2addr.c
1012+++ b/tests/line2addr.c
1013@@ -124,7 +124,7 @@ main (int argc, char *argv[])
1014 {
1015 struct args a = { .arg = argv[cnt] };
1016
1017- switch (sscanf (a.arg, "%m[^:]:%d", &a.file, &a.line))
1018+ switch (sscanf (a.arg, "%a[^:]:%d", &a.file, &a.line))
1019 {
1020 default:
1021 case 0: