diff --git a/build.diff b/build.diff deleted file mode 100644 index ba0e745..0000000 --- a/build.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- - libelf/Makefile.am | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -Index: b/libelf/Makefile.am -=================================================================== ---- a/libelf/Makefile.am -+++ b/libelf/Makefile.am -@@ -125,11 +125,12 @@ libelf.so: libelf_pic.a libelf.map - else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ - fi - --install: install-am libelf.so -+install: install-am libelf.so libelf_pic.a - $(mkinstalldirs) $(DESTDIR)$(libdir) -- $(INSTALL_PROGRAM) libelf.so $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so -+ $(INSTALL) -m644 libelf.so $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so - ln -fs libelf-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libelf.so.$(VERSION) - ln -fs libelf.so.$(VERSION) $(DESTDIR)$(libdir)/libelf.so -+ $(INSTALL) -m644 libelf_pic.a $(DESTDIR)$(libdir)/libelf_pic.a - - uninstall: uninstall-am - rm -f $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so diff --git a/elfutils-0.137-dwarf-header-check-fix.diff b/elfutils-0.137-dwarf-header-check-fix.diff index 14808a8..2176c53 100644 --- a/elfutils-0.137-dwarf-header-check-fix.diff +++ b/elfutils-0.137-dwarf-header-check-fix.diff @@ -1,4 +1,16 @@ +From: Takashi Iwai +Subject: Fix for kernel debuginfo files +References: https://bugzilla.novell.com/show_bug.cgi?id=468247, comments 17-20 +References: https://bugzilla.novell.com/show_bug.cgi?id=433182 + +Above BZ originally occured with Systemtap testsuite (stmt_rel.exp). + +# stap -e 'probe kernel.statement("bio_put@fs/bio.c:*") {}' +semantic error: libdw failure (dwarf_getsrcfiles): invalid DWARF +... --- + + libdw/dwarf_getsrclines.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/elfutils-0.142-no-osl.tar.bz2 b/elfutils-0.142-no-osl.tar.bz2 deleted file mode 100644 index dd91fdd..0000000 --- a/elfutils-0.142-no-osl.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:114accfbfb80a136b076554c586d75a153e54e187f81715740b0d8570b0fb74d -size 1512351 diff --git a/elfutils-0.147.tar.bz2 b/elfutils-0.147.tar.bz2 new file mode 100644 index 0000000..847ca01 --- /dev/null +++ b/elfutils-0.147.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3dbcc2ac3d12a00f1d8fee4fa3fa8b61dfa7491d9e790e4b6a2af542d739848 +size 1777826 diff --git a/elfutils-0.97-ftruncate-mmap-fix.diff b/elfutils-0.97-ftruncate-mmap-fix.diff deleted file mode 100644 index fdb34be..0000000 --- a/elfutils-0.97-ftruncate-mmap-fix.diff +++ /dev/null @@ -1,83 +0,0 @@ ---- - libelf/elf_update.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 54 insertions(+) - -Index: b/libelf/elf_update.c -=================================================================== ---- a/libelf/elf_update.c -+++ b/libelf/elf_update.c -@@ -53,6 +53,7 @@ - #endif - - #include -+#include - #include - #include - #include -@@ -100,6 +101,33 @@ write_file (Elf *elf, off_t size, int ch - #endif - } - -+ /* -+ * We may have truncated the file so lets update the mapping before -+ * actually writing to the file. -+ */ -+ /* -+ else if (elf->map_address != NULL && elf->parent == NULL -+ && (elf->maximum_size != ~((size_t) 0) -+ && size != elf->maximum_size)) -+ { -+ void *new_address; -+ int ret; -+ fprintf(stderr, "sync old: %p\n", elf->map_address); -+ ret = msync(elf->map_address, elf->maximum_size, MS_SYNC); -+ if (ret) -+ perror("msync failed"); -+ new_address = mremap (elf->map_address, elf->maximum_size, -+ size, MREMAP_MAYMOVE); -+ if (unlikely (new_address == MAP_FAILED)) { -+ __libelf_seterrno (ELF_E_WRITE_ERROR); -+ return -1; -+ } -+ -+ fprintf(stderr, "old: %p, new: %p\n", elf->map_address, new_address); -+ elf->map_address = new_address; -+ } -+ */ -+ - if (elf->map_address != NULL) - { - /* The file is mmaped. */ -@@ -141,6 +169,32 @@ write_file (Elf *elf, off_t size, int ch - size = -1; - } - -+ if (elf->map_address != NULL && elf->parent == NULL -+ && (elf->maximum_size != ~((size_t) 0) -+ && (size > 0 && (size_t)size != elf->maximum_size))) -+ { -+ /* -+ * We may have truncated the file so lets update the mapping before -+ * actually writing to the file. -+ */ -+ void *new_address; -+ int ret; -+ -+ fprintf(stderr, "sync old: %p\n", elf->map_address); -+ ret = msync(elf->map_address, elf->maximum_size, MS_SYNC); -+ if (ret) -+ perror("msync failed"); -+ new_address = mremap (elf->map_address, elf->maximum_size, -+ size, MREMAP_MAYMOVE); -+ if (unlikely (new_address == MAP_FAILED)) { -+ __libelf_seterrno (ELF_E_WRITE_ERROR); -+ return -1; -+ } -+ -+ fprintf(stderr, "old: %p, new: %p\n", elf->map_address, new_address); -+ elf->map_address = new_address; -+ } -+ - if (size != -1 && elf->parent == NULL) - elf->maximum_size = size; - diff --git a/elfutils-no-po-test-build.diff b/elfutils-no-po-test-build.diff index dd3b5e1..60714f5 100644 --- a/elfutils-no-po-test-build.diff +++ b/elfutils-no-po-test-build.diff @@ -1,5 +1,9 @@ ---- Makefile.am-dist 2007-07-04 12:05:20.000000000 +0200 -+++ Makefile.am 2007-07-04 12:05:25.000000000 +0200 +From: unknown +Upstream: no +Subject: do not build po and tests components + +--- elfutils/Makefile.am-dist 2007-07-04 12:05:20.000000000 +0200 ++++ elfutils/Makefile.am 2007-07-04 12:05:25.000000000 +0200 @@ -29,7 +29,7 @@ # Add doc back when we have some real content. diff --git a/elfutils-old-scanf-fix.diff b/elfutils-old-scanf-fix.diff deleted file mode 100644 index d186b00..0000000 --- a/elfutils-old-scanf-fix.diff +++ /dev/null @@ -1,27 +0,0 @@ -Index: src/addr2line.c -=================================================================== ---- src/addr2line.c.orig 2009-04-21 16:50:01.000000000 +0200 -+++ src/addr2line.c 2009-08-20 13:11:58.000000000 +0200 -@@ -446,11 +446,11 @@ handle_address (const char *string, Dwfl - { - bool parsed = false; - int n; -- char *name = NULL; -- if (sscanf (string, "(%m[^)])%" PRIiMAX "%n", &name, &addr, &n) == 2 -+ char name[4096]; /* FIXME */ -+ if (sscanf (string, "(%[^)])%" PRIiMAX "%n", name, &addr, &n) == 2 - && string[n] == '\0') - parsed = adjust_to_section (name, &addr, dwfl); -- else if (sscanf (string, "%m[^-+]%" PRIiMAX "%n", &name, &addr, &n) == 2 -+ else if (sscanf (string, "%[^-+]%" PRIiMAX "%n", &name, &addr, &n) == 2 - && string[n] == '\0') - { - /* It was symbol+offset. */ -@@ -471,7 +471,6 @@ handle_address (const char *string, Dwfl - } - } - -- free (name); - if (!parsed) - return 1; - } diff --git a/elfutils-portability.patch b/elfutils-portability.patch index 71a1bf0..a1d758a 100644 --- a/elfutils-portability.patch +++ b/elfutils-portability.patch @@ -1,53 +1,23 @@ ---- - ChangeLog | 17 +++++++++++++++++ - Makefile.in | 2 ++ - backends/ChangeLog | 12 ++++++++++++ - backends/Makefile.am | 6 ++++-- - backends/Makefile.in | 8 +++++--- - config.h.in | 6 ++++++ - config/Makefile.in | 2 ++ - configure.ac | 38 +++++++++++++++++++++++++++++++++++++- - lib/ChangeLog | 8 ++++++++ - lib/Makefile.am | 3 ++- - lib/Makefile.in | 6 ++++-- - lib/eu-config.h | 11 +++++++++++ - libasm/ChangeLog | 5 +++++ - libasm/Makefile.am | 3 ++- - libasm/Makefile.in | 6 ++++-- - libcpu/ChangeLog | 8 ++++++++ - libcpu/Makefile.am | 3 ++- - libcpu/Makefile.in | 11 +++++++---- - libcpu/i386_disasm.c | 1 + - libdw/ChangeLog | 5 +++++ - libdw/Makefile.am | 3 ++- - libdw/Makefile.in | 7 +++++-- - libdwfl/ChangeLog | 5 +++++ - libdwfl/Makefile.am | 3 ++- - libdwfl/Makefile.in | 6 ++++-- - libebl/ChangeLog | 5 +++++ - libebl/Makefile.am | 3 ++- - libebl/Makefile.in | 6 ++++-- - libelf/ChangeLog | 5 +++++ - libelf/Makefile.am | 3 ++- - libelf/Makefile.in | 6 ++++-- - libelf/common.h | 4 ++-- - m4/Makefile.in | 2 ++ - src/ChangeLog | 20 ++++++++++++++++++++ - src/Makefile.am | 6 +++++- - src/Makefile.in | 9 +++++++-- - src/findtextrel.c | 6 +++++- - src/readelf.c | 2 +- - src/strings.c | 9 +++++++++ - src/strip.c | 20 ++++++++++++++++++-- - tests/ChangeLog | 7 +++++++ - tests/Makefile.am | 5 +++-- - tests/Makefile.in | 6 ++++-- - tests/line2addr.c | 2 +- - 44 files changed, 268 insertions(+), 43 deletions(-) +From: Tony Jones +Subject: Elfutils portability patch +Version: 0.147 +References: https://fedorahosted.org/releases/e/l/elfutils/elfutils-portability.patch +Upstream: yes ---- a/backends/ChangeLog -+++ b/backends/ChangeLog -@@ -48,6 +48,10 @@ +This patch contains portability fixes that are regarded as generally useful +by the community but are not accepted by the elfutils maintainer (and are +therefore not in the git repository). + + +Following change is removed from the patch (as Factory is built using +GNU_SOURCE and thus %a is interpreted as having a float param): + ++ * addr2line.c (handle_address): Use %a instead of %m for compatibility. ++ + +--- elfutils/backends/ChangeLog ++++ elfutils/backends/ChangeLog +@@ -106,6 +106,10 @@ * ppc_attrs.c (ppc_check_object_attribute): Handle tag GNU_Power_ABI_Struct_Return. @@ -58,7 +28,7 @@ 2008-10-04 Ulrich Drepper * i386_reloc.def: Fix entries for TLS_GOTDESC, TLS_DESC_CALL, and -@@ -375,6 +379,11 @@ +@@ -433,6 +437,11 @@ * sparc_init.c: Likewise. * x86_64_init.c: Likewise. @@ -70,7 +40,7 @@ 2005-11-19 Roland McGrath * ppc64_reloc.def: REL30 -> ADDR30. -@@ -397,6 +406,9 @@ +@@ -455,6 +464,9 @@ * Makefile.am (uninstall): Don't try to remove $(pkgincludedir). (CLEANFILES): Add libebl_$(m).so. @@ -80,36 +50,20 @@ * ppc_reloc.def: Update bits per Alan Modra . * ppc64_reloc.def: Likewise. ---- a/backends/Makefile.am -+++ b/backends/Makefile.am -@@ -25,12 +25,14 @@ - ## . - ## - DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\" -+WEXTRA = @WEXTRA@ -+LD_AS_NEEDED = @LD_AS_NEEDED@ - if MUDFLAP - AM_CFLAGS = -fmudflap - else - AM_CFLAGS = - endif --AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 \ -+AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 \ - -std=gnu99 - INCLUDES = -I$(srcdir) -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \ - -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ -@@ -115,7 +117,7 @@ - $(LINK) -shared -o $@ -Wl,--whole-archive,$<\ - $(cpu_$(@:libebl_%.so=%)) -Wl,--no-whole-archive \ - -Wl,--version-script,$(word 2,$^) \ +--- elfutils/backends/Makefile.am ++++ elfutils/backends/Makefile.am +@@ -103,7 +103,7 @@ libebl_%.so libebl_%.map: libebl_%_pic.a + $(LINK) -shared -o $(@:.map=.so) \ + -Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \ + -Wl,--version-script,$(@:.so=.map) \ - -Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw) $(libmudflap) + -Wl,-z,defs $(LD_AS_NEEDED) $(libelf) $(libdw) $(libmudflap) $(textrel_check) - # XXX Should not be needed... ---- a/backends/Makefile.in -+++ b/backends/Makefile.in -@@ -159,6 +159,7 @@ + libebl_i386.so: $(cpu_i386) +--- elfutils/backends/Makefile.in ++++ elfutils/backends/Makefile.in +@@ -165,6 +165,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -117,38 +71,57 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -188,6 +189,7 @@ +@@ -193,6 +194,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ -@@ -245,9 +247,9 @@ - top_srcdir = @top_srcdir@ - zip_LIBS = @zip_LIBS@ - @MUDFLAP_FALSE@AM_CFLAGS = -fpic -Wall -Wshadow -Werror -Wunused \ --@MUDFLAP_FALSE@ -Wextra -Wformat=2 -std=gnu99 -+@MUDFLAP_FALSE@ $(WEXTRA) -Wformat=2 -std=gnu99 - @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -fpic -Wall -Wshadow -Werror \ --@MUDFLAP_TRUE@ -Wunused -Wextra -Wformat=2 -std=gnu99 -+@MUDFLAP_TRUE@ -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 - INCLUDES = -I$(srcdir) -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \ - -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ - -I$(top_srcdir)/lib -I.. -@@ -652,7 +654,7 @@ - $(LINK) -shared -o $@ -Wl,--whole-archive,$<\ - $(cpu_$(@:libebl_%.so=%)) -Wl,--no-whole-archive \ - -Wl,--version-script,$(word 2,$^) \ + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +@@ -256,7 +258,7 @@ INCLUDES = -I. -I$(srcdir) -I$(top_srcdi + -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw + AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ + $($(*F)_no_Werror),,-Werror) $(if \ +- $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ ++ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ + $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ + $(am__append_1) + @MUDFLAP_FALSE@libmudflap = +@@ -697,7 +699,7 @@ libebl_%.so libebl_%.map: libebl_%_pic.a + $(LINK) -shared -o $(@:.map=.so) \ + -Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \ + -Wl,--version-script,$(@:.so=.map) \ - -Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw) $(libmudflap) + -Wl,-z,defs $(LD_AS_NEEDED) $(libelf) $(libdw) $(libmudflap) $(textrel_check) - # XXX Should not be needed... ---- a/ChangeLog -+++ b/ChangeLog -@@ -9,6 +9,8 @@ + libebl_i386.so: $(cpu_i386) +--- elfutils/ChangeLog ++++ elfutils/ChangeLog +@@ -2,6 +2,10 @@ + + * configure.ac (LOCALEDIR, DATADIRNAME): Removed. + ++2009-11-22 Roland McGrath ++ ++ * configure.ac: Use sed and expr instead of modern bash extensions. ++ + 2009-09-21 Ulrich Drepper + + * configure.ac: Update for more modern autoconf. +@@ -10,6 +14,10 @@ + + * configure.ac (zip_LIBS): Check for liblzma too. + ++2009-08-17 Roland McGrath ++ ++ * configure.ac: Check for -fgnu89-inline; add it to WEXTRA if it works. ++ + 2009-04-19 Roland McGrath + + * configure.ac (eu_version): Round down here, not in version.h macros. +@@ -21,6 +29,8 @@ 2009-01-23 Roland McGrath @@ -157,7 +130,7 @@ * configure.ac (zlib check): Check for gzdirect, need zlib >= 1.2.2.3. * configure.ac (__thread check): Use AC_LINK_IFELSE, in case of -@@ -89,6 +91,10 @@ +@@ -101,6 +111,10 @@ * configure.ac: Add dummy automake conditional to get dependencies for non-generic linker right. See src/Makefile.am. @@ -168,7 +141,7 @@ 2005-11-18 Roland McGrath * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): New variable. -@@ -136,6 +142,17 @@ +@@ -148,6 +162,17 @@ * Makefile.am (all_SUBDIRS): Add libdwfl. * configure.ac: Write libdwfl/Makefile. @@ -186,9 +159,27 @@ 2005-05-19 Roland McGrath * configure.ac [AH_BOTTOM] (INTDECL, _INTDECL): New macros. ---- a/config/Makefile.in -+++ b/config/Makefile.in -@@ -73,6 +73,7 @@ +--- elfutils/config/eu.am ++++ elfutils/config/eu.am +@@ -25,11 +25,14 @@ + ## . + ## + ++WEXTRA = @WEXTRA@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ ++ + DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"' + INCLUDES = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. + AM_CFLAGS = -std=gnu99 -Wall -Wshadow \ + $(if $($(*F)_no_Werror),,-Werror) \ +- $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ ++ $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \ + $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \ + $($(*F)_CFLAGS) + +--- elfutils/config/Makefile.in ++++ elfutils/config/Makefile.in +@@ -76,6 +76,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -196,16 +187,16 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -102,6 +103,7 @@ +@@ -104,6 +105,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ ---- a/config.h.in -+++ b/config.h.in + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +--- elfutils/config.h.in ++++ elfutils/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.ac by autoheader. */ @@ -223,9 +214,265 @@ +#undef __thread + #include ---- a/configure.ac -+++ b/configure.ac -@@ -74,6 +74,39 @@ +--- elfutils/configure ++++ elfutils/configure +@@ -646,6 +646,8 @@ NEVER_TRUE + base_cpu + NATIVE_LD_FALSE + NATIVE_LD_TRUE ++LD_AS_NEEDED ++WEXTRA + LEXLIB + LEX_OUTPUT_ROOT + LEX +@@ -4098,6 +4100,205 @@ $as_echo "$as_me: error: gcc with C99 su + fi + + ++{ $as_echo "$as_me:$LINENO: checking for -Wextra option to $CC" >&5 ++$as_echo_n "checking for -Wextra option to $CC... " >&6; } ++if test "${ac_cv_cc_wextra+set}" = set; then ++ $as_echo_n "(cached) " >&6 ++else ++ old_CFLAGS="$CFLAGS" ++CFLAGS="$CFLAGS -Wextra" ++cat >conftest.$ac_ext <<_ACEOF ++void foo (void) { } ++_ACEOF ++rm -f conftest.$ac_objext ++if { (ac_try="$ac_compile" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" ++$as_echo "$ac_try_echo") >&5 ++ (eval "$ac_compile") 2>conftest.er1 ++ ac_status=$? ++ grep -v '^ *+' conftest.er1 >conftest.err ++ rm -f conftest.er1 ++ cat conftest.err >&5 ++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); } && { ++ test -z "$ac_c_werror_flag" || ++ test ! -s conftest.err ++ } && test -s conftest.$ac_objext; then ++ ac_cv_cc_wextra=yes ++else ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ ac_cv_cc_wextra=no ++fi ++ ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++CFLAGS="$old_CFLAGS" ++fi ++{ $as_echo "$as_me:$LINENO: result: $ac_cv_cc_wextra" >&5 ++$as_echo "$ac_cv_cc_wextra" >&6; } ++ ++if test "x$ac_cv_cc_wextra" = xyes; then ++ WEXTRA=-Wextra ++else ++ WEXTRA=-W ++fi ++ ++ ++{ $as_echo "$as_me:$LINENO: checking for -fgnu89-inline option to $CC" >&5 ++$as_echo_n "checking for -fgnu89-inline option to $CC... " >&6; } ++if test "${ac_cv_cc_gnu89_inline+set}" = set; then ++ $as_echo_n "(cached) " >&6 ++else ++ old_CFLAGS="$CFLAGS" ++CFLAGS="$CFLAGS -fgnu89-inline -Werror" ++cat >conftest.$ac_ext <<_ACEOF ++ ++void foo (void) ++{ ++ inline void bar (void) {} ++ bar (); ++} ++extern inline void baz (void) {} ++ ++_ACEOF ++rm -f conftest.$ac_objext ++if { (ac_try="$ac_compile" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" ++$as_echo "$ac_try_echo") >&5 ++ (eval "$ac_compile") 2>conftest.er1 ++ ac_status=$? ++ grep -v '^ *+' conftest.er1 >conftest.err ++ rm -f conftest.er1 ++ cat conftest.err >&5 ++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); } && { ++ test -z "$ac_c_werror_flag" || ++ test ! -s conftest.err ++ } && test -s conftest.$ac_objext; then ++ ac_cv_cc_gnu89_inline=yes ++else ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ ac_cv_cc_gnu89_inline=no ++fi ++ ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++CFLAGS="$old_CFLAGS" ++fi ++{ $as_echo "$as_me:$LINENO: result: $ac_cv_cc_gnu89_inline" >&5 ++$as_echo "$ac_cv_cc_gnu89_inline" >&6; } ++if test "x$ac_cv_cc_gnu89_inline" = xyes; then ++ WEXTRA="${WEXTRA:+$WEXTRA }-fgnu89-inline" ++fi ++ ++ ++{ $as_echo "$as_me:$LINENO: checking for --as-needed linker option" >&5 ++$as_echo_n "checking for --as-needed linker option... " >&6; } ++if test "${ac_cv_as_needed+set}" = set; then ++ $as_echo_n "(cached) " >&6 ++else ++ cat > conftest.c <&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; } ++then ++ ac_cv_as_needed=yes ++else ++ ac_cv_as_needed=no ++fi ++rm -f conftest* ++fi ++{ $as_echo "$as_me:$LINENO: result: $ac_cv_as_needed" >&5 ++$as_echo "$ac_cv_as_needed" >&6; } ++if test "x$ac_cv_as_needed" = xyes; then ++ LD_AS_NEEDED=-Wl,--as-needed ++else ++ LD_AS_NEEDED= ++fi ++ ++ ++ ++{ $as_echo "$as_me:$LINENO: checking for __builtin_popcount" >&5 ++$as_echo_n "checking for __builtin_popcount... " >&6; } ++if test "${ac_cv_popcount+set}" = set; then ++ $as_echo_n "(cached) " >&6 ++else ++ cat >conftest.$ac_ext <<_ACEOF ++/* confdefs.h. */ ++_ACEOF ++cat confdefs.h >>conftest.$ac_ext ++cat >>conftest.$ac_ext <<_ACEOF ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++exit (__builtin_popcount (127)); ++ ; ++ return 0; ++} ++_ACEOF ++rm -f conftest.$ac_objext conftest$ac_exeext ++if { (ac_try="$ac_link" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" ++$as_echo "$ac_try_echo") >&5 ++ (eval "$ac_link") 2>conftest.er1 ++ ac_status=$? ++ grep -v '^ *+' conftest.er1 >conftest.err ++ rm -f conftest.er1 ++ cat conftest.err >&5 ++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); } && { ++ test -z "$ac_c_werror_flag" || ++ test ! -s conftest.err ++ } && test -s conftest$ac_exeext && { ++ test "$cross_compiling" = yes || ++ $as_test_x conftest$ac_exeext ++ }; then ++ ac_cv_popcount=yes ++else ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ ac_cv_popcount=no ++fi ++ ++rm -rf conftest.dSYM ++rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ ++ conftest$ac_exeext conftest.$ac_ext ++fi ++{ $as_echo "$as_me:$LINENO: result: $ac_cv_popcount" >&5 ++$as_echo "$ac_cv_popcount" >&6; } ++if test "x$ac_cv_popcount" = xyes; then ++ ++cat >>confdefs.h <<\_ACEOF ++#define HAVE_BUILTIN_POPCOUNT 1 ++_ACEOF ++ ++fi ++ ++ + { $as_echo "$as_me:$LINENO: checking for __thread support" >&5 + $as_echo_n "checking for __thread support... " >&6; } + if test "${ac_cv_tls+set}" = set; then +@@ -4163,9 +4364,18 @@ fi + { $as_echo "$as_me:$LINENO: result: $ac_cv_tls" >&5 + $as_echo "$ac_cv_tls" >&6; } + if test "x$ac_cv_tls" != xyes; then +- { { $as_echo "$as_me:$LINENO: error: __thread support required" >&5 +-$as_echo "$as_me: error: __thread support required" >&2;} ++ if test "$use_locks" = yes; then ++ { { $as_echo "$as_me:$LINENO: error: --enable-thread-safety requires __thread support" >&5 ++$as_echo "$as_me: error: --enable-thread-safety requires __thread support" >&2;} + { (exit 1); exit 1; }; } ++else ++ ++cat >>confdefs.h <<\_ACEOF ++#define __thread /* empty: no multi-thread support */ ++_ACEOF ++ ++fi ++ + fi + + +@@ -5454,7 +5664,7 @@ ac_config_files="$ac_config_files versio + + # 1.234 -> 1234 + case "$PACKAGE_VERSION" in +-[0-9].*) eu_version="${PACKAGE_VERSION/./}" ;; ++[0-9].*) eu_version=`echo "$PACKAGE_VERSION" | sed 's@\.@@'` ;; + *) { { $as_echo "$as_me:$LINENO: error: confused by version number '$PACKAGE_VERSION'" >&5 + $as_echo "$as_me: error: confused by version number '$PACKAGE_VERSION'" >&2;} + { (exit 1); exit 1; }; } ;; +@@ -5489,7 +5699,7 @@ $as_echo "$as_me: error: confused by ver + esac + + # Round up to the next release API (x.y) version. +-eu_version=$[($eu_version + 999) / 1000] ++eu_version=`expr \( $eu_version + 999 \) / 1000` + + cat >confcache <<\_ACEOF + # This file is a shell script that caches the results of configure +--- elfutils/configure.ac ++++ elfutils/configure.ac +@@ -73,6 +73,54 @@ CFLAGS="$old_CFLAGS"]) AS_IF([test "x$ac_cv_c99" != xyes], AC_MSG_ERROR([gcc with C99 support required])) @@ -238,6 +485,21 @@ +AC_SUBST(WEXTRA) +AS_IF([test "x$ac_cv_cc_wextra" = xyes], [WEXTRA=-Wextra], [WEXTRA=-W]) + ++AC_CACHE_CHECK([for -fgnu89-inline option to $CC], ac_cv_cc_gnu89_inline, [dnl ++old_CFLAGS="$CFLAGS" ++CFLAGS="$CFLAGS -fgnu89-inline -Werror" ++AC_COMPILE_IFELSE([ ++void foo (void) ++{ ++ inline void bar (void) {} ++ bar (); ++} ++extern inline void baz (void) {} ++], ac_cv_cc_gnu89_inline=yes, ac_cv_cc_gnu89_inline=no) ++CFLAGS="$old_CFLAGS"]) ++AS_IF([test "x$ac_cv_cc_gnu89_inline" = xyes], ++ [WEXTRA="${WEXTRA:+$WEXTRA }-fgnu89-inline"]) ++ +AC_CACHE_CHECK([for --as-needed linker option], + ac_cv_as_needed, [dnl +cat > conftest.c < -> 1234 + case "$PACKAGE_VERSION" in +-[[0-9]].*) eu_version="${PACKAGE_VERSION/./}" ;; ++[[0-9]].*) eu_version=`echo "$PACKAGE_VERSION" | sed 's@\.@@'` ;; + *) AC_MSG_ERROR([confused by version number '$PACKAGE_VERSION']) ;; + esac + case "$eu_version" in +@@ -280,6 +331,6 @@ case "$eu_version" in + esac + + # Round up to the next release API (x.y) version. +-[eu_version=$[($eu_version + 999) / 1000]] ++eu_version=`expr \( $eu_version + 999 \) / 1000` + + AC_OUTPUT +--- elfutils/lib/ChangeLog ++++ elfutils/lib/ChangeLog +@@ -8,6 +8,9 @@ + 2009-01-23 Roland McGrath + * eu-config.h [! HAVE_BUILTIN_POPCOUNT] @@ -288,7 +568,7 @@ * eu-config.h: Add multiple inclusion protection. 2009-01-17 Ulrich Drepper -@@ -56,6 +59,11 @@ +@@ -64,6 +67,11 @@ * Makefile.am (libeu_a_SOURCES): Add it. * system.h: Declare crc32_file. @@ -300,9 +580,9 @@ 2005-04-30 Ulrich Drepper * Makefile.am: Use -ffunction-sections for xmalloc.c. ---- a/lib/eu-config.h -+++ b/lib/eu-config.h -@@ -182,5 +182,16 @@ +--- elfutils/lib/eu-config.h ++++ elfutils/lib/eu-config.h +@@ -182,6 +182,17 @@ asm (".section predict_data, \"aw\"; .pr /* This macro is used by the tests conditionalize for standalone building. */ #define ELFUTILS_HEADER(name) @@ -318,27 +598,11 @@ +#endif /* HAVE_BUILTIN_POPCOUNT */ + - #endif /* eu-config.h */ ---- a/lib/Makefile.am -+++ b/lib/Makefile.am -@@ -25,12 +25,13 @@ - ## . - ## - DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -+WEXTRA = @WEXTRA@ - if MUDFLAP - AM_CFLAGS = -fmudflap - else - AM_CFLAGS = - endif --AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra $($(*F)_CFLAGS) -+AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) $($(*F)_CFLAGS) - INCLUDES = -I$(srcdir)/../libelf -I.. - - noinst_LIBRARIES = libeu.a ---- a/lib/Makefile.in -+++ b/lib/Makefile.in -@@ -94,6 +94,7 @@ + #ifdef SHARED + # define OLD_VERSION(name, version) \ +--- elfutils/lib/Makefile.in ++++ elfutils/lib/Makefile.in +@@ -99,6 +99,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -346,29 +610,26 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -123,6 +124,7 @@ +@@ -127,6 +128,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ -@@ -180,9 +182,9 @@ - top_srcdir = @top_srcdir@ - zip_LIBS = @zip_LIBS@ - @MUDFLAP_FALSE@AM_CFLAGS = -fpic -Wall -Wshadow -Werror -Wunused \ --@MUDFLAP_FALSE@ -Wextra $($(*F)_CFLAGS) -+@MUDFLAP_FALSE@ $(WEXTRA) $($(*F)_CFLAGS) - @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -fpic -Wall -Wshadow -Werror \ --@MUDFLAP_TRUE@ -Wunused -Wextra $($(*F)_CFLAGS) -+@MUDFLAP_TRUE@ -Wunused $(WEXTRA) $($(*F)_CFLAGS) - INCLUDES = -I$(srcdir)/../libelf -I.. - noinst_LIBRARIES = libeu.a - libeu_a_SOURCES = xstrndup.c xmalloc.c next_prime.c \ ---- a/libasm/ChangeLog -+++ b/libasm/ChangeLog -@@ -63,6 +63,11 @@ + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +@@ -189,7 +191,7 @@ INCLUDES = -I. -I$(srcdir) -I$(top_srcdi + -I$(srcdir)/../libelf + AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ + $($(*F)_no_Werror),,-Werror) $(if \ +- $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ ++ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ + $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ + $(am__append_1) -fpic + @MUDFLAP_FALSE@libmudflap = +--- elfutils/libasm/ChangeLog ++++ elfutils/libasm/ChangeLog +@@ -67,6 +67,11 @@ * asm_error.c: Add new error ASM_E_IOERROR. * libasmP.h: Add ASM_E_IOERROR definition. @@ -380,26 +641,9 @@ 2005-02-15 Ulrich Drepper * Makefile.am (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2. ---- a/libasm/Makefile.am -+++ b/libasm/Makefile.am -@@ -25,12 +25,13 @@ - ## . - ## - DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -+WEXTRA = @WEXTRA@ - if MUDFLAP - AM_CFLAGS = -fmudflap - else - AM_CFLAGS = - endif --AM_CFLAGS += -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 -+AM_CFLAGS += -std=gnu99 -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 - INCLUDES = -I. -I$(srcdir) -I.. \ - -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl -I$(top_srcdir)/libdw\ - -I$(top_srcdir)/lib ---- a/libasm/Makefile.in -+++ b/libasm/Makefile.in -@@ -128,6 +128,7 @@ +--- elfutils/libasm/Makefile.in ++++ elfutils/libasm/Makefile.in +@@ -147,6 +147,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -407,29 +651,26 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -157,6 +158,7 @@ +@@ -175,6 +176,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ -@@ -214,9 +216,9 @@ - top_srcdir = @top_srcdir@ - zip_LIBS = @zip_LIBS@ - @MUDFLAP_FALSE@AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Werror -Wunused \ --@MUDFLAP_FALSE@ -Wextra -Wformat=2 -+@MUDFLAP_FALSE@ $(WEXTRA) -Wformat=2 - @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -std=gnu99 -Wall -Wshadow -Werror \ --@MUDFLAP_TRUE@ -Wunused -Wextra -Wformat=2 -+@MUDFLAP_TRUE@ -Wunused $(WEXTRA) -Wformat=2 - INCLUDES = -I. -I$(srcdir) -I.. \ - -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl -I$(top_srcdir)/libdw\ - -I$(top_srcdir)/lib ---- a/libcpu/ChangeLog -+++ b/libcpu/ChangeLog -@@ -5,6 +5,9 @@ + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +@@ -238,7 +240,7 @@ INCLUDES = -I. -I$(srcdir) -I$(top_srcdi + -I$(top_srcdir)/libdw + AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ + $($(*F)_no_Werror),,-Werror) $(if \ +- $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ ++ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ + $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ + $(am__append_1) + @MUDFLAP_FALSE@libmudflap = +--- elfutils/libcpu/ChangeLog ++++ elfutils/libcpu/ChangeLog +@@ -9,6 +9,9 @@ 2009-01-23 Roland McGrath @@ -439,7 +680,7 @@ * Makefile.am (i386_parse_CFLAGS): Use quotes around command substitution that can produce leading whitespace. -@@ -334,6 +337,11 @@ +@@ -338,6 +341,11 @@ * defs/i386.doc: New file. * defs/x86_64: New file. @@ -451,9 +692,9 @@ 2005-02-15 Ulrich Drepper * Makefile (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2. ---- a/libcpu/i386_disasm.c -+++ b/libcpu/i386_disasm.c -@@ -791,6 +791,7 @@ +--- elfutils/libcpu/i386_disasm.c ++++ elfutils/libcpu/i386_disasm.c +@@ -791,6 +791,7 @@ i386_disasm (const uint8_t **startp, con default: assert (! "INVALID not handled"); @@ -461,21 +702,9 @@ } } else ---- a/libcpu/Makefile.am -+++ b/libcpu/Makefile.am -@@ -30,7 +30,8 @@ - else - AM_CFLAGS = - endif --AM_CFLAGS += -Wall -Wshadow -Wunused -Wextra -std=gnu99 -fpic \ -+WEXTRA = @WEXTRA@ -+AM_CFLAGS += -Wall -Wshadow -Wunused $(WEXTRA) -std=gnu99 -fpic \ - -fdollars-in-identifiers \ - $($(*F)_CFLAGS) \ - $(if $($(*F)_no_Werror),,-Werror) ---- a/libcpu/Makefile.in -+++ b/libcpu/Makefile.in -@@ -110,6 +110,7 @@ +--- elfutils/libcpu/Makefile.in ++++ elfutils/libcpu/Makefile.in +@@ -116,6 +116,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -483,33 +712,37 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = lex.$( ++ ++ * libdw.h: Disable extern inlines for GCC 4.2. ++ + 2009-08-10 Roland McGrath + + * dwarf_getscopevar.c: Use dwarf_diename. +@@ -850,6 +854,11 @@ 2005-05-31 Roland McGrath @@ -521,28 +754,20 @@ * dwarf_formref_die.c (dwarf_formref_die): Add CU header offset to formref offset. ---- a/libdw/Makefile.am -+++ b/libdw/Makefile.am -@@ -25,6 +25,7 @@ - ## . - ## - DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DIS_LIBDW -+WEXTRA = @WEXTRA@ - if MUDFLAP - AM_CFLAGS = -fmudflap - else -@@ -33,7 +34,7 @@ - if BUILD_STATIC - AM_CFLAGS += -fpic - endif --AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99 -+AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 $(WEXTRA) -std=gnu99 - INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib - VERSION = 1 +--- elfutils/libdw/libdw.h ++++ elfutils/libdw/libdw.h +@@ -814,7 +814,7 @@ extern Dwarf_OOM dwarf_new_oom_handler ( ---- a/libdw/Makefile.in -+++ b/libdw/Makefile.in -@@ -170,6 +170,7 @@ + + /* Inline optimizations. */ +-#ifdef __OPTIMIZE__ ++#if defined __OPTIMIZE__ && !(__GNUC__ == 4 && __GNUC_MINOR__ == 2) + /* Return attribute code of given attribute. */ + __libdw_extern_inline unsigned int + dwarf_whatattr (Dwarf_Attribute *attr) +--- elfutils/libdw/Makefile.in ++++ elfutils/libdw/Makefile.in +@@ -189,6 +189,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -550,30 +775,26 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -199,6 +200,7 @@ +@@ -217,6 +218,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ -@@ -256,9 +258,10 @@ - top_srcdir = @top_srcdir@ - zip_LIBS = @zip_LIBS@ - @MUDFLAP_FALSE@AM_CFLAGS = $(am__append_1) -Wall -Werror -Wshadow \ --@MUDFLAP_FALSE@ -Wunused -Wformat=2 -Wextra -std=gnu99 -+@MUDFLAP_FALSE@ -Wunused -Wformat=2 $(WEXTRA) -std=gnu99 - @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap $(am__append_1) -Wall -Werror \ --@MUDFLAP_TRUE@ -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99 -+@MUDFLAP_TRUE@ -Wshadow -Wunused -Wformat=2 $(WEXTRA) \ -+@MUDFLAP_TRUE@ -std=gnu99 - INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib - COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \ - $(COMPILE))) ---- a/libdwfl/ChangeLog -+++ b/libdwfl/ChangeLog -@@ -1098,6 +1098,11 @@ + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +@@ -279,7 +281,7 @@ INCLUDES = -I. -I$(srcdir) -I$(top_srcdi + -I$(srcdir)/../libelf + AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ + $($(*F)_no_Werror),,-Werror) $(if \ +- $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ ++ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ + $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ + $(am__append_1) $(am__append_2) + @MUDFLAP_FALSE@libmudflap = +--- elfutils/libdwfl/ChangeLog ++++ elfutils/libdwfl/ChangeLog +@@ -1207,6 +1207,11 @@ 2005-07-21 Roland McGrath @@ -585,26 +806,9 @@ * Makefile.am (noinst_HEADERS): Add loc2c.c. * test2.c (main): Check sscanf result to quiet warning. ---- a/libdwfl/Makefile.am -+++ b/libdwfl/Makefile.am -@@ -27,12 +27,13 @@ - ## . - ## - DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -+WEXTRA = @WEXTRA@ - if MUDFLAP - AM_CFLAGS = -fmudflap - else - AM_CFLAGS = - endif --AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99 -+AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 $(WEXTRA) -std=gnu99 - INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ - -I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib - VERSION = 1 ---- a/libdwfl/Makefile.in -+++ b/libdwfl/Makefile.in -@@ -158,6 +158,7 @@ +--- elfutils/libdwfl/Makefile.in ++++ elfutils/libdwfl/Makefile.in +@@ -181,6 +181,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -612,29 +816,26 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -187,6 +188,7 @@ +@@ -209,6 +210,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ -@@ -244,9 +246,9 @@ - top_srcdir = @top_srcdir@ - zip_LIBS = @zip_LIBS@ - @MUDFLAP_FALSE@AM_CFLAGS = -Wall -Werror -Wshadow -Wunused -Wformat=2 \ --@MUDFLAP_FALSE@ -Wextra -std=gnu99 -+@MUDFLAP_FALSE@ $(WEXTRA) -std=gnu99 - @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -Wall -Werror -Wshadow -Wunused \ --@MUDFLAP_TRUE@ -Wformat=2 -Wextra -std=gnu99 -+@MUDFLAP_TRUE@ -Wformat=2 $(WEXTRA) -std=gnu99 - INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ - -I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib - ---- a/libebl/ChangeLog -+++ b/libebl/ChangeLog -@@ -593,6 +593,11 @@ + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +@@ -272,7 +274,7 @@ INCLUDES = -I. -I$(srcdir) -I$(top_srcdi + -I$(srcdir)/../libdw + AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ + $($(*F)_no_Werror),,-Werror) $(if \ +- $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ ++ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ + $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ + $(am__append_1) + @MUDFLAP_FALSE@libmudflap = +--- elfutils/libebl/ChangeLog ++++ elfutils/libebl/ChangeLog +@@ -624,6 +624,11 @@ * Makefile.am (libebl_*_so_SOURCES): Set to $(*_SRCS) so dependency tracking works right. @@ -646,26 +847,9 @@ 2005-05-21 Ulrich Drepper * libebl_x86_64.map: Add x86_64_core_note. ---- a/libebl/Makefile.am -+++ b/libebl/Makefile.am -@@ -25,12 +25,13 @@ - ## . - ## - DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\" -+WEXTRA = @WEXTRA@ - if MUDFLAP - AM_CFLAGS = -fmudflap - else - AM_CFLAGS = - endif --AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 \ -+AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 \ - -std=gnu99 - - INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ ---- a/libebl/Makefile.in -+++ b/libebl/Makefile.in -@@ -124,6 +124,7 @@ +--- elfutils/libebl/Makefile.in ++++ elfutils/libebl/Makefile.in +@@ -143,6 +143,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -673,29 +857,26 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -153,6 +154,7 @@ +@@ -171,6 +172,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ -@@ -210,9 +212,9 @@ - top_srcdir = @top_srcdir@ - zip_LIBS = @zip_LIBS@ - @MUDFLAP_FALSE@AM_CFLAGS = -fpic -Wall -Wshadow -Werror -Wunused \ --@MUDFLAP_FALSE@ -Wextra -Wformat=2 -std=gnu99 -+@MUDFLAP_FALSE@ $(WEXTRA) -Wformat=2 -std=gnu99 - @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -fpic -Wall -Wshadow -Werror \ --@MUDFLAP_TRUE@ -Wunused -Wextra -Wformat=2 -std=gnu99 -+@MUDFLAP_TRUE@ -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 - INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ - -I$(top_srcdir)/lib -I.. -I$(srcdir)/../libasm - ---- a/libelf/ChangeLog -+++ b/libelf/ChangeLog -@@ -576,6 +576,11 @@ + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +@@ -234,7 +236,7 @@ INCLUDES = -I. -I$(srcdir) -I$(top_srcdi + -I$(srcdir)/../libasm + AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ + $($(*F)_no_Werror),,-Werror) $(if \ +- $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ ++ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ + $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ + $(am__append_1) -fpic + @MUDFLAP_FALSE@libmudflap = +--- elfutils/libelf/ChangeLog ++++ elfutils/libelf/ChangeLog +@@ -651,6 +651,11 @@ * elf.h: Update from glibc. @@ -707,9 +888,9 @@ 2005-05-08 Roland McGrath * elf_begin.c (read_file) [_MUDFLAP]: Don't use mmap for now. ---- a/libelf/common.h -+++ b/libelf/common.h -@@ -160,7 +160,7 @@ +--- elfutils/libelf/common.h ++++ elfutils/libelf/common.h +@@ -160,7 +160,7 @@ libelf_release_all (Elf *elf) (Var) = (sizeof (Var) == 1 \ ? (unsigned char) (Var) \ : (sizeof (Var) == 2 \ @@ -718,7 +899,7 @@ : (sizeof (Var) == 4 \ ? bswap_32 (Var) \ : bswap_64 (Var)))) -@@ -169,7 +169,7 @@ +@@ -169,7 +169,7 @@ libelf_release_all (Elf *elf) (Dst) = (sizeof (Var) == 1 \ ? (unsigned char) (Var) \ : (sizeof (Var) == 2 \ @@ -727,28 +908,9 @@ : (sizeof (Var) == 4 \ ? bswap_32 (Var) \ : bswap_64 (Var)))) ---- a/libelf/Makefile.am -+++ b/libelf/Makefile.am -@@ -25,6 +25,7 @@ - ## . - ## - DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -+WEXTRA = @WEXTRA@ - if MUDFLAP - AM_CFLAGS = -fmudflap - else -@@ -33,7 +34,7 @@ - if BUILD_STATIC - AM_CFLAGS += -fpic - endif --AM_CFLAGS += -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 -std=gnu99 \ -+AM_CFLAGS += -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 \ - $($(*F)_CFLAGS) - INCLUDES = -I$(srcdir) -I$(top_srcdir)/lib -I.. - GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include) ---- a/libelf/Makefile.in -+++ b/libelf/Makefile.in -@@ -172,6 +172,7 @@ +--- elfutils/libelf/Makefile.in ++++ elfutils/libelf/Makefile.in +@@ -189,6 +189,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -756,30 +918,26 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -201,6 +202,7 @@ +@@ -217,6 +218,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ -@@ -258,10 +260,10 @@ - top_srcdir = @top_srcdir@ - zip_LIBS = @zip_LIBS@ - @MUDFLAP_FALSE@AM_CFLAGS = $(am__append_1) -Wall -Wshadow -Werror \ --@MUDFLAP_FALSE@ -Wunused -Wextra -Wformat=2 -std=gnu99 \ -+@MUDFLAP_FALSE@ -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 \ - @MUDFLAP_FALSE@ $($(*F)_CFLAGS) - @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap $(am__append_1) -Wall -Wshadow \ --@MUDFLAP_TRUE@ -Werror -Wunused -Wextra -Wformat=2 -std=gnu99 \ -+@MUDFLAP_TRUE@ -Werror -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 \ - @MUDFLAP_TRUE@ $($(*F)_CFLAGS) - INCLUDES = -I$(srcdir) -I$(top_srcdir)/lib -I.. - GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include) ---- a/m4/Makefile.in -+++ b/m4/Makefile.in -@@ -72,6 +72,7 @@ + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +@@ -278,7 +280,7 @@ zip_LIBS = @zip_LIBS@ + INCLUDES = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. + AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ + $($(*F)_no_Werror),,-Werror) $(if \ +- $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ ++ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ + $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ + $(am__append_1) $(am__append_2) + @MUDFLAP_FALSE@libmudflap = +--- elfutils/m4/Makefile.in ++++ elfutils/m4/Makefile.in +@@ -75,6 +75,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -787,17 +945,17 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -101,6 +102,7 @@ +@@ -103,6 +104,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ ---- a/Makefile.in -+++ b/Makefile.in -@@ -110,6 +110,7 @@ + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +--- elfutils/Makefile.in ++++ elfutils/Makefile.in +@@ -155,6 +155,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -805,17 +963,34 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -139,6 +140,7 @@ +@@ -183,6 +184,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ ---- a/src/ChangeLog -+++ b/src/ChangeLog -@@ -338,6 +338,11 @@ + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +--- elfutils/src/ChangeLog ++++ elfutils/src/ChangeLog +@@ -98,8 +98,16 @@ + * readelf.c (attr_callback): Use print_block only when we don't use + print_ops. + ++2009-08-17 Roland McGrath ++ ++ * ld.h: Disable extern inlines for GCC 4.2. ++ + 2009-08-14 Roland McGrath + ++ * strings.c (read_block): Conditionalize posix_fadvise use ++ on [POSIX_FADV_SEQUENTIAL]. ++ From Petr Salinger . ++ + * ar.c (do_oper_extract): Use pathconf instead of statfs. + + 2009-08-01 Ulrich Drepper +@@ -446,6 +456,11 @@ that matches its PT_LOAD's p_flags &~ PF_W. On sparc, PF_X really is valid in RELRO. @@ -827,7 +1002,7 @@ 2008-02-29 Roland McGrath * readelf.c (print_attributes): Add a cast. -@@ -589,6 +594,8 @@ +@@ -697,6 +712,8 @@ * readelf.c (hex_dump): Fix rounding error in whitespace calculation. @@ -836,7 +1011,7 @@ 2007-10-15 Roland McGrath * make-debug-archive.in: New file. -@@ -1028,6 +1035,10 @@ +@@ -1136,6 +1153,10 @@ * elflint.c (valid_e_machine): Add EM_ALPHA. Reported by Christian Aichinger . @@ -847,7 +1022,7 @@ 2006-08-08 Ulrich Drepper * elflint.c (check_dynamic): Don't require DT_HASH for DT_SYMTAB. -@@ -1104,6 +1115,10 @@ +@@ -1212,6 +1233,10 @@ * Makefile.am: Add hacks to create dependency files for non-generic linker. @@ -858,7 +1033,7 @@ 2006-06-12 Ulrich Drepper * ldgeneric.c (ld_generic_generate_sections): Don't create .interp -@@ -1452,6 +1467,11 @@ +@@ -1560,6 +1585,11 @@ * readelf.c (print_debug_loc_section): Fix indentation for larger address size. @@ -870,9 +1045,9 @@ 2005-05-30 Roland McGrath * readelf.c (print_debug_line_section): Print section offset of each ---- a/src/findtextrel.c -+++ b/src/findtextrel.c -@@ -490,7 +490,11 @@ +--- elfutils/src/findtextrel.c ++++ elfutils/src/findtextrel.c +@@ -490,7 +490,11 @@ ptrcompare (const void *p1, const void * static void @@ -885,26 +1060,26 @@ GElf_Addr addr, Elf *elf, Elf_Scn *symscn, Dwarf *dw, const char *fname, bool more_than_one, void **knownsrcs) { ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -26,6 +26,7 @@ - ## - DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \ - -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\" -+WEXTRA = @WEXTRA@ - if MUDFLAP - AM_CFLAGS = -fmudflap - else -@@ -33,7 +34,7 @@ - endif - AM_CFLAGS += -Wall -Wshadow -std=gnu99 $(native_ld_cflags) \ - $(if $($(*F)_no_Werror),,-Werror) \ -- $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ -+ $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \ - $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $(CFLAGS_$(*F)) +--- elfutils/src/ld.h ++++ elfutils/src/ld.h +@@ -1122,6 +1122,7 @@ extern bool dynamically_linked_p (void); - INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ -@@ -112,6 +113,9 @@ + /* Checked whether the symbol is undefined and referenced from a DSO. */ + extern bool linked_from_dso_p (struct scninfo *scninfo, size_t symidx); ++#if defined __OPTIMIZE__ && !(__GNUC__ == 4 && __GNUC_MINOR__ == 2) + #ifdef __GNUC_STDC_INLINE__ + __attribute__ ((__gnu_inline__)) + #endif +@@ -1139,5 +1140,6 @@ linked_from_dso_p (struct scninfo *scnin + + return sym->defined && sym->in_dso; + } ++#endif /* Optimizing and not GCC 4.2. */ + + #endif /* ld.h */ +--- elfutils/src/Makefile.am ++++ elfutils/src/Makefile.am +@@ -99,6 +99,9 @@ addr2line_no_Wformat = yes # XXX While the file is not finished, don't warn about this ldgeneric_no_Wunused = yes @@ -914,9 +1089,9 @@ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl size_LDADD = $(libelf) $(libeu) $(libmudflap) ---- a/src/Makefile.in -+++ b/src/Makefile.in -@@ -202,6 +202,7 @@ +--- elfutils/src/Makefile.in ++++ elfutils/src/Makefile.in +@@ -228,6 +228,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -924,31 +1099,24 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -231,6 +232,7 @@ +@@ -256,6 +257,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ -d -@@ -290,13 +292,13 @@ - @MUDFLAP_FALSE@AM_CFLAGS = -Wall -Wshadow -std=gnu99 \ - @MUDFLAP_FALSE@ $(native_ld_cflags) $(if \ - @MUDFLAP_FALSE@ $($(*F)_no_Werror),,-Werror) $(if \ --@MUDFLAP_FALSE@ $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ -+@MUDFLAP_FALSE@ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ - @MUDFLAP_FALSE@ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \ - @MUDFLAP_FALSE@ $(CFLAGS_$(*F)) - @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -Wall -Wshadow -std=gnu99 \ - @MUDFLAP_TRUE@ $(native_ld_cflags) $(if \ - @MUDFLAP_TRUE@ $($(*F)_no_Werror),,-Werror) $(if \ --@MUDFLAP_TRUE@ $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ -+@MUDFLAP_TRUE@ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ - @MUDFLAP_TRUE@ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \ - @MUDFLAP_TRUE@ $(CFLAGS_$(*F)) - INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ -@@ -342,6 +344,9 @@ + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +@@ -320,7 +322,7 @@ INCLUDES = -I. -I$(srcdir) -I$(top_srcdi + -I$(srcdir)/../libasm + AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ + $($(*F)_no_Werror),,-Werror) $(if \ +- $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ ++ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ + $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ + $(am__append_1) + @MUDFLAP_FALSE@libmudflap = +@@ -367,6 +369,9 @@ strings_no_Wformat = yes addr2line_no_Wformat = yes # XXX While the file is not finished, don't warn about this ldgeneric_no_Wunused = yes @@ -958,9 +1126,9 @@ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl size_LDADD = $(libelf) $(libeu) $(libmudflap) ---- a/src/readelf.c -+++ b/src/readelf.c -@@ -7591,7 +7591,7 @@ +--- elfutils/src/readelf.c ++++ elfutils/src/readelf.c +@@ -7655,7 +7655,7 @@ dump_archive_index (Elf *elf, const char if (unlikely (elf_rand (elf, as_off) == 0) || unlikely ((subelf = elf_begin (-1, ELF_C_READ_MMAP, elf)) == NULL)) @@ -969,8 +1137,8 @@ while (1) #endif error (EXIT_FAILURE, 0, ---- a/src/strings.c -+++ b/src/strings.c +--- elfutils/src/strings.c ++++ elfutils/src/strings.c @@ -51,6 +51,10 @@ #include @@ -982,7 +1150,7 @@ /* Prototypes of local functions. */ static int read_fd (int fd, const char *fname, off64_t fdlen); -@@ -491,8 +495,13 @@ +@@ -491,8 +495,13 @@ map_file (int fd, off64_t start_off, off fd, start_off); if (mem != MAP_FAILED) { @@ -996,9 +1164,21 @@ break; } if (errno != EINVAL && errno != ENOMEM) ---- a/src/strip.c -+++ b/src/strip.c -@@ -52,6 +52,12 @@ +@@ -586,9 +595,11 @@ read_block (int fd, const char *fname, o + elfmap_off = from & ~(ps - 1); + elfmap_base = elfmap = map_file (fd, elfmap_off, fdlen, &elfmap_size); + ++#ifdef POSIX_FADV_SEQUENTIAL + if (unlikely (elfmap == MAP_FAILED)) + /* Let the kernel know we are going to read everything in sequence. */ + (void) posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL); ++#endif + } + + if (unlikely (elfmap == MAP_FAILED)) +--- elfutils/src/strip.c ++++ elfutils/src/strip.c +@@ -53,6 +53,12 @@ #include #include @@ -1011,7 +1191,7 @@ /* Name and version of program. */ static void print_version (FILE *stream, struct argp_state *state); -@@ -300,8 +306,18 @@ +@@ -301,8 +307,18 @@ process_file (const char *fname) /* If we have to preserve the timestamp, we need it in the format utimes() understands. */ @@ -1030,7 +1210,7 @@ } /* Open the file. */ -@@ -1746,7 +1762,7 @@ +@@ -1747,7 +1763,7 @@ handle_elf (int fd, Elf *elf, const char /* If requested, preserve the timestamp. */ if (tvp != NULL) { @@ -1039,7 +1219,7 @@ { error (0, errno, gettext ("\ cannot set access and modification date of '%s'"), -@@ -1803,7 +1819,7 @@ +@@ -1804,7 +1820,7 @@ handle_ar (int fd, Elf *elf, const char if (tvp != NULL) { @@ -1048,9 +1228,9 @@ { error (0, errno, gettext ("\ cannot set access and modification date of '%s'"), fname); ---- a/tests/ChangeLog -+++ b/tests/ChangeLog -@@ -124,6 +124,8 @@ +--- elfutils/tests/ChangeLog ++++ elfutils/tests/ChangeLog +@@ -150,6 +150,8 @@ 2008-01-21 Roland McGrath @@ -1059,7 +1239,7 @@ * testfile45.S.bz2: Add tests for cltq, cqto. * testfile45.expect.bz2: Adjust. -@@ -832,6 +834,11 @@ +@@ -858,6 +860,11 @@ * Makefile.am (TESTS): Add run-elflint-test.sh. (EXTRA_DIST): Add run-elflint-test.sh and testfile18.bz2. @@ -1071,9 +1251,9 @@ 2005-05-24 Ulrich Drepper * get-files.c (main): Use correct format specifier. ---- a/tests/line2addr.c -+++ b/tests/line2addr.c -@@ -132,7 +132,7 @@ +--- elfutils/tests/line2addr.c ++++ elfutils/tests/line2addr.c +@@ -132,7 +132,7 @@ main (int argc, char *argv[]) { struct args a = { .arg = argv[cnt] }; @@ -1082,27 +1262,9 @@ { default: case 0: ---- a/tests/Makefile.am -+++ b/tests/Makefile.am -@@ -25,12 +25,13 @@ - ## . - ## - DEFS = -DHAVE_CONFIG_H -D_GNU_SOURCE -+WEXTRA = @WEXTRA@ - if MUDFLAP --AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 -fmudflap\ -+AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 -fmudflap\ - $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) - BUILD_RPATH = \$$ORIGIN/../backends - else --AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 \ -+AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 \ - $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) - BUILT_RPATH = \$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../backends:\$$ORIGIN/../libelf - endif ---- a/tests/Makefile.in -+++ b/tests/Makefile.in -@@ -353,6 +353,7 @@ +--- elfutils/tests/Makefile.in ++++ elfutils/tests/Makefile.in +@@ -372,6 +372,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -1110,24 +1272,20 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -382,6 +383,7 @@ +@@ -400,6 +401,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ - YACC = @YACC@ -@@ -438,10 +440,10 @@ - top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ - zip_LIBS = @zip_LIBS@ --@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 \ -+@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 \ - @MUDFLAP_FALSE@ $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) - --@MUDFLAP_TRUE@AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 -fmudflap\ -+@MUDFLAP_TRUE@AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 -fmudflap\ - @MUDFLAP_TRUE@ $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) - - @MUDFLAP_TRUE@BUILD_RPATH = \$$ORIGIN/../backends + XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +@@ -461,7 +463,7 @@ zip_LIBS = @zip_LIBS@ + INCLUDES = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. $(am__append_2) + AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ + $($(*F)_no_Werror),,-Werror) $(if \ +- $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ ++ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ + $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ + $(am__append_1) + @MUDFLAP_FALSE@libmudflap = diff --git a/elfutils-robustify.patch b/elfutils-robustify.patch index eb195d3..abe0f2c 100644 --- a/elfutils-robustify.patch +++ b/elfutils-robustify.patch @@ -1,59 +1,19 @@ ---- - libelf/ChangeLog | 43 +++++++++++++++++ - libelf/elf32_getphdr.c | 10 ++++ - libelf/elf32_getshdr.c | 15 +++++- - libelf/elf32_newphdr.c | 6 ++ - libelf/elf32_updatefile.c | 7 ++ - libelf/elf_begin.c | 46 ++++++++++++++++++- - libelf/elf_getarsym.c | 3 + - libelf/elf_getshdrstrndx.c | 38 ++++++++++++++- - libelf/elf_newscn.c | 10 +++- - libelf/gelf_getdyn.c | 6 +- - libelf/gelf_getlib.c | 3 - - libelf/gelf_getmove.c | 3 - - libelf/gelf_getrel.c | 12 +--- - libelf/gelf_getrela.c | 12 +--- - libelf/gelf_getsym.c | 6 +- - libelf/gelf_getsyminfo.c | 3 - - libelf/gelf_getsymshndx.c | 10 ++-- - libelf/gelf_getversym.c | 3 - - libelf/gelf_update_dyn.c | 12 +--- - libelf/gelf_update_lib.c | 9 --- - libelf/gelf_update_move.c | 2 - libelf/gelf_update_rel.c | 12 +--- - libelf/gelf_update_rela.c | 12 +--- - libelf/gelf_update_sym.c | 12 +--- - libelf/gelf_update_syminfo.c | 9 --- - libelf/gelf_update_symshndx.c | 12 +--- - libelf/gelf_update_versym.c | 2 - libelf/libelfP.h | 9 +++ - src/ChangeLog | 23 +++++++++ - src/elflint.c | 101 +++++++++++++++++++++++++++++++----------- - src/readelf.c | 92 +++++++++++++++++++++++++++----------- - src/strip.c | 70 +++++++++++++++++++---------- - 32 files changed, 446 insertions(+), 167 deletions(-) +From: Tony Jones +Subject: Elfutils robustify patch +Version: 0.147 +References: https://fedorahosted.org/releases/e/l/elfutils/elfutils-robustify.patch +Upstream: yes ---- a/libelf/ChangeLog -+++ b/libelf/ChangeLog -@@ -568,6 +568,49 @@ +This patch contains functional/stability fixes that are regarded as generally +useful by the community but are not accepted by the elfutils maintainer (and +are therefore not in the git repository). + +--- elfutils/libelf/ChangeLog ++++ elfutils/libelf/ChangeLog +@@ -643,10 +643,53 @@ If section content hasn't been read yet, do it before looking for the block size. If no section data present, infer size of section header. -+2005-05-17 Jakub Jelinek -+ -+ * elf32_getphdr.c (elfw2(LIBELFBITS,getphdr)): Check if program header -+ table fits into object's bounds. -+ * elf_getshstrndx.c (elf_getshstrndx): Add elf->start_offset to -+ elf->map_address. Check if first section header fits into object's -+ bounds. -+ * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)): -+ Check if section header table fits into object's bounds. -+ * elf_begin.c (get_shnum): Ensure section headers fits into -+ object's bounds. -+ (file_read_elf): Make sure scncnt is small enough to allocate both -+ ElfXX_Shdr and Elf_Scn array. Make sure section and program header -+ tables fit into object's bounds. Avoid memory leak on failure. -+ +2005-05-14 Jakub Jelinek + + * libelfP.h (INVALID_NDX): Define. @@ -85,16 +45,35 @@ 2005-05-11 Ulrich Drepper * elf.h: Update again. ---- a/libelf/elf32_getphdr.c -+++ b/libelf/elf32_getphdr.c -@@ -105,6 +105,16 @@ + ++2005-05-17 Jakub Jelinek ++ ++ * elf32_getphdr.c (elfw2(LIBELFBITS,getphdr)): Check if program header ++ table fits into object's bounds. ++ * elf_getshstrndx.c (elf_getshstrndx): Add elf->start_offset to ++ elf->map_address. Check if first section header fits into object's ++ bounds. ++ * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)): ++ Check if section header table fits into object's bounds. ++ * elf_begin.c (get_shnum): Ensure section headers fits into ++ object's bounds. ++ (file_read_elf): Make sure scncnt is small enough to allocate both ++ ElfXX_Shdr and Elf_Scn array. Make sure section and program header ++ tables fit into object's bounds. Avoid memory leak on failure. ++ + 2005-05-09 Ulrich Drepper + + * elf.h: Update from glibc. +--- elfutils/libelf/elf32_getphdr.c ++++ elfutils/libelf/elf32_getphdr.c +@@ -114,6 +114,16 @@ __elfw2(LIBELFBITS,getphdr_wrlock) (elf) if (elf->map_address != NULL) { + /* First see whether the information in the ELF header is + valid and it does not ask for too much. */ + if (unlikely (ehdr->e_phoff >= elf->maximum_size) -+ || unlikely (ehdr->e_phoff + size > elf->maximum_size)) ++ || unlikely (elf->maximum_size - ehdr->e_phoff < size)) + { + /* Something is wrong. */ + __libelf_seterrno (ELF_E_INVALID_PHDR); @@ -104,8 +83,8 @@ /* All the data is already mapped. Use it. */ void *file_phdr = ((char *) elf->map_address + elf->start_offset + ehdr->e_phoff); ---- a/libelf/elf32_getshdr.c -+++ b/libelf/elf32_getshdr.c +--- elfutils/libelf/elf32_getshdr.c ++++ elfutils/libelf/elf32_getshdr.c @@ -1,5 +1,5 @@ /* Return section header. - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2009 Red Hat, Inc. @@ -113,7 +92,7 @@ This file is part of Red Hat elfutils. Written by Ulrich Drepper , 1998. -@@ -81,7 +81,8 @@ +@@ -81,7 +81,8 @@ load_shdr_wrlock (Elf_Scn *scn) goto out; size_t shnum; @@ -123,14 +102,14 @@ goto out; size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr)); -@@ -98,6 +99,16 @@ +@@ -98,6 +99,16 @@ load_shdr_wrlock (Elf_Scn *scn) if (elf->map_address != NULL) { + /* First see whether the information in the ELF header is + valid and it does not ask for too much. */ + if (unlikely (ehdr->e_shoff >= elf->maximum_size) -+ || unlikely (ehdr->e_shoff + size > elf->maximum_size)) ++ || unlikely (elf->maximum_size - ehdr->e_shoff < size)) + { + /* Something is wrong. */ + __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); @@ -140,10 +119,10 @@ ElfW2(LIBELFBITS,Shdr) *notcvt; /* All the data is already mapped. If we could use it ---- a/libelf/elf32_newphdr.c -+++ b/libelf/elf32_newphdr.c -@@ -124,6 +124,12 @@ - else if (elf->state.ELFW(elf,LIBELFBITS).ehdr->e_phnum != count +--- elfutils/libelf/elf32_newphdr.c ++++ elfutils/libelf/elf32_newphdr.c +@@ -135,6 +135,12 @@ elfw2(LIBELFBITS,newphdr) (elf, count) + || count == PN_XNUM || elf->state.ELFW(elf,LIBELFBITS).phdr == NULL) { + if (unlikely (count > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Phdr)))) @@ -155,9 +134,9 @@ /* Allocate a new program header with the appropriate number of elements. */ result = (ElfW2(LIBELFBITS,Phdr) *) ---- a/libelf/elf32_updatefile.c -+++ b/libelf/elf32_updatefile.c -@@ -220,6 +220,9 @@ +--- elfutils/libelf/elf32_updatefile.c ++++ elfutils/libelf/elf32_updatefile.c +@@ -223,6 +223,9 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf /* Write all the sections. Well, only those which are modified. */ if (shnum > 0) { @@ -167,7 +146,7 @@ Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns; Elf_Scn **scns = (Elf_Scn **) alloca (shnum * sizeof (Elf_Scn *)); char *const shdr_start = ((char *) elf->map_address + elf->start_offset -@@ -636,6 +639,10 @@ +@@ -645,6 +648,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf /* Write all the sections. Well, only those which are modified. */ if (shnum > 0) { @@ -178,19 +157,19 @@ off_t shdr_offset = elf->start_offset + ehdr->e_shoff; #if EV_NUM != 2 xfct_t shdr_fctp = __elf_xfctstom[__libelf_version - 1][EV_CURRENT - 1][ELFW(ELFCLASS, LIBELFBITS) - 1][ELF_T_SHDR]; ---- a/libelf/elf_begin.c -+++ b/libelf/elf_begin.c -@@ -165,7 +165,8 @@ +--- elfutils/libelf/elf_begin.c ++++ elfutils/libelf/elf_begin.c +@@ -165,7 +165,8 @@ get_shnum (void *map_address, unsigned c if (unlikely (result == 0) && ehdr.e32->e_shoff != 0) { - if (ehdr.e32->e_shoff + sizeof (Elf32_Shdr) > maxsize) + if (unlikely (ehdr.e32->e_shoff >= maxsize) -+ || unlikely (ehdr.e32->e_shoff + sizeof (Elf32_Shdr) > maxsize)) ++ || unlikely (maxsize - ehdr.e32->e_shoff < sizeof (Elf32_Shdr))) /* Cannot read the first section header. */ return 0; -@@ -213,7 +214,8 @@ +@@ -213,7 +214,8 @@ get_shnum (void *map_address, unsigned c if (unlikely (result == 0) && ehdr.e64->e_shoff != 0) { @@ -200,7 +179,7 @@ /* Cannot read the first section header. */ return 0; -@@ -285,6 +287,15 @@ +@@ -285,6 +287,15 @@ file_read_elf (int fildes, void *map_add /* Could not determine the number of sections. */ return NULL; @@ -213,17 +192,17 @@ + else if (scncnt > SIZE_MAX / (sizeof (Elf_Scn) + sizeof (Elf64_Shdr))) + return NULL; + - /* We can now allocate the memory. */ - Elf *elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent, - ELF_K_ELF, scncnt * sizeof (Elf_Scn)); -@@ -318,13 +329,31 @@ + /* We can now allocate the memory. Even if there are no section headers, + we allocate space for a zeroth section in case we need it later. */ + const size_t scnmax = (scncnt ?: (cmd == ELF_C_RDWR || cmd == ELF_C_RDWR_MMAP) +@@ -324,6 +335,16 @@ file_read_elf (int fildes, void *map_add { /* We can use the mmapped memory. */ elf->state.elf32.ehdr = ehdr; + + if (unlikely (ehdr->e_shoff >= maxsize) -+ || unlikely (ehdr->e_shoff -+ + scncnt * sizeof (Elf32_Shdr) > maxsize)) ++ || unlikely (maxsize - ehdr->e_shoff ++ < scncnt * sizeof (Elf32_Shdr))) + { + free_and_out: + free (elf); @@ -232,23 +211,8 @@ + } elf->state.elf32.shdr = (Elf32_Shdr *) ((char *) ehdr + ehdr->e_shoff); -+ - if (ehdr->e_phnum > 0) -+ { - /* Assign a value only if there really is a program - header. Otherwise the value remains NULL. */ -+ if (unlikely (ehdr->e_phoff >= maxsize) -+ || unlikely (ehdr->e_phoff -+ + ehdr->e_phnum -+ * sizeof (Elf32_Phdr) > maxsize)) -+ goto free_and_out; - elf->state.elf32.phdr - = (Elf32_Phdr *) ((char *) ehdr + ehdr->e_phoff); -+ } - for (size_t cnt = 0; cnt < scncnt; ++cnt) - { -@@ -406,13 +435,26 @@ +@@ -410,6 +431,11 @@ file_read_elf (int fildes, void *map_add { /* We can use the mmapped memory. */ elf->state.elf64.ehdr = ehdr; @@ -259,25 +223,10 @@ + goto free_and_out; elf->state.elf64.shdr = (Elf64_Shdr *) ((char *) ehdr + ehdr->e_shoff); -+ - if (ehdr->e_phnum > 0) -+ { - /* Assign a value only if there really is a program - header. Otherwise the value remains NULL. */ -+ if (unlikely (ehdr->e_phoff >= maxsize) -+ || unlikely (ehdr->e_phoff -+ + ehdr->e_phnum -+ * sizeof (Elf32_Phdr) > maxsize)) -+ goto free_and_out; - elf->state.elf64.phdr - = (Elf64_Phdr *) ((char *) ehdr + ehdr->e_phoff); -+ } - for (size_t cnt = 0; cnt < scncnt; ++cnt) - { ---- a/libelf/elf_getarsym.c -+++ b/libelf/elf_getarsym.c -@@ -179,6 +179,9 @@ +--- elfutils/libelf/elf_getarsym.c ++++ elfutils/libelf/elf_getarsym.c +@@ -179,6 +179,9 @@ elf_getarsym (elf, ptr) size_t index_size = atol (tmpbuf); if (SARMAG + sizeof (struct ar_hdr) + index_size > elf->maximum_size @@ -287,9 +236,9 @@ || n * sizeof (uint32_t) > index_size) { /* This index table cannot be right since it does not fit into ---- a/libelf/elf_getshdrstrndx.c -+++ b/libelf/elf_getshdrstrndx.c -@@ -125,10 +125,25 @@ +--- elfutils/libelf/elf_getshdrstrndx.c ++++ elfutils/libelf/elf_getshdrstrndx.c +@@ -125,10 +125,25 @@ elf_getshdrstrndx (elf, dst) if (elf->map_address != NULL && elf->state.elf32.ehdr->e_ident[EI_DATA] == MY_ELFDATA && (ALLOW_UNALIGNED @@ -297,11 +246,13 @@ + || (((size_t) ((char *) elf->map_address + + elf->start_offset + offset)) & (__alignof__ (Elf32_Shdr) - 1)) == 0)) +- /* We can directly access the memory. */ +- num = ((Elf32_Shdr *) (elf->map_address + offset))->sh_link; + { + /* First see whether the information in the ELF header is + valid and it does not ask for too much. */ -+ if (unlikely (offset + sizeof (Elf32_Shdr) -+ > elf->maximum_size)) ++ if (unlikely (elf->maximum_size - offset ++ < sizeof (Elf32_Shdr))) + { + /* Something is wrong. */ + __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); @@ -309,15 +260,14 @@ + goto out; + } + - /* We can directly access the memory. */ -- num = ((Elf32_Shdr *) (elf->map_address + offset))->sh_link; ++ /* We can directly access the memory. */ + num = ((Elf32_Shdr *) (elf->map_address + elf->start_offset + + offset))->sh_link; + } else { /* We avoid reading in all the section headers. Just read -@@ -163,10 +178,25 @@ +@@ -163,10 +178,25 @@ elf_getshdrstrndx (elf, dst) if (elf->map_address != NULL && elf->state.elf64.ehdr->e_ident[EI_DATA] == MY_ELFDATA && (ALLOW_UNALIGNED @@ -325,11 +275,13 @@ + || (((size_t) ((char *) elf->map_address + + elf->start_offset + offset)) & (__alignof__ (Elf64_Shdr) - 1)) == 0)) +- /* We can directly access the memory. */ +- num = ((Elf64_Shdr *) (elf->map_address + offset))->sh_link; + { + /* First see whether the information in the ELF header is + valid and it does not ask for too much. */ -+ if (unlikely (offset + sizeof (Elf64_Shdr) -+ > elf->maximum_size)) ++ if (unlikely (elf->maximum_size - offset ++ < sizeof (Elf64_Shdr))) + { + /* Something is wrong. */ + __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); @@ -337,17 +289,16 @@ + goto out; + } + - /* We can directly access the memory. */ -- num = ((Elf64_Shdr *) (elf->map_address + offset))->sh_link; -+ num = ((Elf64_Shdr *) (elf->map_address -+ + elf->start_offset + offset))->sh_link; ++ /* We can directly access the memory. */ ++ num = ((Elf64_Shdr *) (elf->map_address + elf->start_offset ++ + offset))->sh_link; + } else { /* We avoid reading in all the section headers. Just read ---- a/libelf/elf_newscn.c -+++ b/libelf/elf_newscn.c -@@ -104,10 +104,18 @@ +--- elfutils/libelf/elf_newscn.c ++++ elfutils/libelf/elf_newscn.c +@@ -104,10 +104,18 @@ elf_newscn (elf) else { /* We must allocate a new element. */ @@ -367,55 +318,79 @@ newp = (Elf_ScnList *) calloc (sizeof (Elf_ScnList) + ((elf->state.elf.scnincr *= 2) * sizeof (Elf_Scn)), 1); ---- a/libelf/gelf_getdyn.c -+++ b/libelf/gelf_getdyn.c -@@ -93,7 +93,8 @@ +--- elfutils/libelf/gelf_getdyn.c ++++ elfutils/libelf/gelf_getdyn.c +@@ -1,5 +1,5 @@ + /* Get information from dynamic table at the given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -93,7 +93,7 @@ gelf_getdyn (data, ndx, dst) table entries has to be adopted. The user better has provided a buffer where we can store the information. While copying the data we are converting the format. */ - if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf32_Dyn) -+ || unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Dyn, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; -@@ -114,7 +115,8 @@ +@@ -114,7 +114,7 @@ gelf_getdyn (data, ndx, dst) /* The data is already in the correct form. Just make sure the index is OK. */ - if (unlikely ((ndx + 1) * sizeof (GElf_Dyn) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, GElf_Dyn) -+ || unlikely ((ndx + 1) * sizeof (GElf_Dyn) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, GElf_Dyn, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- a/libelf/gelf_getlib.c -+++ b/libelf/gelf_getlib.c -@@ -86,7 +86,8 @@ +--- elfutils/libelf/gelf_getlib.c ++++ elfutils/libelf/gelf_getlib.c +@@ -1,5 +1,5 @@ + /* Get library from table at the given index. +- Copyright (C) 2004 Red Hat, Inc. ++ Copyright (C) 2004-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2004. + +@@ -86,7 +86,7 @@ gelf_getlib (data, ndx, dst) /* The data is already in the correct form. Just make sure the index is OK. */ GElf_Lib *result = NULL; - if (unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size)) -+ if (INVALID_NDX (ndx, GElf_Lib) -+ || unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size)) ++ if (INVALID_NDX (ndx, GElf_Lib, data)) __libelf_seterrno (ELF_E_INVALID_INDEX); else { ---- a/libelf/gelf_getmove.c -+++ b/libelf/gelf_getmove.c -@@ -83,7 +83,8 @@ +--- elfutils/libelf/gelf_getmove.c ++++ elfutils/libelf/gelf_getmove.c +@@ -1,5 +1,5 @@ + /* Get move structure at the given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -83,7 +83,7 @@ gelf_getmove (data, ndx, dst) /* The data is already in the correct form. Just make sure the index is OK. */ - if (unlikely ((ndx + 1) * sizeof (GElf_Move) > data->d_size)) -+ if (INVALID_NDX (ndx, GElf_Move) -+ || unlikely ((ndx + 1) * sizeof (GElf_Move) > data->d_size)) ++ if (INVALID_NDX (ndx, GElf_Move, data)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- a/libelf/gelf_getrela.c -+++ b/libelf/gelf_getrela.c -@@ -71,12 +71,6 @@ +--- elfutils/libelf/gelf_getrela.c ++++ elfutils/libelf/gelf_getrela.c +@@ -1,5 +1,5 @@ + /* Get RELA relocation information at given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -71,12 +71,6 @@ gelf_getrela (data, ndx, dst) if (data_scn == NULL) return NULL; @@ -428,29 +403,34 @@ if (unlikely (data_scn->d.d_type != ELF_T_RELA)) { __libelf_seterrno (ELF_E_INVALID_HANDLE); -@@ -93,7 +87,8 @@ +@@ -93,7 +87,7 @@ gelf_getrela (data, ndx, dst) if (scn->elf->class == ELFCLASS32) { /* We have to convert the data. */ - if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf32_Rela) -+ || unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Rela, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); result = NULL; -@@ -114,7 +109,8 @@ +@@ -114,7 +108,7 @@ gelf_getrela (data, ndx, dst) { /* Simply copy the data after we made sure we are actually getting correct data. */ - if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf64_Rela) -+ || unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Rela, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); result = NULL; ---- a/libelf/gelf_getrel.c -+++ b/libelf/gelf_getrel.c -@@ -71,12 +71,6 @@ +--- elfutils/libelf/gelf_getrel.c ++++ elfutils/libelf/gelf_getrel.c +@@ -1,5 +1,5 @@ + /* Get REL relocation information at given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -71,12 +71,6 @@ gelf_getrel (data, ndx, dst) if (data_scn == NULL) return NULL; @@ -463,108 +443,134 @@ if (unlikely (data_scn->d.d_type != ELF_T_REL)) { __libelf_seterrno (ELF_E_INVALID_HANDLE); -@@ -93,7 +87,8 @@ +@@ -93,7 +87,7 @@ gelf_getrel (data, ndx, dst) if (scn->elf->class == ELFCLASS32) { /* We have to convert the data. */ - if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf32_Rel) -+ || unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Rel, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); result = NULL; -@@ -113,7 +108,8 @@ +@@ -113,7 +107,7 @@ gelf_getrel (data, ndx, dst) { /* Simply copy the data after we made sure we are actually getting correct data. */ - if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf64_Rel) -+ || unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Rel, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); result = NULL; ---- a/libelf/gelf_getsym.c -+++ b/libelf/gelf_getsym.c -@@ -90,7 +90,8 @@ +--- elfutils/libelf/gelf_getsym.c ++++ elfutils/libelf/gelf_getsym.c +@@ -1,5 +1,5 @@ + /* Get symbol information from symbol table at the given index. +- Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 1999-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 1999. + +@@ -90,7 +90,7 @@ gelf_getsym (data, ndx, dst) table entries has to be adopted. The user better has provided a buffer where we can store the information. While copying the data we are converting the format. */ - if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data->d_size)) -+ if (INVALID_NDX (ndx, Elf32_Sym) -+ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data->d_size)) ++ if (INVALID_NDX (ndx, Elf32_Sym, data)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; -@@ -119,7 +120,8 @@ +@@ -119,7 +119,7 @@ gelf_getsym (data, ndx, dst) /* The data is already in the correct form. Just make sure the index is OK. */ - if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > data->d_size)) -+ if (INVALID_NDX (ndx, GElf_Sym) -+ || unlikely ((ndx + 1) * sizeof (GElf_Sym) > data->d_size)) ++ if (INVALID_NDX (ndx, GElf_Sym, data)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- a/libelf/gelf_getsyminfo.c -+++ b/libelf/gelf_getsyminfo.c -@@ -84,7 +84,8 @@ +--- elfutils/libelf/gelf_getsyminfo.c ++++ elfutils/libelf/gelf_getsyminfo.c +@@ -1,5 +1,5 @@ + /* Get additional symbol information from symbol table at the given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -84,7 +84,7 @@ gelf_getsyminfo (data, ndx, dst) /* The data is already in the correct form. Just make sure the index is OK. */ - if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data->d_size)) -+ if (INVALID_NDX (ndx, GElf_Syminfo) -+ || unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data->d_size)) ++ if (INVALID_NDX (ndx, GElf_Syminfo, data)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- a/libelf/gelf_getsymshndx.c -+++ b/libelf/gelf_getsymshndx.c -@@ -90,7 +90,9 @@ +--- elfutils/libelf/gelf_getsymshndx.c ++++ elfutils/libelf/gelf_getsymshndx.c +@@ -1,6 +1,6 @@ + /* Get symbol information and separate section index from symbol table + at the given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -90,7 +90,7 @@ gelf_getsymshndx (symdata, shndxdata, nd section index table. */ if (likely (shndxdata_scn != NULL)) { - if (unlikely ((ndx + 1) * sizeof (Elf32_Word) > shndxdata_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf32_Word) -+ || unlikely ((ndx + 1) * sizeof (Elf32_Word) -+ > shndxdata_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Word, &shndxdata_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; -@@ -110,7 +112,8 @@ +@@ -110,7 +110,7 @@ gelf_getsymshndx (symdata, shndxdata, nd table entries has to be adopted. The user better has provided a buffer where we can store the information. While copying the data we are converting the format. */ - if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata->d_size)) -+ if (INVALID_NDX (ndx, Elf32_Sym) -+ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata->d_size)) ++ if (INVALID_NDX (ndx, Elf32_Sym, symdata)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; -@@ -139,7 +142,8 @@ +@@ -139,7 +139,7 @@ gelf_getsymshndx (symdata, shndxdata, nd /* The data is already in the correct form. Just make sure the index is OK. */ - if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > symdata->d_size)) -+ if (INVALID_NDX (ndx, GElf_Sym) -+ || unlikely ((ndx + 1) * sizeof (GElf_Sym) > symdata->d_size)) ++ if (INVALID_NDX (ndx, GElf_Sym, symdata)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- a/libelf/gelf_getversym.c -+++ b/libelf/gelf_getversym.c -@@ -92,7 +92,8 @@ +--- elfutils/libelf/gelf_getversym.c ++++ elfutils/libelf/gelf_getversym.c +@@ -1,5 +1,5 @@ + /* Get symbol version information at the given index. +- Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 1999-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 1999. + +@@ -92,7 +92,7 @@ gelf_getversym (data, ndx, dst) /* The data is already in the correct form. Just make sure the index is OK. */ - if (unlikely ((ndx + 1) * sizeof (GElf_Versym) > data->d_size)) -+ if (INVALID_NDX (ndx, GElf_Versym) -+ || unlikely ((ndx + 1) * sizeof (GElf_Versym) > data->d_size)) ++ if (INVALID_NDX (ndx, GElf_Versym, data)) { __libelf_seterrno (ELF_E_INVALID_INDEX); result = NULL; ---- a/libelf/gelf_update_dyn.c -+++ b/libelf/gelf_update_dyn.c -@@ -71,12 +71,6 @@ +--- elfutils/libelf/gelf_update_dyn.c ++++ elfutils/libelf/gelf_update_dyn.c +@@ -1,5 +1,5 @@ + /* Update information in dynamic table at the given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -71,12 +71,6 @@ gelf_update_dyn (data, ndx, src) if (data == NULL) return 0; @@ -577,29 +583,34 @@ if (unlikely (data_scn->d.d_type != ELF_T_DYN)) { /* The type of the data better should match. */ -@@ -102,7 +96,8 @@ +@@ -102,7 +96,7 @@ gelf_update_dyn (data, ndx, src) } /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf32_Dyn) -+ || unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Dyn, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; -@@ -116,7 +111,8 @@ +@@ -116,7 +110,7 @@ gelf_update_dyn (data, ndx, src) else { /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf64_Dyn) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf64_Dyn) -+ || unlikely ((ndx + 1) * sizeof (Elf64_Dyn) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Dyn, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- a/libelf/gelf_update_lib.c -+++ b/libelf/gelf_update_lib.c -@@ -68,12 +68,6 @@ +--- elfutils/libelf/gelf_update_lib.c ++++ elfutils/libelf/gelf_update_lib.c +@@ -1,5 +1,5 @@ + /* Update library in table at the given index. +- Copyright (C) 2004 Red Hat, Inc. ++ Copyright (C) 2004-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2004. + +@@ -68,12 +68,6 @@ gelf_update_lib (data, ndx, src) if (data == NULL) return 0; @@ -612,30 +623,44 @@ Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data; if (unlikely (data_scn->d.d_type != ELF_T_LIB)) { -@@ -87,7 +81,8 @@ +@@ -87,7 +81,7 @@ gelf_update_lib (data, ndx, src) /* Check whether we have to resize the data buffer. */ int result = 0; - if (unlikely ((ndx + 1) * sizeof (Elf64_Lib) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf64_Lib) -+ || unlikely ((ndx + 1) * sizeof (Elf64_Lib) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Lib, &data_scn->d)) __libelf_seterrno (ELF_E_INVALID_INDEX); else { ---- a/libelf/gelf_update_move.c -+++ b/libelf/gelf_update_move.c -@@ -75,7 +75,7 @@ +--- elfutils/libelf/gelf_update_move.c ++++ elfutils/libelf/gelf_update_move.c +@@ -1,5 +1,5 @@ + /* Update move structure at the given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -75,8 +75,7 @@ gelf_update_move (data, ndx, src) assert (sizeof (GElf_Move) == sizeof (Elf64_Move)); /* Check whether we have to resize the data buffer. */ - if (unlikely (ndx < 0) -+ if (INVALID_NDX (ndx, GElf_Move) - || unlikely ((ndx + 1) * sizeof (GElf_Move) > data_scn->d.d_size)) +- || unlikely ((ndx + 1) * sizeof (GElf_Move) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, GElf_Move, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); ---- a/libelf/gelf_update_rela.c -+++ b/libelf/gelf_update_rela.c -@@ -68,12 +68,6 @@ + return 0; +--- elfutils/libelf/gelf_update_rela.c ++++ elfutils/libelf/gelf_update_rela.c +@@ -1,5 +1,5 @@ + /* Update RELA relocation information at given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -68,12 +68,6 @@ gelf_update_rela (Elf_Data *dst, int ndx if (dst == NULL) return 0; @@ -648,29 +673,34 @@ if (unlikely (data_scn->d.d_type != ELF_T_RELA)) { /* The type of the data better should match. */ -@@ -101,7 +95,8 @@ +@@ -101,7 +95,7 @@ gelf_update_rela (Elf_Data *dst, int ndx } /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf32_Rela) -+ || unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Rela, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; -@@ -117,7 +112,8 @@ +@@ -117,7 +111,7 @@ gelf_update_rela (Elf_Data *dst, int ndx else { /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf64_Rela) -+ || unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Rela, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- a/libelf/gelf_update_rel.c -+++ b/libelf/gelf_update_rel.c -@@ -68,12 +68,6 @@ +--- elfutils/libelf/gelf_update_rel.c ++++ elfutils/libelf/gelf_update_rel.c +@@ -1,5 +1,5 @@ + /* Update REL relocation information at given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -68,12 +68,6 @@ gelf_update_rel (Elf_Data *dst, int ndx, if (dst == NULL) return 0; @@ -683,29 +713,34 @@ if (unlikely (data_scn->d.d_type != ELF_T_REL)) { /* The type of the data better should match. */ -@@ -99,7 +93,8 @@ +@@ -99,7 +93,7 @@ gelf_update_rel (Elf_Data *dst, int ndx, } /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf32_Rel) -+ || unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Rel, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; -@@ -114,7 +109,8 @@ +@@ -114,7 +108,7 @@ gelf_update_rel (Elf_Data *dst, int ndx, else { /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf64_Rel) -+ || unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Rel, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- a/libelf/gelf_update_sym.c -+++ b/libelf/gelf_update_sym.c -@@ -72,12 +72,6 @@ +--- elfutils/libelf/gelf_update_sym.c ++++ elfutils/libelf/gelf_update_sym.c +@@ -1,5 +1,5 @@ + /* Update symbol information in symbol table at the given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -72,12 +72,6 @@ gelf_update_sym (data, ndx, src) if (data == NULL) return 0; @@ -718,29 +753,34 @@ if (unlikely (data_scn->d.d_type != ELF_T_SYM)) { /* The type of the data better should match. */ -@@ -102,7 +96,8 @@ +@@ -102,7 +96,7 @@ gelf_update_sym (data, ndx, src) } /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf32_Sym) -+ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Sym, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; -@@ -125,7 +120,8 @@ +@@ -125,7 +119,7 @@ gelf_update_sym (data, ndx, src) else { /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf64_Sym) -+ || unlikely ((ndx + 1) * sizeof (Elf64_Sym) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Sym, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- a/libelf/gelf_update_syminfo.c -+++ b/libelf/gelf_update_syminfo.c -@@ -72,12 +72,6 @@ +--- elfutils/libelf/gelf_update_syminfo.c ++++ elfutils/libelf/gelf_update_syminfo.c +@@ -1,5 +1,5 @@ + /* Update additional symbol information in symbol table at the given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -72,12 +72,6 @@ gelf_update_syminfo (data, ndx, src) if (data == NULL) return 0; @@ -753,19 +793,26 @@ if (unlikely (data_scn->d.d_type != ELF_T_SYMINFO)) { /* The type of the data better should match. */ -@@ -93,7 +87,8 @@ +@@ -93,7 +87,7 @@ gelf_update_syminfo (data, ndx, src) rwlock_wrlock (scn->elf->lock); /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data_scn->d.d_size)) -+ if (INVALID_NDX (ndx, GElf_Syminfo) -+ || unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, GElf_Syminfo, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- a/libelf/gelf_update_symshndx.c -+++ b/libelf/gelf_update_symshndx.c -@@ -77,12 +77,6 @@ +--- elfutils/libelf/gelf_update_symshndx.c ++++ elfutils/libelf/gelf_update_symshndx.c +@@ -1,6 +1,6 @@ + /* Update symbol information and section index in symbol table at the + given index. +- Copyright (C) 2000, 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2000-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2000. + +@@ -77,12 +77,6 @@ gelf_update_symshndx (symdata, shndxdata if (symdata == NULL) return 0; @@ -778,56 +825,57 @@ if (unlikely (symdata_scn->d.d_type != ELF_T_SYM)) { /* The type of the data better should match. */ -@@ -128,7 +122,8 @@ +@@ -128,7 +122,7 @@ gelf_update_symshndx (symdata, shndxdata } /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf32_Sym) -+ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Sym, &symdata_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; -@@ -151,7 +146,8 @@ +@@ -151,7 +145,7 @@ gelf_update_symshndx (symdata, shndxdata else { /* Check whether we have to resize the data buffer. */ - if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size)) -+ if (INVALID_NDX (ndx, Elf64_Sym) -+ || unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Sym, &symdata_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- a/libelf/gelf_update_versym.c -+++ b/libelf/gelf_update_versym.c -@@ -75,7 +75,7 @@ +--- elfutils/libelf/gelf_update_versym.c ++++ elfutils/libelf/gelf_update_versym.c +@@ -1,5 +1,5 @@ + /* Update symbol version information. +- Copyright (C) 2001, 2002 Red Hat, Inc. ++ Copyright (C) 2001-2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2001. + +@@ -75,8 +75,7 @@ gelf_update_versym (data, ndx, src) assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym)); /* Check whether we have to resize the data buffer. */ - if (unlikely (ndx < 0) -+ if (INVALID_NDX (ndx, GElf_Versym) - || unlikely ((ndx + 1) * sizeof (GElf_Versym) > data_scn->d.d_size)) +- || unlikely ((ndx + 1) * sizeof (GElf_Versym) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, GElf_Versym, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); ---- a/libelf/libelfP.h -+++ b/libelf/libelfP.h -@@ -606,4 +606,13 @@ + return 0; +--- elfutils/libelf/libelfP.h ++++ elfutils/libelf/libelfP.h +@@ -608,4 +608,8 @@ extern uint32_t __libelf_crc32 (uint32_t /* Align offset to 4 bytes as needed for note name and descriptor data. */ #define NOTE_ALIGN(n) (((n) + 3) & -4U) -+/* Convenience macro. Assumes int NDX and TYPE with size at least -+ 2 bytes. */ -+#if SIZE_MAX > 4294967295U -+# define INVALID_NDX(ndx, type) unlikely (ndx < 0) -+#else -+# define INVALID_NDX(ndx, type) \ -+ unlikely ((unsigned int) (ndx) >= SIZE_MAX / sizeof (type)) -+#endif ++/* Convenience macro. */ ++#define INVALID_NDX(ndx, type, data) \ ++ unlikely ((data)->d_size / sizeof (type) <= (unsigned int) (ndx)) + #endif /* libelfP.h */ ---- a/src/ChangeLog -+++ b/src/ChangeLog -@@ -1455,6 +1455,16 @@ +--- elfutils/src/ChangeLog ++++ elfutils/src/ChangeLog +@@ -1548,6 +1548,16 @@ object symbols or symbols with unknown type. (check_rel): Likewise. @@ -844,7 +892,7 @@ 2005-06-08 Roland McGrath * readelf.c (print_ops): Add consts. -@@ -1505,6 +1515,19 @@ +@@ -1593,6 +1603,19 @@ * readelf.c (dwarf_tag_string): Add new tags. @@ -864,19 +912,20 @@ 2005-05-08 Roland McGrath * strip.c (handle_elf): Don't translate hash and versym data formats, ---- a/src/elflint.c -+++ b/src/elflint.c -@@ -130,6 +130,9 @@ +--- elfutils/src/elflint.c ++++ elfutils/src/elflint.c +@@ -131,6 +131,10 @@ static uint32_t shstrndx; /* Array to count references in section groups. */ static int *scnref; -+/* Number of sections. */ ++/* Numbers of sections and program headers. */ +static unsigned int shnum; ++static unsigned int phnum; + int main (int argc, char *argv[]) -@@ -318,10 +321,19 @@ +@@ -319,10 +323,19 @@ section_name (Ebl *ebl, int idx) { GElf_Shdr shdr_mem; GElf_Shdr *shdr; @@ -897,18 +946,19 @@ } -@@ -343,10 +355,6 @@ +@@ -344,11 +357,6 @@ static const int valid_e_machine[] = (sizeof (valid_e_machine) / sizeof (valid_e_machine[0])) --/* Number of sections. */ +-/* Numbers of sections and program headers. */ -static unsigned int shnum; +-static unsigned int phnum; - - static void check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size) { -@@ -612,7 +620,8 @@ +@@ -632,7 +640,8 @@ section [%2d] '%s': symbol table cannot } } @@ -918,7 +968,7 @@ ERROR (gettext ("\ section [%2u] '%s': entry size is does not match ElfXX_Sym\n"), idx, section_name (ebl, idx)); -@@ -650,7 +659,7 @@ +@@ -670,7 +679,7 @@ section [%2d] '%s': XINDEX for zeroth en xndxscnidx, section_name (ebl, xndxscnidx)); } @@ -927,7 +977,7 @@ { sym = gelf_getsymshndx (data, xndxdata, cnt, &sym_mem, &xndx); if (sym == NULL) -@@ -670,7 +679,8 @@ +@@ -690,7 +699,8 @@ section [%2d] '%s': symbol %zu: invalid else { name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name); @@ -937,7 +987,7 @@ } if (sym->st_shndx == SHN_XINDEX) -@@ -1018,9 +1028,11 @@ +@@ -1038,9 +1048,11 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e { GElf_Shdr rcshdr_mem; const GElf_Shdr *rcshdr = gelf_getshdr (scn, &rcshdr_mem); @@ -951,7 +1001,7 @@ { /* Found the dynamic section. Look through it. */ Elf_Data *d = elf_getdata (scn, NULL); -@@ -1030,7 +1042,9 @@ +@@ -1050,7 +1062,9 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e { GElf_Dyn dyn_mem; GElf_Dyn *dyn = gelf_getdyn (d, cnt, &dyn_mem); @@ -962,7 +1012,7 @@ if (dyn->d_tag == DT_RELCOUNT) { -@@ -1044,7 +1058,9 @@ +@@ -1064,7 +1078,9 @@ section [%2d] '%s': DT_RELCOUNT used for /* Does the number specified number of relative relocations exceed the total number of relocations? */ @@ -973,7 +1023,7 @@ ERROR (gettext ("\ section [%2d] '%s': DT_RELCOUNT value %d too high for this section\n"), idx, section_name (ebl, idx), -@@ -1204,7 +1220,8 @@ +@@ -1224,7 +1240,8 @@ section [%2d] '%s': no relocations for m } } @@ -983,7 +1033,7 @@ ERROR (gettext (reltype == ELF_T_RELA ? "\ section [%2d] '%s': section entry size does not match ElfXX_Rela\n" : "\ section [%2d] '%s': section entry size does not match ElfXX_Rel\n"), -@@ -1427,7 +1444,8 @@ +@@ -1447,7 +1464,8 @@ check_rela (Ebl *ebl, GElf_Ehdr *ehdr, G Elf_Data *symdata = elf_getdata (symscn, NULL); enum load_state state = state_undecided; @@ -993,7 +1043,7 @@ { GElf_Rela rela_mem; GElf_Rela *rela = gelf_getrela (data, cnt, &rela_mem); -@@ -1477,7 +1495,8 @@ +@@ -1497,7 +1515,8 @@ check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GE Elf_Data *symdata = elf_getdata (symscn, NULL); enum load_state state = state_undecided; @@ -1003,7 +1053,7 @@ { GElf_Rel rel_mem; GElf_Rel *rel = gelf_getrel (data, cnt, &rel_mem); -@@ -1580,7 +1599,8 @@ +@@ -1600,7 +1619,8 @@ section [%2d] '%s': referenced as string shdr->sh_link, section_name (ebl, shdr->sh_link), idx, section_name (ebl, idx)); @@ -1013,7 +1063,7 @@ ERROR (gettext ("\ section [%2d] '%s': section entry size does not match ElfXX_Dyn\n"), idx, section_name (ebl, idx)); -@@ -1590,7 +1610,7 @@ +@@ -1610,7 +1630,7 @@ section [%2d] '%s': section entry size d idx, section_name (ebl, idx)); bool non_null_warned = false; @@ -1022,7 +1072,7 @@ { GElf_Dyn dyn_mem; GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dyn_mem); -@@ -1871,6 +1891,8 @@ +@@ -1891,6 +1911,8 @@ section [%2d] '%s': entry size does not idx, section_name (ebl, idx)); if (symshdr != NULL @@ -1031,7 +1081,7 @@ && (shdr->sh_size / shdr->sh_entsize < symshdr->sh_size / symshdr->sh_entsize)) ERROR (gettext ("\ -@@ -1897,6 +1919,12 @@ +@@ -1917,6 +1939,12 @@ section [%2d] '%s': extended section ind } Elf_Data *data = elf_getdata (elf_getscn (ebl->elf, idx), NULL); @@ -1044,7 +1094,7 @@ if (*((Elf32_Word *) data->d_buf) != 0) ERROR (gettext ("symbol 0 should have zero extended section index\n")); -@@ -1939,7 +1967,7 @@ +@@ -1959,7 +1987,7 @@ section [%2d] '%s': hash table section i size_t maxidx = nchain; @@ -1053,7 +1103,7 @@ { size_t symsize = symshdr->sh_size / symshdr->sh_entsize; -@@ -1950,18 +1978,28 @@ +@@ -1970,18 +1998,28 @@ section [%2d] '%s': hash table section i maxidx = symsize; } @@ -1084,7 +1134,7 @@ } -@@ -1991,18 +2029,28 @@ +@@ -2011,18 +2049,28 @@ section [%2d] '%s': hash table section i maxidx = symsize; } @@ -1116,7 +1166,7 @@ } -@@ -2027,7 +2075,7 @@ +@@ -2047,7 +2095,7 @@ section [%2d] '%s': bitmask size not pow if (shdr->sh_size < (4 + bitmask_words + nbuckets) * sizeof (Elf32_Word)) { ERROR (gettext ("\ @@ -1125,7 +1175,7 @@ idx, section_name (ebl, idx), (long int) shdr->sh_size, (long int) ((4 + bitmask_words + nbuckets) * sizeof (Elf32_Word))); return; -@@ -2699,8 +2747,9 @@ +@@ -2719,8 +2767,9 @@ section [%2d] '%s' refers in sh_link to /* The number of elements in the version symbol table must be the same as the number of symbols. */ @@ -1137,9 +1187,9 @@ ERROR (gettext ("\ section [%2d] '%s' has different number of entries than symbol table [%2d] '%s'\n"), idx, section_name (ebl, idx), ---- a/src/readelf.c -+++ b/src/readelf.c -@@ -1146,6 +1146,8 @@ +--- elfutils/src/readelf.c ++++ elfutils/src/readelf.c +@@ -1171,6 +1171,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G Elf32_Word *grpref = (Elf32_Word *) data->d_buf; GElf_Sym sym_mem; @@ -1148,7 +1198,7 @@ printf ((grpref[0] & GRP_COMDAT) ? ngettext ("\ \nCOMDAT section group [%2zu] '%s' with signature '%s' contains %zu entry:\n", -@@ -1158,8 +1160,8 @@ +@@ -1183,8 +1185,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G data->d_size / sizeof (Elf32_Word) - 1), elf_ndxscn (scn), elf_strptr (ebl->elf, shstrndx, shdr->sh_name), @@ -1159,7 +1209,7 @@ ?: gettext (""), data->d_size / sizeof (Elf32_Word) - 1); -@@ -1310,7 +1312,8 @@ +@@ -1335,7 +1337,8 @@ static void handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) { int class = gelf_getclass (ebl->elf); @@ -1169,7 +1219,7 @@ Elf_Data *data; size_t cnt; size_t shstrndx; -@@ -1325,6 +1328,11 @@ +@@ -1350,6 +1353,11 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); @@ -1181,7 +1231,7 @@ printf (ngettext ("\ \nDynamic segment contains %lu entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", "\ -@@ -1334,9 +1342,7 @@ +@@ -1359,9 +1367,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, shdr->sh_offset, (int) shdr->sh_link, @@ -1192,7 +1242,7 @@ fputs_unlocked (gettext (" Type Value\n"), stdout); for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) -@@ -1919,6 +1925,13 @@ +@@ -1944,6 +1950,13 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); @@ -1206,7 +1256,7 @@ /* Now we can compute the number of entries in the section. */ unsigned int nsyms = data->d_size / (class == ELFCLASS32 ? sizeof (Elf32_Sym) -@@ -1929,15 +1942,12 @@ +@@ -1954,15 +1967,12 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G nsyms), (unsigned int) elf_ndxscn (scn), elf_strptr (ebl->elf, shstrndx, shdr->sh_name), nsyms); @@ -1223,7 +1273,7 @@ fputs_unlocked (class == ELFCLASS32 ? gettext ("\ -@@ -2173,7 +2183,13 @@ +@@ -2198,7 +2208,13 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn, error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); @@ -1238,7 +1288,7 @@ printf (ngettext ("\ \nVersion needs section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", "\ -@@ -2184,9 +2200,7 @@ +@@ -2209,9 +2225,7 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn, class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, shdr->sh_offset, (unsigned int) shdr->sh_link, @@ -1249,7 +1299,7 @@ unsigned int offset = 0; for (int cnt = shdr->sh_info; --cnt >= 0; ) -@@ -2239,8 +2253,14 @@ +@@ -2264,8 +2278,14 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); @@ -1265,7 +1315,7 @@ printf (ngettext ("\ \nVersion definition section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", "\ -@@ -2252,9 +2272,7 @@ +@@ -2277,9 +2297,7 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, shdr->sh_offset, (unsigned int) shdr->sh_link, @@ -1276,7 +1326,7 @@ unsigned int offset = 0; for (int cnt = shdr->sh_info; --cnt >= 0; ) -@@ -2516,8 +2534,14 @@ +@@ -2541,8 +2559,14 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G filename = NULL; } @@ -1292,7 +1342,7 @@ printf (ngettext ("\ \nVersion symbols section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'", "\ -@@ -2529,9 +2553,7 @@ +@@ -2554,9 +2578,7 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, shdr->sh_offset, (unsigned int) shdr->sh_link, @@ -1303,7 +1353,7 @@ /* Now we can finally look at the actual contents of this section. */ for (unsigned int cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) -@@ -2583,7 +2605,17 @@ +@@ -2608,7 +2630,17 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn, for (Elf32_Word cnt = 0; cnt < nbucket; ++cnt) ++counts[lengths[cnt]]; @@ -1322,7 +1372,7 @@ printf (ngettext ("\ \nHistogram for bucket list length in section [%2u] '%s' (total of %d bucket):\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", "\ -@@ -2596,9 +2628,7 @@ +@@ -2621,9 +2653,7 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn, shdr->sh_addr, shdr->sh_offset, (unsigned int) shdr->sh_link, @@ -1333,7 +1383,7 @@ if (extrastr != NULL) fputs (extrastr, stdout); -@@ -4231,6 +4261,16 @@ +@@ -4265,6 +4295,16 @@ print_debug_aranges_section (Dwfl_Module return; } @@ -1350,9 +1400,9 @@ printf (ngettext ("\ \nDWARF section [%2zu] '%s' at offset %#" PRIx64 " contains %zu entry:\n", "\ ---- a/src/strip.c -+++ b/src/strip.c -@@ -560,6 +560,11 @@ +--- elfutils/src/strip.c ++++ elfutils/src/strip.c +@@ -545,6 +545,11 @@ handle_elf (int fd, Elf *elf, const char goto fail_close; } @@ -1364,7 +1414,7 @@ /* Storage for section information. We leave room for two more entries since we unconditionally create a section header string table. Maybe some weird tool created an ELF file without one. -@@ -581,7 +586,7 @@ +@@ -566,7 +571,7 @@ handle_elf (int fd, Elf *elf, const char { /* This should always be true (i.e., there should not be any holes in the numbering). */ @@ -1373,7 +1423,7 @@ shdr_info[cnt].scn = scn; -@@ -594,6 +599,7 @@ +@@ -579,6 +584,7 @@ handle_elf (int fd, Elf *elf, const char shdr_info[cnt].shdr.sh_name); if (shdr_info[cnt].name == NULL) { @@ -1381,7 +1431,7 @@ error (0, 0, gettext ("illformed file '%s'"), fname); goto fail_close; } -@@ -603,6 +609,8 @@ +@@ -588,6 +594,8 @@ handle_elf (int fd, Elf *elf, const char /* Remember the shdr.sh_link value. */ shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link; @@ -1390,7 +1440,7 @@ /* Sections in files other than relocatable object files which are not loaded can be freely moved by us. In relocatable -@@ -615,7 +623,7 @@ +@@ -600,7 +608,7 @@ handle_elf (int fd, Elf *elf, const char appropriate reference. */ if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX)) { @@ -1399,7 +1449,7 @@ shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt; } else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP)) -@@ -632,7 +640,12 @@ +@@ -617,7 +625,12 @@ handle_elf (int fd, Elf *elf, const char for (inner = 1; inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); ++inner) @@ -1412,7 +1462,7 @@ if (inner == 1 || (inner == 2 && (grpref[0] & GRP_COMDAT) == 0)) /* If the section group contains only one element and this -@@ -643,7 +656,7 @@ +@@ -628,7 +641,7 @@ handle_elf (int fd, Elf *elf, const char } else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym)) { @@ -1421,7 +1471,7 @@ shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt; } -@@ -651,7 +664,7 @@ +@@ -636,7 +649,7 @@ handle_elf (int fd, Elf *elf, const char discarded right away. */ if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0) { @@ -1430,7 +1480,7 @@ if (shdr_info[shdr_info[cnt].group_idx].idx == 0) { -@@ -726,11 +739,15 @@ +@@ -711,11 +724,15 @@ handle_elf (int fd, Elf *elf, const char { /* If a relocation section is marked as being removed make sure the section it is relocating is removed, too. */ @@ -1448,7 +1498,7 @@ if (shdr_info[cnt].idx == 1) { -@@ -757,7 +774,7 @@ +@@ -742,7 +759,7 @@ handle_elf (int fd, Elf *elf, const char if (shdr_info[cnt].symtab_idx != 0 && shdr_info[shdr_info[cnt].symtab_idx].data == NULL) { @@ -1457,7 +1507,7 @@ shdr_info[shdr_info[cnt].symtab_idx].data = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, -@@ -797,6 +814,9 @@ +@@ -782,6 +799,9 @@ handle_elf (int fd, Elf *elf, const char else if (scnidx == SHN_XINDEX) scnidx = xndx; @@ -1467,7 +1517,7 @@ if (shdr_info[scnidx].idx == 0) /* This symbol table has a real symbol in a discarded section. So preserve the -@@ -827,12 +847,16 @@ +@@ -812,12 +832,16 @@ handle_elf (int fd, Elf *elf, const char } /* Handle references through sh_info. */ @@ -1486,7 +1536,7 @@ /* Mark the section as investigated. */ shdr_info[cnt].idx = 2; -@@ -971,7 +995,7 @@ +@@ -956,7 +980,7 @@ handle_elf (int fd, Elf *elf, const char error (EXIT_FAILURE, 0, gettext ("while generating output file: %s"), elf_errmsg (-1)); @@ -1495,7 +1545,7 @@ /* Add this name to the section header string table. */ shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0); -@@ -1008,7 +1032,7 @@ +@@ -993,7 +1017,7 @@ handle_elf (int fd, Elf *elf, const char error (EXIT_FAILURE, 0, gettext ("while create section header section: %s"), elf_errmsg (-1)); @@ -1504,7 +1554,7 @@ shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn); if (shdr_info[cnt].data == NULL) -@@ -1064,7 +1088,7 @@ +@@ -1049,7 +1073,7 @@ handle_elf (int fd, Elf *elf, const char error (EXIT_FAILURE, 0, gettext ("while create section header section: %s"), elf_errmsg (-1)); @@ -1513,7 +1563,7 @@ /* Finalize the string table and fill in the correct indices in the section headers. */ -@@ -1154,20 +1178,20 @@ +@@ -1139,20 +1163,20 @@ handle_elf (int fd, Elf *elf, const char shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, NULL); @@ -1537,7 +1587,7 @@ >= shdr_info[cnt].data->d_size / elsize); } -@@ -1222,7 +1246,7 @@ +@@ -1207,7 +1231,7 @@ handle_elf (int fd, Elf *elf, const char sec = shdr_info[sym->st_shndx].idx; else { @@ -1546,7 +1596,7 @@ sec = shdr_info[xshndx].idx; } -@@ -1243,7 +1267,7 @@ +@@ -1228,7 +1252,7 @@ handle_elf (int fd, Elf *elf, const char nxshndx = sec; } @@ -1555,7 +1605,7 @@ if ((inner != destidx || nshndx != sym->st_shndx || (shndxdata != NULL && nxshndx != xshndx)) -@@ -1267,7 +1291,7 @@ +@@ -1252,7 +1276,7 @@ handle_elf (int fd, Elf *elf, const char || shdr_info[cnt].debug_data == NULL) /* This is a section symbol for a section which has been removed. */ @@ -1564,7 +1614,7 @@ } if (destidx != inner) -@@ -1454,11 +1478,11 @@ +@@ -1439,11 +1463,11 @@ handle_elf (int fd, Elf *elf, const char { GElf_Sym sym_mem; GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem); @@ -1578,7 +1628,7 @@ size_t hidx = elf_hash (name) % nbucket; if (bucket[hidx] == 0) -@@ -1477,7 +1501,7 @@ +@@ -1462,7 +1486,7 @@ handle_elf (int fd, Elf *elf, const char else { /* Alpha and S390 64-bit use 64-bit SHT_HASH entries. */ @@ -1587,7 +1637,7 @@ == sizeof (Elf64_Xword)); Elf64_Xword *bucket = (Elf64_Xword *) hashd->d_buf; -@@ -1508,11 +1532,11 @@ +@@ -1493,11 +1517,11 @@ handle_elf (int fd, Elf *elf, const char { GElf_Sym sym_mem; GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem); diff --git a/elfutils-suse-10.3-fixes.diff b/elfutils-suse-10.3-fixes.diff deleted file mode 100644 index f0fe313..0000000 --- a/elfutils-suse-10.3-fixes.diff +++ /dev/null @@ -1,154 +0,0 @@ ---- libdwfl/Makefile.am-dist 2009-02-19 15:35:22.000000000 +0100 -+++ libdwfl/Makefile.am 2009-02-19 15:36:58.000000000 +0100 -@@ -33,7 +33,8 @@ - else - AM_CFLAGS = - endif --AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 $(WEXTRA) -std=gnu99 -+AM_CFLAGS += -Wall -Wshadow -Wunused -Wformat=2 $(WEXTRA) -std=gnu99 -+AM_CFLAGS += -fgnu89-inline - INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ - -I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib - VERSION = 1 ---- libdwfl/link_map.c-dist 2009-02-15 23:39:44.000000000 +0100 -+++ libdwfl/link_map.c 2009-02-19 15:36:58.000000000 +0100 -@@ -75,10 +75,10 @@ - /* Examine an auxv data block and determine its format. - Return true iff we figured it out. */ - static bool --auxv_format_probe (const void *auxv, size_t size, -+auxv_format_probe (void *auxv, size_t size, - uint_fast8_t *elfclass, uint_fast8_t *elfdata) - { -- const union -+ union - { - char buf[size]; - Elf32_auxv_t a32[size / sizeof (Elf32_auxv_t)]; -@@ -301,7 +301,7 @@ report_r_debug (uint_fast8_t elfclass, u - return true; - } - -- const union -+ union - { - Elf32_Addr a32[n]; - Elf64_Addr a64[n]; -@@ -568,7 +568,7 @@ consider_executable (Dwfl_Module *mod, G - d_val_vaddr, buffer_available, - memory_callback_arg)) - { -- const union -+ union - { - Elf32_Addr a32; - Elf64_Addr a64; -@@ -626,10 +626,11 @@ find_executable (Dwfl *dwfl, GElf_Addr a - - - int --dwfl_link_map_report (Dwfl *dwfl, const void *auxv, size_t auxv_size, -+dwfl_link_map_report (Dwfl *dwfl, const void *_auxv, size_t auxv_size, - Dwfl_Memory_Callback *memory_callback, - void *memory_callback_arg) - { -+ void *auxv = (void *)_auxv; - GElf_Addr r_debug_vaddr = 0; - - uint_fast8_t elfclass = ELFCLASSNONE; -@@ -644,7 +645,7 @@ dwfl_link_map_report (Dwfl *dwfl, const - - #define AUXV_SCAN(NN, BL) do \ - { \ -- const Elf##NN##_auxv_t *av = auxv; \ -+ Elf##NN##_auxv_t *av = auxv; \ - for (size_t i = 0; i < auxv_size / sizeof av[0]; ++i) \ - { \ - Elf##NN##_Addr val = BL##NN (av[i].a_un.a_val); \ -@@ -718,7 +719,7 @@ dwfl_link_map_report (Dwfl *dwfl, const - (&out, &in, elfdata) != NULL)) - { - /* We are looking for PT_DYNAMIC. */ -- const union -+ union - { - Elf32_Phdr p32[phnum]; - Elf64_Phdr p64[phnum]; -@@ -806,7 +807,7 @@ dwfl_link_map_report (Dwfl *dwfl, const - (&out, &in, elfdata) != NULL)) - { - /* We are looking for PT_DYNAMIC. */ -- const union -+ union - { - Elf32_Dyn d32[dyn_filesz / sizeof (Elf32_Dyn)]; - Elf64_Dyn d64[dyn_filesz / sizeof (Elf64_Dyn)]; ---- libdw/Makefile.am-dist 2009-02-19 15:35:22.000000000 +0100 -+++ libdw/Makefile.am 2009-02-19 15:36:58.000000000 +0100 -@@ -35,6 +35,7 @@ - AM_CFLAGS += -fpic - endif - AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 $(WEXTRA) -std=gnu99 -+AM_CFLAGS += -fgnu89-inline - INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib - VERSION = 1 - ---- libdw/libdw.h-dist 2008-12-10 23:21:29.000000000 +0100 -+++ libdw/libdw.h 2009-02-19 15:36:58.000000000 +0100 -@@ -67,7 +67,7 @@ - #ifdef __GNUC_STDC_INLINE__ - # define __libdw_extern_inline extern __inline __attribute__ ((__gnu_inline__)) - #else --# define __libdw_extern_inline extern __inline -+# define __libdw_extern_inline extern __inline __attribute__ ((gnu_inline)) - #endif - - ---- src/Makefile.am-dist 2009-02-19 15:35:22.000000000 +0100 -+++ src/Makefile.am 2009-02-19 15:37:25.000000000 +0100 -@@ -37,6 +37,8 @@ - $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \ - $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $(CFLAGS_$(*F)) - -+AM_CFLAGS += -fgnu89-inline -+ - INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ - -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \ - -I$(srcdir)/../libasm -I$(srcdir)/../lib -I.. ---- src/ldgeneric.c-dist 2008-12-10 23:21:30.000000000 +0100 -+++ src/ldgeneric.c 2009-02-19 15:36:58.000000000 +0100 -@@ -63,6 +63,14 @@ struct unw_eh_frame_hdr - }; - #define EH_FRAME_HDR_VERSION 1 - -+static inline int popcount(unsigned int val) -+{ -+ int count = 0; -+ for (; val; val >>= 1) -+ if (val & 1) -+ count++; -+ return count; -+} - - /* Prototypes for local functions. */ - static const char **ld_generic_lib_extensions (struct ld_state *) -@@ -5830,7 +5838,7 @@ cannot create dynamic symbol table for o - - /* We need one more array which contains the hash codes of the - symbol names. */ -- hashcodes = (Elf32_Word *) xcalloc (__builtin_popcount ((int) ld_state.hash_style) -+ hashcodes = (Elf32_Word *) xcalloc (popcount ((int) ld_state.hash_style) - * nsym_dyn_allocated, - sizeof (Elf32_Word)); - gnuhashcodes = hashcodes; ---- backends/ia64_retval.c-dist 2008-12-10 23:21:28.000000000 +0100 -+++ backends/ia64_retval.c 2009-02-19 15:36:58.000000000 +0100 -@@ -96,7 +96,7 @@ hfa_type (Dwarf_Die *typedie, const Dwar - If we find a datum that's not the same FP type as the first datum, punt. - If we count more than eight total homogeneous FP data, punt. */ - -- inline int hfa (const Dwarf_Op *loc, int nregs) -+ inline __attribute__((gnu_inline)) int hfa (const Dwarf_Op *loc, int nregs) - { - if (fpregs_used == 0) - *locp = loc; diff --git a/elfutils.changes b/elfutils.changes index f7d392a..f58e5ee 100644 --- a/elfutils.changes +++ b/elfutils.changes @@ -1,3 +1,50 @@ +------------------------------------------------------------------- +Tue May 11 20:01:23 UTC 2010 - tonyj@novell.com + +- update to version 0.147 (fix bnc#588293) +- dropped patches for 10.3 and older +- dropped elfutils-0.97-ftruncate-mmap-fix, libelf-ignore-NOBITS, test and + build patches. According to jbl these were mistakenly checked in from + home:janblunck:debuginfo:libs/elfutils and the purpose of this project is + no longer known. Absense of any patch header makes confirmation difficult. + +- Upstream changelog: + 0.147 + - libdw: Fixes in CFI handling, best possible handling of bogus CFA + ops. + - libdwfl: Ignore R_*_NONE relocs, works around old (binutils) ld -r + bugs. + + 0.146 + - libdwfl: New function dwfl_core_file_report. + + 0.145 + - Fix build with --disable-dependency-tracking. + - Fix build with most recent glibc headers. + - libelf: More robust to bogus section headers. + - libdw: Fix CFI decoding. + - libdwfl: Fix address bias returned by CFI accessors. Fix core + file module layout identification. + - readelf: Fix CFI decoding. + + 0.144 + - libelf: New function elf_getphdrnum. Now support using more than + 65536 program headers in a file. + - libdw: New function dwarf_aggregate_size for computing (constant) + type sizes, including array_type cases with nontrivial + calculation. + - readelf: Don't give errors for missing info under -a. + Handle Linux "VMCOREINFO" notes under -n. + + 0.143 + - libdw: Various convenience functions for individual attributes now + use dwarf_attr_integrate to look up indirect inherited + attributes. Location expression handling now supports + DW_OP_implicit_value. + - libdwfl: Support automatic decompression of files in XZ format, + and of Linux kernel images made with bzip2 or LZMA (as well + as gzip). + ------------------------------------------------------------------- Wed Feb 10 12:21:51 CET 2010 - rguenther@suse.de diff --git a/elfutils.spec b/elfutils.spec index 05a8f66..00ffabd 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,5 +1,5 @@ # -# spec file for package elfutils (Version 0.142) +# spec file for package elfutils (Version 0.147) # # Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -19,27 +19,22 @@ Name: elfutils -License: GPLv2+ -Version: 0.142 -Release: 4 +License: GPLv2 ; GPLv2+ ; LGPLv2.1+ +Version: 0.147 +Release: 1 Summary: Higher-level library to access ELF Group: System/Libraries Url: http://elfutils.fedorahosted.org -Source: elfutils-%{version}-no-osl.tar.bz2 +Source: elfutils-%{version}.tar.bz2 Source2: baselibs.conf -Patch: elfutils-portability.patch -Patch1: elfutils-robustify.patch +Patch1: elfutils-portability.patch +Patch2: elfutils-robustify.patch Patch3: elfutils-no-po-test-build.diff -Patch7: libebl-prototype-fix.diff -Patch8: elfutils-0.97-ftruncate-mmap-fix.diff -Patch9: libelf-ignore-NOBITS-sh_offset.patch -Patch10: test.diff -Patch11: build.diff -Patch12: elfutils-old-scanf-fix.diff -Patch13: elfutils-suse-10.3-fixes.diff -Patch20: elfutils-0.137-dwarf-header-check-fix.diff -Patch21: elfutils-uninitialized.diff +Patch4: libebl-prototype-fix.diff +Patch5: elfutils-uninitialized.diff +Patch6: elfutils-0.137-dwarf-header-check-fix.diff BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: bison flex %description This package provides a higher-level library to access ELF files. This @@ -195,23 +190,12 @@ Authors: %prep %setup -q -n elfutils-%{version} -%patch -p1 %patch1 -p1 -%patch3 -%patch7 -%patch8 -p1 -%patch9 -p1 -#%patch10 -p1 -%patch11 -p1 -%if %suse_version < 1100 -%patch12 -%endif -%if %suse_version == 1030 -# only 10.3 gcc has a problem -%patch13 -%endif -%patch20 -p1 -%patch21 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 %build autoreconf -fi @@ -222,6 +206,7 @@ make %{?jobs:-j%jobs}; make DESTDIR=$RPM_BUILD_ROOT install # remove unneeded files rm -f $RPM_BUILD_ROOT%{_libdir}/*.la +ls -lR $RPM_BUILD_ROOT%{_libdir}/libelf* %post -n libebl1 -p /sbin/ldconfig @@ -274,7 +259,7 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root) %{_libdir}/libelf.so %{_libdir}/libelf.a -%{_libdir}/libelf_pic.a +#%{_libdir}/libelf_pic.a %{_includedir}/libelf.h %{_includedir}/gelf.h %{_includedir}/nlist.h diff --git a/libebl-prototype-fix.diff b/libebl-prototype-fix.diff index ca8f74d..cb26571 100644 --- a/libebl-prototype-fix.diff +++ b/libebl-prototype-fix.diff @@ -1,5 +1,11 @@ ---- libebl/eblopenbackend.c-dist 2008-01-28 14:21:23.000000000 +0100 -+++ libebl/eblopenbackend.c 2008-01-28 14:21:39.000000000 +0100 +From: unknown +Upstream: no +References: none + +Update from K&R to ANSI prototype. This fix should go upstream. + +--- elfutils/libebl/eblopenbackend.c-dist 2008-01-28 14:21:23.000000000 +0100 ++++ elfutils/libebl/eblopenbackend.c 2008-01-28 14:21:39.000000000 +0100 @@ -253,10 +253,7 @@ fill_defaults (Ebl *result) /* Find an appropriate backend for the file associated with ELF. */ @@ -12,8 +18,8 @@ { Ebl *result; size_t cnt; ---- lib/dynamicsizehash.c-dist 2008-01-28 14:25:32.000000000 +0100 -+++ lib/dynamicsizehash.c 2008-01-28 14:25:52.000000000 +0100 +--- elfutils/lib/dynamicsizehash.c-dist 2008-01-28 14:25:32.000000000 +0100 ++++ elfutils/lib/dynamicsizehash.c 2008-01-28 14:25:52.000000000 +0100 @@ -65,10 +65,7 @@ diff --git a/libelf-ignore-NOBITS-sh_offset.patch b/libelf-ignore-NOBITS-sh_offset.patch deleted file mode 100644 index 4906a0c..0000000 --- a/libelf-ignore-NOBITS-sh_offset.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- - libelf/elf32_updatenull.c | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -Index: b/libelf/elf32_updatenull.c -=================================================================== ---- a/libelf/elf32_updatenull.c -+++ b/libelf/elf32_updatenull.c -@@ -331,10 +331,11 @@ __elfw2(LIBELFBITS,updatenull) (Elf *elf - - if (elf->flags & ELF_F_LAYOUT) - { -- size = MAX ((GElf_Word) size, -- shdr->sh_offset -- + (shdr->sh_type != SHT_NOBITS -- ? shdr->sh_size : 0)); -+ /* Even the sh_offset is only the "conceptual" possition -+ in the file. So completely ignore NOBITS sections. */ -+ if (shdr->sh_type != SHT_NOBITS) -+ size = MAX ((GElf_Word) size, -+ shdr->sh_offset + shdr->sh_size); - - /* The alignment must be a power of two. This is a - requirement from the ELF specification. Additionally diff --git a/test.diff b/test.diff deleted file mode 100644 index 3232765..0000000 --- a/test.diff +++ /dev/null @@ -1,126 +0,0 @@ ---- - libelf/elf32_updatenull.c | 35 +++++++++++++++++++++++++++++++---- - 1 file changed, 31 insertions(+), 4 deletions(-) - -Index: b/libelf/elf32_updatenull.c -=================================================================== ---- a/libelf/elf32_updatenull.c -+++ b/libelf/elf32_updatenull.c -@@ -55,6 +55,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -144,7 +145,7 @@ __elfw2(LIBELFBITS,updatenull) (Elf *elf - return -1; - - /* At least the ELF header is there. */ -- off_t size = elf_typesize (LIBELFBITS, ELF_T_EHDR, 1); -+ off_t size = elf_typesize (LIBELFBITS, ELF_T_EHDR, 1), old_size; - - /* Set the program header position. */ - if (elf->state.ELFW(elf,LIBELFBITS).phdr == NULL -@@ -166,9 +167,12 @@ __elfw2(LIBELFBITS,updatenull) (Elf *elf - { - /* The user is supposed to fill out e_phoff. Use it and - e_phnum to determine the maximum extend. */ -+ old_size = size; - size = MAX ((size_t) size, - ehdr->e_phoff - + elf_typesize (LIBELFBITS, ELF_T_PHDR, ehdr->e_phnum)); -+ fprintf(stderr, "e_phoff: old=%ld, new=%ld\n", (long) old_size, -+ (long) size); - } - else - { -@@ -176,8 +180,11 @@ __elfw2(LIBELFBITS,updatenull) (Elf *elf - elf_typesize (LIBELFBITS, ELF_T_EHDR, 1), - ehdr_flags); - -+ old_size = size; - /* We need no alignment here. */ - size += elf_typesize (LIBELFBITS, ELF_T_PHDR, ehdr->e_phnum); -+ fprintf(stderr, "e_phnum: old=%ld, new=%ld\n", (long) old_size, -+ (long) size); - } - } - -@@ -334,9 +341,13 @@ __elfw2(LIBELFBITS,updatenull) (Elf *elf - /* Even the sh_offset is only the "conceptual" possition - in the file. So completely ignore NOBITS sections. */ - if (shdr->sh_type != SHT_NOBITS) -- size = MAX ((GElf_Word) size, -- shdr->sh_offset + shdr->sh_size); -- -+ { -+ old_size = size; -+ size = MAX ((GElf_Word) size, -+ shdr->sh_offset + shdr->sh_size); -+ fprintf(stderr, "sh_offset: old=%ld, new=%ld\n", -+ (long) old_size, (long) size); -+ } - /* The alignment must be a power of two. This is a - requirement from the ELF specification. Additionally - we test for the alignment of the section being large -@@ -355,7 +366,11 @@ __elfw2(LIBELFBITS,updatenull) (Elf *elf - update_if_changed (shdr->sh_addralign, sh_align, - scn->shdr_flags); - -+ old_size = size; - size = (size + sh_align - 1) & ~(sh_align - 1); -+ fprintf(stderr, "sh_align: old=%ld, new=%ld\n", -+ (long) old_size, (long) size); -+ - int offset_changed = 0; - update_if_changed (shdr->sh_offset, (GElf_Word) size, - offset_changed); -@@ -373,8 +388,11 @@ __elfw2(LIBELFBITS,updatenull) (Elf *elf - update_if_changed (shdr->sh_size, (GElf_Word) offset, - changed); - -+ old_size = size; - if (shdr->sh_type != SHT_NOBITS) - size += offset; -+ fprintf(stderr, "sh_size: old=%ld, new=%ld\n", -+ (long) old_size, (long) size); - - scn->flags |= changed; - } -@@ -401,9 +419,12 @@ __elfw2(LIBELFBITS,updatenull) (Elf *elf - { - /* The user is supposed to fill out e_phoff. Use it and - e_phnum to determine the maximum extend. */ -+ old_size = size; - size = MAX ((GElf_Word) size, - (ehdr->e_shoff - + (elf_typesize (LIBELFBITS, ELF_T_SHDR, shnum)))); -+ fprintf(stderr, "e_shoff: old=%ld, new=%ld\n", (long) old_size, -+ (long) size); - } - else - { -@@ -413,7 +434,10 @@ __elfw2(LIBELFBITS,updatenull) (Elf *elf - want to be surprised by architectures with less strict - alignment rules. */ - #define SHDR_ALIGN sizeof (ElfW2(LIBELFBITS,Off)) -+ old_size = size; - size = (size + SHDR_ALIGN - 1) & ~(SHDR_ALIGN - 1); -+ fprintf(stderr, "e_shoff(align): old=%ld, new=%ld\n", -+ (long) old_size, (long) size); - - update_if_changed (ehdr->e_shoff, (GElf_Word) size, elf->flags); - update_if_changed (ehdr->e_shentsize, -@@ -421,7 +445,10 @@ __elfw2(LIBELFBITS,updatenull) (Elf *elf - ehdr_flags); - - /* Account for the section header size. */ -+ old_size = size; - size += elf_typesize (LIBELFBITS, ELF_T_SHDR, shnum); -+ fprintf(stderr, "shnum: old=%ld, new=%ld\n", (long) old_size, -+ (long) size); - } - } -