diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 14bd43f..0000000 --- a/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -testfile16.symtab.bz2 -testfile16.symtab.debug.bz2 -elfutils-0.134.tar.gz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..264d3c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +elfutils-0.141.tar.bz2 diff --git a/Makefile b/Makefile deleted file mode 100644 index 208b99f..0000000 --- a/Makefile +++ /dev/null @@ -1,96 +0,0 @@ -# Makefile for source rpm: elfutils -# $Id$ -NAME := elfutils -SPECFILE = elfutils.spec - -UPSTREAM_CHECKS := sig -UPSTREAM_FILES = $(NAME)-$(VERSION).tar.gz -upstream:; - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attept a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) - -CURL += -k - -MONOTONE = mtn - -branch-portability = portable - -elfutils-%.patch: elfutils-$(VERSION).tar.gz Makefile - @rm -rf elfutils-master elfutils-$* -# $(MONOTONE) checkout -b com.redhat.elfutils elfutils-master - $(MONOTONE) checkout -b com.redhat.elfutils \ - -r t:elfutils-$(VERSION) elfutils-master - $(MONOTONE) checkout \ - -b com.redhat.elfutils.$(firstword $(branch-$*) $*) \ - elfutils-$* - cd elfutils-master; autoreconf -i; rm -rf autom4te.cache _MTN - cd elfutils-$*; autoreconf -i; rm -rf autom4te.cache _MTN - diff -Nrpu elfutils-master elfutils-$* | \ - filterdiff --remove-timestamps --strip=1 --addprefix=elfutils/ > $@.new - mv $@.new $@ - -elfutils-portable.spec: elfutils.spec - (echo '%define _with_compat 1'; sed 's/ check$$/& || :/' $<) > $@.new - mv -f $@.new $@ - -portable-r = 0.$(subst $(DIST),,$(RELEASE)) -portable-vr = $(VERSION)-$(portable-r) -portable.srpm = elfutils-$(portable-vr).src.rpm -$(portable.srpm): elfutils-portable.spec elfutils-portability.patch \ - elfutils-$(VERSION).tar.gz - $(RPM_WITH_DIRS) --nodeps -bs $< - -portable-srpm: $(portable.srpm) - -portable-dist = 3.0E-scratch -portable-build = \ - $(redhat)/brewroot/packages/elfutils/$(VERSION)/$(portable-r) - -ifeq (,$(wildcard /mnt/redhat/brewroot/packages/elfutils)) -redhat = datadump.devel.redhat.com::redhat -rsync-to = devserv.devel.redhat.com:dist/elfutils/devel/systemtap-dist/ -build-dep = $(portable.srpm) -else -redhat = /mnt/redhat -$(portable-build): $(portable.srpm) - brew build $(BUILD_FLAGS) dist-$(portable-dist) $< -rsync-to = $(public) -build-dep = $(portable-build)/src/$(portable.srpm) -portable-build: $(portable-build) -$(build-dep): $(portable-build) -endif - -dist-files = README.elfutils systemtap-elfutils.repo -rsync-files = --exclude=tests --exclude=data $(portable-build)/ -public = sources.redhat.com:/sourceware/ftp/anonftp/pub/systemtap/elfutils/ - -RSYNC = RSYNC_RSH=ssh rsync - -systemtap-dist: $(build-dep) $(dist-files) - @mkdir -p $@ - $(RSYNC) -a --delete --progress -v $(rsync-files) systemtap-dist/ - ln $(dist-files) systemtap-dist/ - ln -v `rpm -qlp $<` systemtap-dist/ - -systemtap-dist-createrepo: systemtap-dist -ifneq ($(wildcard /usr/bin/createrepo),) - createrepo -q `cd $<; /bin/pwd` -endif - -systemtap-sync: systemtap-dist-createrepo - $(RSYNC) -az --delete --progress -v systemtap-dist/ $(rsync-to) diff --git a/README.elfutils b/README.elfutils deleted file mode 100644 index 730d93a..0000000 --- a/README.elfutils +++ /dev/null @@ -1,76 +0,0 @@ -THIS IS HERE ONLY TO SUPPORT SYSTEMTAP DEVELOPMENT. IT IS NOT FOR GENERAL USE. - -Building systemtap requires a recent development version of elfutils, -which provides libraries for making use of debugging information. - -This is unfinished work in active development. This code is not intended -for general consumption in its present form. Development of these -libraries is simultaneous with Systemtap development. The Systemtap code -will require new versions as things evolve; the systemtap.spec.in file in -the systemtap source tree should always indicate the minimum version of -elfutils libraries that will suffice. We will make an effort to make a -compatible version available here, that you can use for compiling Systemtap. - -Current elfutils can always be found in Fedora Core Development, AKA Rawhide. -If you are interested in the elfutils code in general or for any purpose -other than developing Systemtap, please see http://fedora.redhat.com/ about -getting involved with Fedora Core Development directly. - -To use the elfutils libraries to build Systemtap, you can either use -installed libraries, or you can build elfutils from source as part of the -systemtap build. To use installed libraries, you'll need to have the -current elfutils version installed on your system where the compiler will -find it with whatever build flags you pass systemtap's configure script. -Unless your system already has the current elfutils installed -(i.e. Rawhide), you'll have to install a nonstandard build either via RPM -or by hand with "make" as detailed below. To build the elfutils source -locally as part of the systemtap build, see systemtap's README about the ---with-elfutils=... option to systemtap's configure. - -You can find the rawhide rpms updated daily on a variety of sites -(see http://fedora.redhat.com/download/mirrors.html) under core/development. -What's distributed in this directory is made trivially from those same sources. - -The vanilla elfutils code, in elfutils-VERSION.tar.gz and what the rawhide -RPMs ordinarily build, can only be built using GCC 4 and a recent glibc. -Fedora Core 4 is the only released system meeting the requirements. - -To rebuild the rawhide src.rpm on an older system, you can use: - - rpmbuild --with compat --rebuild elfutils-VERSION-N.src.rpm - -The SRPMS/elfutils-VERSION-0.N.src.rpm provided here is exactly the same as -the elfutils-VERSION-N.src.rpm from Rawhide except that it doesn't require -that you specify --with compat to build on an older system. - -We have done this for you for a few architectures, and those RPMs are -available here. These were built on RHEL3, and so their requirements -should not be too demanding. We must remind you that this is unsupported, -pre-beta development code. Furthermore, these builds are completely -unofficial, unsupported, unsigned, unlikely to have been tested, -unequivocally not guaranteed not to ruin your whole day, and we really -cannot recommend that anyone install them on their system. Do so at your -own risk. All that said, here they is, and if you copy this file: - - ftp://sources.redhat.com/pub/systemtap/elfutils/systemtap-elfutils.repo - -into your /etc/yum.repos.d/ directory, then you can get them all with just: - - yum install elfutils-devel - - -To compile elfutils from source by hand, simply use elfutils-VERSION.tar.gz -and follow the usual procedure for GNU configure conventions. The patch -available here has to be applied before you can compile on an older system: - - tar xzf elfutils-VERSION.tar.gz - patch -p1 -d elfutils-VERSION < elfutils-portability.patch - cd elfutils-VERSION - ./configure --program-prefix=eu-devel- - make && make check && make install - -(That of course installs things under /usr/local, unlike the RPMs.) - - -Caveat emptor. Carpe noctem. -Reply to . diff --git a/elfutils-0.134.tar.gz.sig b/elfutils-0.134.tar.gz.sig deleted file mode 100644 index 9fff7d5..0000000 Binary files a/elfutils-0.134.tar.gz.sig and /dev/null differ diff --git a/elfutils-portability.patch b/elfutils-portability.patch index 464cf1e..79dc4fa 100644 --- a/elfutils-portability.patch +++ b/elfutils-portability.patch @@ -1,6 +1,17 @@ --- elfutils/backends/ChangeLog +++ elfutils/backends/ChangeLog -@@ -296,6 +296,11 @@ +@@ -33,6 +33,10 @@ + * ppc_attrs.c (ppc_check_object_attribute): Handle tag + GNU_Power_ABI_Struct_Return. + ++2009-01-23 Roland McGrath ++ ++ * Makefile.am (libebl_%.so): Use $(LD_AS_NEEDED). ++ + 2008-10-04 Ulrich Drepper + + * i386_reloc.def: Fix entries for TLS_GOTDESC, TLS_DESC_CALL, and +@@ -360,6 +364,11 @@ * sparc_init.c: Likewise. * x86_64_init.c: Likewise. @@ -12,7 +23,7 @@ 2005-11-19 Roland McGrath * ppc64_reloc.def: REL30 -> ADDR30. -@@ -318,6 +323,9 @@ +@@ -382,6 +391,9 @@ * Makefile.am (uninstall): Don't try to remove $(pkgincludedir). (CLEANFILES): Add libebl_$(m).so. @@ -46,11 +57,20 @@ - i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c \ - i386_retval.c i386_regs.c i386_auxv.c + i386_retval.c i386_regs.c i386_auxv.c i386_syscall.c cpu_i386 = ../libcpu/libcpu_i386.a +@@ -115,7 +116,7 @@ libebl_%.so: libebl_%_pic.a libebl_%.map + $(LINK) -shared -o $@ -Wl,--whole-archive,$<\ + $(cpu_$(@:libebl_%.so=%)) -Wl,--no-whole-archive \ + -Wl,--version-script,$(word 2,$^) \ +- -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... --- elfutils/backends/Makefile.in +++ elfutils/backends/Makefile.in -@@ -153,6 +153,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -158,6 +158,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -58,7 +78,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -182,6 +183,7 @@ SHELL = @SHELL@ +@@ -187,6 +188,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ @@ -66,9 +86,9 @@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ -@@ -237,9 +239,9 @@ target_alias = @target_alias@ - top_builddir = @top_builddir@ +@@ -245,9 +247,9 @@ top_builddir = @top_builddir@ 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 @@ -78,9 +98,27 @@ INCLUDES = -I$(srcdir) -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \ -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ -I$(top_srcdir)/lib -I.. +@@ -650,7 +652,7 @@ libebl_%.so: libebl_%_pic.a libebl_%.map + $(LINK) -shared -o $@ -Wl,--whole-archive,$<\ + $(cpu_$(@:libebl_%.so=%)) -Wl,--no-whole-archive \ + -Wl,--version-script,$(word 2,$^) \ +- -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... --- elfutils/ChangeLog +++ elfutils/ChangeLog -@@ -30,6 +30,10 @@ +@@ -9,6 +9,8 @@ + + 2009-01-23 Roland McGrath + ++ * configure.ac: Check for __builtin_popcount. ++ + * 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 @@ * configure.ac: Add dummy automake conditional to get dependencies for non-generic linker right. See src/Makefile.am. @@ -91,7 +129,7 @@ 2005-11-18 Roland McGrath * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): New variable. -@@ -77,6 +81,17 @@ +@@ -136,6 +142,17 @@ * Makefile.am (all_SUBDIRS): Add libdwfl. * configure.ac: Write libdwfl/Makefile. @@ -99,19 +137,19 @@ + + * configure.ac (WEXTRA): Check for -Wextra and set this substitution. + -+ * configure.ac: Check for struct stat st_?tim members. -+ * src/strip.c (process_file): Use st_?time if st_?tim are not there. ++ * configure.ac: Check for struct stat st_?tim members. ++ * src/strip.c (process_file): Use st_?time if st_?tim are not there. + -+ * configure.ac: Check for futimes function. -+ * src/strip.c (handle_elf) [! HAVE_FUTIMES]: Use utimes instead. -+ (handle_ar) [! HAVE_FUTIMES]: Likewise. ++ * configure.ac: Check for futimes function. ++ * src/strip.c (handle_elf) [! HAVE_FUTIMES]: Use utimes instead. ++ (handle_ar) [! HAVE_FUTIMES]: Likewise. + 2005-05-19 Roland McGrath * configure.ac [AH_BOTTOM] (INTDECL, _INTDECL): New macros. --- elfutils/config/Makefile.in +++ elfutils/config/Makefile.in -@@ -72,6 +72,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -73,6 +73,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -119,7 +157,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -101,6 +102,7 @@ SHELL = @SHELL@ +@@ -102,6 +103,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ @@ -127,25 +165,44 @@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ +--- elfutils/config.h.in ++++ elfutils/config.h.in +@@ -1,5 +1,8 @@ + /* config.h.in. Generated from configure.ac by autoheader. */ + ++/* Have __builtin_popcount. */ ++#undef HAVE_BUILTIN_POPCOUNT ++ + /* $libdir subdirectory containing libebl modules. */ + #undef LIBEBL_SUBDIR + +@@ -52,4 +55,7 @@ + /* Define for large files, on AIX-style hosts. */ + #undef _LARGE_FILES + ++/* Stubbed out if missing compiler support. */ ++#undef __thread ++ + #include --- elfutils/configure +++ elfutils/configure -@@ -674,6 +674,8 @@ YFLAGS - LEX - LEX_OUTPUT_ROOT - LEXLIB -+WEXTRA -+LD_AS_NEEDED - LOCALEDIR - DATADIRNAME +@@ -642,6 +642,8 @@ NATIVE_LD_FALSE NATIVE_LD_TRUE -@@ -3877,6 +3879,88 @@ echo "$as_me: error: gcc with C99 suppor + DATADIRNAME + LOCALEDIR ++LD_AS_NEEDED ++WEXTRA + LEXLIB + LEX_OUTPUT_ROOT + LEX +@@ -4041,6 +4043,152 @@ $as_echo "$as_me: error: gcc with C99 su fi -+{ echo "$as_me:$LINENO: checking for -Wextra option to $CC" >&5 -+echo $ECHO_N "checking for -Wextra option to $CC... $ECHO_C" >&6; } ++{ $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 -+ echo $ECHO_N "(cached) $ECHO_C" >&6 ++ $as_echo_n "(cached) " >&6 +else + old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wextra" @@ -158,20 +215,21 @@ + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac -+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 ++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 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&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 -+ echo "$as_me: failed program was:" >&5 ++ $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_cc_wextra=no @@ -180,8 +238,8 @@ +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$old_CFLAGS" +fi -+{ echo "$as_me:$LINENO: result: $ac_cv_cc_wextra" >&5 -+echo "${ECHO_T}$ac_cv_cc_wextra" >&6; } ++{ $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 @@ -190,10 +248,10 @@ +fi + + -+{ echo "$as_me:$LINENO: checking for --as-needed linker option" >&5 -+echo $ECHO_N "checking for --as-needed linker option... $ECHO_C" >&6; } ++{ $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 -+ echo $ECHO_N "(cached) $ECHO_C" >&6 ++ $as_echo_n "(cached) " >&6 +else + cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } +then + ac_cv_as_needed=yes @@ -213,8 +271,8 @@ +fi +rm -f conftest* +fi -+{ echo "$as_me:$LINENO: result: $ac_cv_as_needed" >&5 -+echo "${ECHO_T}$ac_cv_as_needed" >&6; } ++{ $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 @@ -223,44 +281,97 @@ + + + ++{ $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. */ + - LOCALEDIR=$datadir ++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 +@@ -4106,9 +4254,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 - cat >>confdefs.h <<_ACEOF -@@ -5621,10 +5705,10 @@ YFLAGS!$YFLAGS$ac_delim - LEX!$LEX$ac_delim - LEX_OUTPUT_ROOT!$LEX_OUTPUT_ROOT$ac_delim - LEXLIB!$LEXLIB$ac_delim -+WEXTRA!$WEXTRA$ac_delim -+LD_AS_NEEDED!$LD_AS_NEEDED$ac_delim - LOCALEDIR!$LOCALEDIR$ac_delim - DATADIRNAME!$DATADIRNAME$ac_delim --NATIVE_LD_TRUE!$NATIVE_LD_TRUE$ac_delim --NATIVE_LD_FALSE!$NATIVE_LD_FALSE$ac_delim - _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then -@@ -5666,6 +5750,8 @@ _ACEOF - ac_delim='%!_!# ' - for ac_last_try in false false false false false :; do - cat >conf$$subs.sed <<_ACEOF -+NATIVE_LD_TRUE!$NATIVE_LD_TRUE$ac_delim -+NATIVE_LD_FALSE!$NATIVE_LD_FALSE$ac_delim - base_cpu!$base_cpu$ac_delim - NEVER_TRUE!$NEVER_TRUE$ac_delim - NEVER_FALSE!$NEVER_FALSE$ac_delim -@@ -5697,7 +5783,7 @@ LIBOBJS!$LIBOBJS$ac_delim - LTLIBOBJS!$LTLIBOBJS$ac_delim - _ACEOF - -- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 29; then -+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 31; then - break - elif $ac_last_try; then - { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 --- elfutils/configure.ac +++ elfutils/configure.ac -@@ -71,6 +71,34 @@ CFLAGS="$old_CFLAGS"]) +@@ -74,6 +74,39 @@ CFLAGS="$old_CFLAGS"]) AS_IF([test "x$ac_cv_c99" != xyes], AC_MSG_ERROR([gcc with C99 support required])) @@ -291,13 +402,39 @@ + [LD_AS_NEEDED=-Wl,--as-needed], [LD_AS_NEEDED=]) +AC_SUBST(LD_AS_NEEDED) + ++AC_CACHE_CHECK([for __builtin_popcount], ac_cv_popcount, [dnl ++AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[exit (__builtin_popcount (127));]])], ++ ac_cv_popcount=yes, ac_cv_popcount=no)]) ++AS_IF([test "x$ac_cv_popcount" = xyes], ++ [AC_DEFINE([HAVE_BUILTIN_POPCOUNT], [1], [Have __builtin_popcount.])]) + + AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl + # Use the same flags that we use for our DSOs, so the test is representative. + # Some old compiler/linker/libc combinations fail some ways and not others. +@@ -89,7 +122,10 @@ static __thread int a; int foo (int b) { + CFLAGS="$save_CFLAGS" + LDFLAGS="$save_LDFLAGS"]) + AS_IF([test "x$ac_cv_tls" != xyes], +- AC_MSG_ERROR([__thread support required])) ++ [AS_IF([test "$use_locks" = yes], ++ [AC_MSG_ERROR([--enable-thread-safety requires __thread support])], ++ [AC_DEFINE([__thread], [/* empty: no multi-thread support */], ++ [Stubbed out if missing compiler support.])])]) + LOCALEDIR=$datadir AC_SUBST(LOCALEDIR) - AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR") --- elfutils/lib/ChangeLog +++ elfutils/lib/ChangeLog -@@ -30,6 +30,11 @@ +@@ -1,5 +1,8 @@ + 2009-01-23 Roland McGrath + ++ * eu-config.h [! HAVE_BUILTIN_POPCOUNT] ++ (__builtin_popcount): New inline function. ++ + * eu-config.h: Add multiple inclusion protection. + + 2009-01-17 Ulrich Drepper +@@ -56,6 +59,11 @@ * Makefile.am (libeu_a_SOURCES): Add it. * system.h: Declare crc32_file. @@ -309,6 +446,25 @@ 2005-04-30 Ulrich Drepper * Makefile.am: Use -ffunction-sections for xmalloc.c. +--- elfutils/lib/eu-config.h ++++ elfutils/lib/eu-config.h +@@ -182,5 +182,16 @@ asm (".section predict_data, \"aw\"; .pr + /* This macro is used by the tests conditionalize for standalone building. */ + #define ELFUTILS_HEADER(name) + ++#ifndef HAVE_BUILTIN_POPCOUNT ++# define __builtin_popcount hakmem_popcount ++static inline unsigned int __attribute__ ((unused)) ++hakmem_popcount (unsigned int x) ++{ ++ /* HAKMEM 169 */ ++ unsigned int n = x - ((x >> 1) & 033333333333) - ((x >> 2) & 011111111111); ++ return ((n + (n >> 3)) & 030707070707) % 63; ++} ++#endif /* HAVE_BUILTIN_POPCOUNT */ ++ + + #endif /* eu-config.h */ --- elfutils/lib/Makefile.am +++ elfutils/lib/Makefile.am @@ -25,12 +25,13 @@ @@ -328,7 +484,7 @@ noinst_LIBRARIES = libeu.a --- elfutils/lib/Makefile.in +++ elfutils/lib/Makefile.in -@@ -93,6 +93,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -94,6 +94,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -336,7 +492,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -122,6 +123,7 @@ SHELL = @SHELL@ +@@ -123,6 +124,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ @@ -344,9 +500,9 @@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ -@@ -177,9 +179,9 @@ target_alias = @target_alias@ - top_builddir = @top_builddir@ +@@ -181,9 +183,9 @@ top_builddir = @top_builddir@ 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) @@ -358,7 +514,7 @@ libeu_a_SOURCES = xstrndup.c xmalloc.c next_prime.c \ --- elfutils/libasm/ChangeLog +++ elfutils/libasm/ChangeLog -@@ -54,6 +54,11 @@ +@@ -63,6 +63,11 @@ * asm_error.c: Add new error ASM_E_IOERROR. * libasmP.h: Add ASM_E_IOERROR definition. @@ -389,7 +545,7 @@ -I$(top_srcdir)/lib --- elfutils/libasm/Makefile.in +++ elfutils/libasm/Makefile.in -@@ -126,6 +126,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -128,6 +128,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -397,7 +553,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -155,6 +156,7 @@ SHELL = @SHELL@ +@@ -157,6 +158,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 @@ -405,9 +561,9 @@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ -@@ -210,9 +212,9 @@ target_alias = @target_alias@ - top_builddir = @top_builddir@ +@@ -215,9 +217,9 @@ top_builddir = @top_builddir@ 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 @@ -419,7 +575,17 @@ -I$(top_srcdir)/lib --- elfutils/libcpu/ChangeLog +++ elfutils/libcpu/ChangeLog -@@ -265,6 +265,11 @@ +@@ -5,6 +5,9 @@ + + 2009-01-23 Roland McGrath + ++ * i386_disasm.c (i386_disasm): Add abort after assert-constant for old ++ compilers that don't realize it's noreturn. ++ + * Makefile.am (i386_parse_CFLAGS): Use quotes around command + substitution that can produce leading whitespace. + +@@ -334,6 +337,11 @@ * defs/i386.doc: New file. * defs/x86_64: New file. @@ -431,6 +597,16 @@ 2005-02-15 Ulrich Drepper * Makefile (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2. +--- 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"); ++ abort (); + } + } + else --- elfutils/libcpu/Makefile.am +++ elfutils/libcpu/Makefile.am @@ -30,7 +30,8 @@ AM_CFLAGS = -fmudflap @@ -440,12 +616,12 @@ -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) - INCLUDES = -I$(srcdir) -I$(srcdir)/../lib -I$(srcdir)/../libelf \ --- elfutils/libcpu/Makefile.in +++ elfutils/libcpu/Makefile.in -@@ -109,6 +109,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -110,6 +110,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -453,7 +629,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = lex.$( @@ -510,7 +688,7 @@ --- elfutils/libdw/Makefile.in +++ elfutils/libdw/Makefile.in -@@ -164,6 +164,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -165,6 +165,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -518,7 +696,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -193,6 +194,7 @@ SHELL = @SHELL@ +@@ -194,6 +195,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 @@ -526,9 +704,9 @@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ -@@ -248,9 +250,10 @@ target_alias = @target_alias@ - top_builddir = @top_builddir@ +@@ -252,9 +254,10 @@ top_builddir = @top_builddir@ 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 @@ -541,7 +719,7 @@ $(COMPILE))) --- elfutils/libdwfl/ChangeLog +++ elfutils/libdwfl/ChangeLog -@@ -787,6 +787,11 @@ +@@ -1076,6 +1076,11 @@ 2005-07-21 Roland McGrath @@ -572,7 +750,7 @@ VERSION = 1 --- elfutils/libdwfl/Makefile.in +++ elfutils/libdwfl/Makefile.in -@@ -129,6 +129,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -156,6 +156,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -580,7 +758,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -158,6 +159,7 @@ SHELL = @SHELL@ +@@ -185,6 +186,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 @@ -588,9 +766,9 @@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ -@@ -213,9 +215,9 @@ target_alias = @target_alias@ - top_builddir = @top_builddir@ +@@ -243,9 +245,9 @@ top_builddir = @top_builddir@ 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 @@ -602,7 +780,7 @@ --- elfutils/libebl/ChangeLog +++ elfutils/libebl/ChangeLog -@@ -538,6 +538,11 @@ +@@ -569,6 +569,11 @@ * Makefile.am (libebl_*_so_SOURCES): Set to $(*_SRCS) so dependency tracking works right. @@ -633,7 +811,7 @@ INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ --- elfutils/libebl/Makefile.in +++ elfutils/libebl/Makefile.in -@@ -122,6 +122,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -124,6 +124,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -641,7 +819,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -151,6 +152,7 @@ SHELL = @SHELL@ +@@ -153,6 +154,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 @@ -649,9 +827,9 @@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ -@@ -206,9 +208,9 @@ target_alias = @target_alias@ - top_builddir = @top_builddir@ +@@ -211,9 +213,9 @@ top_builddir = @top_builddir@ 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 @@ -663,21 +841,21 @@ --- elfutils/libelf/ChangeLog +++ elfutils/libelf/ChangeLog -@@ -359,6 +359,11 @@ - 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. +@@ -537,6 +537,11 @@ + + * elf.h: Update from glibc. +2005-05-31 Roland McGrath + + * Makefile.am (WEXTRA): New variable, substituted by configure. + (AM_CFLAGS): Use it in place of -Wextra. + - 2005-05-11 Ulrich Drepper + 2005-05-08 Roland McGrath - * elf.h: Update again. + * elf_begin.c (read_file) [_MUDFLAP]: Don't use mmap for now. --- elfutils/libelf/common.h +++ elfutils/libelf/common.h -@@ -159,7 +159,7 @@ libelf_release_all (Elf *elf) +@@ -160,7 +160,7 @@ libelf_release_all (Elf *elf) (Var) = (sizeof (Var) == 1 \ ? (unsigned char) (Var) \ : (sizeof (Var) == 2 \ @@ -686,7 +864,7 @@ : (sizeof (Var) == 4 \ ? bswap_32 (Var) \ : bswap_64 (Var)))) -@@ -168,7 +168,7 @@ libelf_release_all (Elf *elf) +@@ -169,7 +169,7 @@ libelf_release_all (Elf *elf) (Dst) = (sizeof (Var) == 1 \ ? (unsigned char) (Var) \ : (sizeof (Var) == 2 \ @@ -705,30 +883,18 @@ if MUDFLAP AM_CFLAGS = -fmudflap else -@@ -33,7 +34,10 @@ endif +@@ -33,7 +34,7 @@ endif if BUILD_STATIC AM_CFLAGS += -fpic endif -AM_CFLAGS += -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 -std=gnu99 \ -+if BUILD_STATIC -+AM_CFLAGS += -fpic -+endif +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) --- elfutils/libelf/Makefile.in +++ elfutils/libelf/Makefile.in -@@ -34,7 +34,7 @@ PRE_UNINSTALL = : - POST_UNINSTALL = : - build_triplet = @build@ - host_triplet = @host@ --@BUILD_STATIC_TRUE@am__append_1 = -fpic -+@BUILD_STATIC_TRUE@am__append_1 = -fpic -fpic - @MUDFLAP_FALSE@noinst_PROGRAMS = $(am__EXEEXT_1) - @MUDFLAP_TRUE@am_libelf_pic_a_OBJECTS = - subdir = libelf -@@ -170,6 +170,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -172,6 +172,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -736,7 +902,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -199,6 +200,7 @@ SHELL = @SHELL@ +@@ -201,6 +202,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 @@ -744,9 +910,9 @@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ -@@ -254,10 +256,10 @@ target_alias = @target_alias@ - top_builddir = @top_builddir@ +@@ -259,10 +261,10 @@ top_builddir = @top_builddir@ 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 \ @@ -759,7 +925,7 @@ GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include) --- elfutils/m4/Makefile.in +++ elfutils/m4/Makefile.in -@@ -71,6 +71,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -72,6 +72,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -767,7 +933,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -100,6 +101,7 @@ SHELL = @SHELL@ +@@ -101,6 +102,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ @@ -777,7 +943,7 @@ YACC = @YACC@ --- elfutils/Makefile.in +++ elfutils/Makefile.in -@@ -98,6 +98,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -110,6 +110,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -785,7 +951,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -127,6 +128,7 @@ SHELL = @SHELL@ +@@ -139,6 +140,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ @@ -793,9 +959,33 @@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ +--- elfutils/src/addr2line.c ++++ elfutils/src/addr2line.c +@@ -447,10 +447,10 @@ handle_address (const char *string, Dwfl + bool parsed = false; + int n; + char *name = NULL; +- if (sscanf (string, "(%m[^)])%" PRIiMAX "%n", &name, &addr, &n) == 2 ++ if (sscanf (string, "(%a[^)])%" 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, "%a[^-+]%" PRIiMAX "%n", &name, &addr, &n) == 2 + && string[n] == '\0') + { + /* It was symbol+offset. */ --- elfutils/src/ChangeLog +++ elfutils/src/ChangeLog -@@ -15,6 +15,11 @@ +@@ -91,6 +91,8 @@ + * readelf.c (print_debug_frame_section): Use t instead of j formats + for ptrdiff_t OFFSET. + ++ * addr2line.c (handle_address): Use %a instead of %m for compatibility. ++ + 2009-01-21 Ulrich Drepper + + * elflint.c (check_program_header): Fix typo in .eh_frame_hdr section +@@ -274,6 +276,11 @@ that matches its PT_LOAD's p_flags &~ PF_W. On sparc, PF_X really is valid in RELRO. @@ -807,7 +997,7 @@ 2008-02-29 Roland McGrath * readelf.c (print_attributes): Add a cast. -@@ -266,6 +271,8 @@ +@@ -525,6 +532,8 @@ * readelf.c (hex_dump): Fix rounding error in whitespace calculation. @@ -816,7 +1006,7 @@ 2007-10-15 Roland McGrath * make-debug-archive.in: New file. -@@ -705,6 +712,10 @@ +@@ -964,6 +973,10 @@ * elflint.c (valid_e_machine): Add EM_ALPHA. Reported by Christian Aichinger . @@ -827,7 +1017,7 @@ 2006-08-08 Ulrich Drepper * elflint.c (check_dynamic): Don't require DT_HASH for DT_SYMTAB. -@@ -781,6 +792,10 @@ +@@ -1040,6 +1053,10 @@ * Makefile.am: Add hacks to create dependency files for non-generic linker. @@ -838,7 +1028,7 @@ 2006-06-12 Ulrich Drepper * ldgeneric.c (ld_generic_generate_sections): Don't create .interp -@@ -1129,6 +1144,11 @@ +@@ -1388,6 +1405,11 @@ * readelf.c (print_debug_loc_section): Fix indentation for larger address size. @@ -852,7 +1042,7 @@ * readelf.c (print_debug_line_section): Print section offset of each --- elfutils/src/findtextrel.c +++ elfutils/src/findtextrel.c -@@ -488,7 +488,11 @@ ptrcompare (const void *p1, const void * +@@ -490,7 +490,11 @@ ptrcompare (const void *p1, const void * static void @@ -881,10 +1071,10 @@ $(if $($(*F)_no_Werror),,-Werror) \ - $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ + $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \ - $(if $($(*F)_no_Wformat),,-Wformat=2) $(CFLAGS_$(*F)) + $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $(CFLAGS_$(*F)) INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ -@@ -111,6 +112,9 @@ strings_no_Wformat = yes +@@ -112,6 +113,9 @@ addr2line_no_Wformat = yes # XXX While the file is not finished, don't warn about this ldgeneric_no_Wunused = yes @@ -896,7 +1086,7 @@ size_LDADD = $(libelf) $(libeu) $(libmudflap) --- elfutils/src/Makefile.in +++ elfutils/src/Makefile.in -@@ -201,6 +201,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -202,6 +202,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -904,7 +1094,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -230,6 +231,7 @@ SHELL = @SHELL@ +@@ -231,6 +232,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ @@ -912,24 +1102,24 @@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ -d -@@ -287,13 +289,13 @@ top_srcdir = @top_srcdir@ +@@ -291,13 +293,13 @@ zip_LIBS = @zip_LIBS@ @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),,-Wformat=2) \ + @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),,-Wformat=2) $(CFLAGS_$(*F)) + @MUDFLAP_TRUE@ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \ + @MUDFLAP_TRUE@ $(CFLAGS_$(*F)) INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ - -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \ -@@ -337,6 +339,9 @@ size_no_Wformat = yes - strings_no_Wformat = yes +@@ -343,6 +345,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 + @@ -940,7 +1130,7 @@ size_LDADD = $(libelf) $(libeu) $(libmudflap) --- elfutils/src/readelf.c +++ elfutils/src/readelf.c -@@ -6340,7 +6340,7 @@ dump_archive_index (Elf *elf, const char +@@ -7443,7 +7443,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)) @@ -1010,7 +1200,7 @@ } /* Open the file. */ -@@ -1703,7 +1719,7 @@ handle_elf (int fd, Elf *elf, const char +@@ -1746,7 +1762,7 @@ handle_elf (int fd, Elf *elf, const char /* If requested, preserve the timestamp. */ if (tvp != NULL) { @@ -1019,7 +1209,7 @@ { error (0, errno, gettext ("\ cannot set access and modification date of '%s'"), -@@ -1760,7 +1776,7 @@ handle_ar (int fd, Elf *elf, const char +@@ -1803,7 +1819,7 @@ handle_ar (int fd, Elf *elf, const char if (tvp != NULL) { @@ -1030,7 +1220,7 @@ cannot set access and modification date of '%s'"), fname); --- elfutils/tests/ChangeLog +++ elfutils/tests/ChangeLog -@@ -32,6 +32,8 @@ +@@ -106,6 +106,8 @@ 2008-01-21 Roland McGrath @@ -1039,7 +1229,7 @@ * testfile45.S.bz2: Add tests for cltq, cqto. * testfile45.expect.bz2: Adjust. -@@ -740,6 +742,11 @@ +@@ -814,6 +816,11 @@ * Makefile.am (TESTS): Add run-elflint-test.sh. (EXTRA_DIST): Add run-elflint-test.sh and testfile18.bz2. @@ -1082,7 +1272,7 @@ endif --- elfutils/tests/Makefile.in +++ elfutils/tests/Makefile.in -@@ -334,6 +334,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ +@@ -343,6 +343,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ @@ -1090,7 +1280,7 @@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ -@@ -363,6 +364,7 @@ SHELL = @SHELL@ +@@ -372,6 +373,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ @@ -1098,10 +1288,10 @@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ -@@ -417,10 +419,10 @@ sysconfdir = @sysconfdir@ - target_alias = @target_alias@ +@@ -429,10 +431,10 @@ top_build_prefix = @top_build_prefix@ 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) diff --git a/elfutils-robustify.patch b/elfutils-robustify.patch index 7bc2a35..c238f52 100644 --- a/elfutils-robustify.patch +++ b/elfutils-robustify.patch @@ -1,973 +1,259 @@ -src/ -2005-06-09 Roland McGrath - - * readelf.c (handle_dynamic, handle_symtab): Check for bogus sh_link. - (handle_verneed, handle_verdef, handle_versym, handle_hash): Likewise. - (handle_scngrp): Check for bogus sh_info. - - * strip.c (handle_elf): Check for bogus values in sh_link, sh_info, - st_shndx, e_shstrndx, and SHT_GROUP or SHT_SYMTAB_SHNDX data. - Don't use assert on input values, instead bail with "illformed" error. - -2005-05-17 Jakub Jelinek - -libelf/ - * 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. - -src/ - * elflint.c (check_hash): Don't check entries beyond end of section. - (check_note): Don't crash if gelf_rawchunk fails. - (section_name): Return if gelf_getshdr returns NULL. - -2005-05-14 Jakub Jelinek - -libelf/ - * libelfP.h (INVALID_NDX): Define. - * gelf_getdyn.c (gelf_getdyn): Use it. Remove ndx < 0 test if any. - * gelf_getlib.c (gelf_getlib): Likewise. - * gelf_getmove.c (gelf_getmove): Likewise. - * gelf_getrel.c (gelf_getrel): Likewise. - * gelf_getrela.c (gelf_getrela): Likewise. - * gelf_getsym.c (gelf_getsym): Likewise. - * gelf_getsyminfo.c (gelf_getsyminfo): Likewise. - * gelf_getsymshndx.c (gelf_getsymshndx): Likewise. - * gelf_getversym.c (gelf_getversym): Likewise. - * gelf_update_dyn.c (gelf_update_dyn): Likewise. - * gelf_update_lib.c (gelf_update_lib): Likewise. - * gelf_update_move.c (gelf_update_move): Likewise. - * gelf_update_rel.c (gelf_update_rel): Likewise. - * gelf_update_rela.c (gelf_update_rela): Likewise. - * gelf_update_sym.c (gelf_update_sym): Likewise. - * gelf_update_syminfo.c (gelf_update_syminfo): Likewise. - * gelf_update_symshndx.c (gelf_update_symshndx): Likewise. - * gelf_update_versym.c (gelf_update_versym): Likewise. - * elf_newscn.c (elf_newscn): Check for overflow. - * elf32_updatefile.c (__elfw2(LIBELFBITS,updatemmap)): Likewise. - (__elfw2(LIBELFBITS,updatefile)): Likewise. - * elf_begin.c (file_read_elf): Likewise. - * elf32_newphdr.c (elfw2(LIBELFBITS,newphdr)): Likewise. - * elf_getarsym.c (elf_getarsym): Likewise. - * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)): Likewise. -src/ - * elflint.c (section_name): Return "" instead of - crashing on invalid section name. - (check_symtab, is_rel_dyn, check_rela, check_rel, check_dynamic, - check_symtab_shndx, check_hash, check_versym): Robustify. - ---- elfutils-0.132/src/elflint.c.robustify -+++ elfutils-0.132/src/elflint.c -@@ -126,6 +126,9 @@ static uint32_t shstrndx; - /* Array to count references in section groups. */ - static int *scnref; +--- elfutils/libelf/ChangeLog ++++ elfutils/libelf/ChangeLog +@@ -529,6 +529,49 @@ + 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. -+/* Number of sections. */ -+static unsigned int shnum; ++2005-05-17 Jakub Jelinek + - - int - main (int argc, char *argv[]) -@@ -315,10 +318,19 @@ section_name (Ebl *ebl, int idx) - { - GElf_Shdr shdr_mem; - GElf_Shdr *shdr; -+ const char *ret; ++ * 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. + -+ if ((unsigned int) idx > shnum) -+ return ""; - - shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem); -+ if (shdr == NULL) -+ return ""; - -- return elf_strptr (ebl->elf, shstrndx, shdr->sh_name); -+ ret = elf_strptr (ebl->elf, shstrndx, shdr->sh_name); -+ if (ret == NULL) -+ return ""; -+ return ret; - } - - -@@ -340,10 +352,6 @@ static const int valid_e_machine[] = - (sizeof (valid_e_machine) / sizeof (valid_e_machine[0])) - - --/* Number of sections. */ --static unsigned int shnum; -- -- - static void - check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size) - { -@@ -605,7 +613,8 @@ section [%2d] '%s': symbol table cannot - } - } - -- if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT)) -+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT); -+ if (shdr->sh_entsize != sh_entsize) - ERROR (gettext ("\ - section [%2u] '%s': entry size is does not match ElfXX_Sym\n"), - idx, section_name (ebl, idx)); -@@ -643,7 +652,7 @@ section [%2d] '%s': XINDEX for zeroth en - xndxscnidx, section_name (ebl, xndxscnidx)); - } - -- for (size_t cnt = 1; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) -+ for (size_t cnt = 1; cnt < shdr->sh_size / sh_entsize; ++cnt) - { - sym = gelf_getsymshndx (data, xndxdata, cnt, &sym_mem, &xndx); - if (sym == NULL) -@@ -661,7 +670,8 @@ section [%2d] '%s': symbol %zu: invalid - else - { - name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name); -- assert (name != NULL); -+ assert (name != NULL -+ || strshdr->sh_type != SHT_STRTAB); - } - - if (sym->st_shndx == SHN_XINDEX) -@@ -991,9 +1001,11 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e - { - GElf_Shdr rcshdr_mem; - const GElf_Shdr *rcshdr = gelf_getshdr (scn, &rcshdr_mem); -- assert (rcshdr != NULL); - -- if (rcshdr->sh_type == SHT_DYNAMIC) -+ if (rcshdr == NULL) -+ break; ++2005-05-14 Jakub Jelinek + -+ if (rcshdr->sh_type == SHT_DYNAMIC && rcshdr->sh_entsize) - { - /* Found the dynamic section. Look through it. */ - Elf_Data *d = elf_getdata (scn, NULL); -@@ -1003,7 +1015,9 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e - { - GElf_Dyn dyn_mem; - GElf_Dyn *dyn = gelf_getdyn (d, cnt, &dyn_mem); -- assert (dyn != NULL); -+ -+ if (dyn == NULL) -+ break; - - if (dyn->d_tag == DT_RELCOUNT) - { -@@ -1017,7 +1031,9 @@ section [%2d] '%s': DT_RELCOUNT used for - /* Does the number specified number of relative - relocations exceed the total number of - relocations? */ -- if (dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize) -+ if (shdr->sh_entsize != 0 -+ && dyn->d_un.d_val > (shdr->sh_size -+ / shdr->sh_entsize)) - ERROR (gettext ("\ - section [%2d] '%s': DT_RELCOUNT value %d too high for this section\n"), - idx, section_name (ebl, idx), -@@ -1177,7 +1193,8 @@ section [%2d] '%s': no relocations for m - } - } - -- if (shdr->sh_entsize != gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT)) -+ size_t sh_entsize = gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT); -+ if (shdr->sh_entsize != sh_entsize) - 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"), -@@ -1400,7 +1417,8 @@ check_rela (Ebl *ebl, GElf_Ehdr *ehdr, G - Elf_Data *symdata = elf_getdata (symscn, NULL); - enum load_state state = state_undecided; - -- for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) -+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT); -+ for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) - { - GElf_Rela rela_mem; - GElf_Rela *rela = gelf_getrela (data, cnt, &rela_mem); -@@ -1450,7 +1468,8 @@ check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GE - Elf_Data *symdata = elf_getdata (symscn, NULL); - enum load_state state = state_undecided; - -- for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) -+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT); -+ for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) - { - GElf_Rel rel_mem; - GElf_Rel *rel = gelf_getrel (data, cnt, &rel_mem); -@@ -1553,7 +1572,8 @@ section [%2d] '%s': referenced as string - shdr->sh_link, section_name (ebl, shdr->sh_link), - idx, section_name (ebl, idx)); - -- if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT)) -+ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT); -+ if (shdr->sh_entsize != sh_entsize) - ERROR (gettext ("\ - section [%2d] '%s': section entry size does not match ElfXX_Dyn\n"), - idx, section_name (ebl, idx)); -@@ -1563,7 +1583,7 @@ section [%2d] '%s': section entry size d - idx, section_name (ebl, idx)); - - bool non_null_warned = false; -- for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) -+ for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) - { - GElf_Dyn dyn_mem; - GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dyn_mem); -@@ -1844,6 +1864,8 @@ section [%2d] '%s': entry size does not - idx, section_name (ebl, idx)); - - if (symshdr != NULL -+ && shdr->sh_entsize -+ && symshdr->sh_entsize - && (shdr->sh_size / shdr->sh_entsize - < symshdr->sh_size / symshdr->sh_entsize)) - ERROR (gettext ("\ -@@ -1870,6 +1892,12 @@ section [%2d] '%s': extended section ind - } - - Elf_Data *data = elf_getdata (elf_getscn (ebl->elf, idx), NULL); -+ if (data == NULL) -+ { -+ ERROR (gettext ("section [%2d] '%s': cannot get section data\n"), -+ idx, section_name (ebl, idx)); -+ return; -+ } - - if (*((Elf32_Word *) data->d_buf) != 0) - ERROR (gettext ("symbol 0 should have zero extended section index\n")); -@@ -1912,7 +1940,7 @@ section [%2d] '%s': hash table section i - - size_t maxidx = nchain; - -- if (symshdr != NULL) -+ if (symshdr != NULL && symshdr->sh_entsize != 0) - { - size_t symsize = symshdr->sh_size / symshdr->sh_entsize; - -@@ -1923,18 +1951,28 @@ section [%2d] '%s': hash table section i - maxidx = symsize; - } - -+ Elf32_Word *buf = (Elf32_Word *) data->d_buf; -+ Elf32_Word *end = (Elf32_Word *) ((char *) data->d_buf + shdr->sh_size); - size_t cnt; - for (cnt = 2; cnt < 2 + nbucket; ++cnt) -- if (((Elf32_Word *) data->d_buf)[cnt] >= maxidx) -+ { -+ if (buf + cnt >= end) -+ break; -+ else if (buf[cnt] >= maxidx) - ERROR (gettext ("\ - section [%2d] '%s': hash bucket reference %zu out of bounds\n"), - idx, section_name (ebl, idx), cnt - 2); -+ } - - for (; cnt < 2 + nbucket + nchain; ++cnt) -- if (((Elf32_Word *) data->d_buf)[cnt] >= maxidx) -+ { -+ if (buf + cnt >= end) -+ break; -+ else if (buf[cnt] >= maxidx) - ERROR (gettext ("\ - section [%2d] '%s': hash chain reference %zu out of bounds\n"), - idx, section_name (ebl, idx), cnt - 2 - nbucket); -+ } - } - - -@@ -1964,18 +2002,28 @@ section [%2d] '%s': hash table section i - maxidx = symsize; - } - -+ Elf64_Xword *buf = (Elf64_Xword *) data->d_buf; -+ Elf64_Xword *end = (Elf64_Xword *) ((char *) data->d_buf + shdr->sh_size); - size_t cnt; - for (cnt = 2; cnt < 2 + nbucket; ++cnt) -- if (((Elf64_Xword *) data->d_buf)[cnt] >= maxidx) -+ { -+ if (buf + cnt >= end) -+ break; -+ else if (buf[cnt] >= maxidx) - ERROR (gettext ("\ - section [%2d] '%s': hash bucket reference %zu out of bounds\n"), - idx, section_name (ebl, idx), cnt - 2); -+ } - - for (; cnt < 2 + nbucket + nchain; ++cnt) -- if (((Elf64_Xword *) data->d_buf)[cnt] >= maxidx) -+ { -+ if (buf + cnt >= end) -+ break; -+ else if (buf[cnt] >= maxidx) - ERROR (gettext ("\ - section [%2d] '%s': hash chain reference %" PRIu64 " out of bounds\n"), -- idx, section_name (ebl, idx), (uint64_t) (cnt - 2 - nbucket)); -+ idx, section_name (ebl, idx), (uint64_t) cnt - 2 - nbucket); -+ } - } - - -@@ -2000,7 +2048,7 @@ section [%2d] '%s': bitmask size not pow - if (shdr->sh_size < (4 + bitmask_words + nbuckets) * sizeof (Elf32_Word)) - { - ERROR (gettext ("\ --section [%2d] '%s': hash table section is too small (is %ld, expected at least%ld)\n"), -+section [%2d] '%s': hash table section is too small (is %ld, expected at least %ld)\n"), - idx, section_name (ebl, idx), (long int) shdr->sh_size, - (long int) ((4 + bitmask_words + nbuckets) * sizeof (Elf32_Word))); - return; -@@ -2657,8 +2705,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. */ -- if (shdr->sh_size / shdr->sh_entsize -- != symshdr->sh_size / symshdr->sh_entsize) -+ if (shdr->sh_entsize && symshdr->sh_entsize -+ && (shdr->sh_size / shdr->sh_entsize -+ != symshdr->sh_size / symshdr->sh_entsize)) - ERROR (gettext ("\ - section [%2d] '%s' has different number of entries than symbol table [%2d] '%s'\n"), - idx, section_name (ebl, idx), ---- elfutils-0.132/src/readelf.c.robustify -+++ elfutils-0.132/src/readelf.c -@@ -1107,6 +1107,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G - Elf32_Word *grpref = (Elf32_Word *) data->d_buf; - - GElf_Sym sym_mem; -+ GElf_Sym *sym = gelf_getsym (symdata, shdr->sh_info, &sym_mem); -+ - printf ((grpref[0] & GRP_COMDAT) - ? ngettext ("\ - \nCOMDAT section group [%2zu] '%s' with signature '%s' contains %zu entry:\n", -@@ -1119,8 +1121,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), -- elf_strptr (ebl->elf, symshdr->sh_link, -- gelf_getsym (symdata, shdr->sh_info, &sym_mem)->st_name) -+ (sym == NULL ? NULL -+ : elf_strptr (ebl->elf, symshdr->sh_link, sym->st_name)) - ?: gettext (""), - data->d_size / sizeof (Elf32_Word) - 1); - -@@ -1271,7 +1273,8 @@ static void - handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) - { - int class = gelf_getclass (ebl->elf); -- GElf_Shdr glink; -+ GElf_Shdr glink_mem; -+ GElf_Shdr *glink; - Elf_Data *data; - size_t cnt; - size_t shstrndx; -@@ -1286,6 +1289,11 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, - error (EXIT_FAILURE, 0, - gettext ("cannot get section header string table index")); - -+ glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem); -+ if (glink == NULL) -+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), -+ elf_ndxscn (scn)); -+ - printf (ngettext ("\ - \nDynamic segment contains %lu entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", - "\ -@@ -1295,9 +1303,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, - class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, - shdr->sh_offset, - (int) shdr->sh_link, -- elf_strptr (ebl->elf, shstrndx, -- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), -- &glink)->sh_name)); -+ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); - fputs_unlocked (gettext (" Type Value\n"), stdout); - - for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) -@@ -1797,6 +1803,13 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G - error (EXIT_FAILURE, 0, - gettext ("cannot get section header string table index")); - -+ GElf_Shdr glink_mem; -+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), -+ &glink_mem); -+ if (glink == NULL) -+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), -+ elf_ndxscn (scn)); -+ - /* Now we can compute the number of entries in the section. */ - unsigned int nsyms = data->d_size / (class == ELFCLASS32 - ? sizeof (Elf32_Sym) -@@ -1807,15 +1820,12 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G - nsyms), - (unsigned int) elf_ndxscn (scn), - elf_strptr (ebl->elf, shstrndx, shdr->sh_name), nsyms); -- GElf_Shdr glink; - printf (ngettext (" %lu local symbol String table: [%2u] '%s'\n", - " %lu local symbols String table: [%2u] '%s'\n", - shdr->sh_info), - (unsigned long int) shdr->sh_info, - (unsigned int) shdr->sh_link, -- elf_strptr (ebl->elf, shstrndx, -- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), -- &glink)->sh_name)); -+ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); - - fputs_unlocked (class == ELFCLASS32 - ? gettext ("\ -@@ -2051,7 +2061,13 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn, - error (EXIT_FAILURE, 0, - gettext ("cannot get section header string table index")); - -- GElf_Shdr glink; -+ GElf_Shdr glink_mem; -+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), -+ &glink_mem); -+ if (glink == NULL) -+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), -+ elf_ndxscn (scn)); -+ - printf (ngettext ("\ - \nVersion needs section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", - "\ -@@ -2062,9 +2078,7 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn, - class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, - shdr->sh_offset, - (unsigned int) shdr->sh_link, -- elf_strptr (ebl->elf, shstrndx, -- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), -- &glink)->sh_name)); -+ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); - - unsigned int offset = 0; - for (int cnt = shdr->sh_info; --cnt >= 0; ) -@@ -2117,8 +2131,14 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G - error (EXIT_FAILURE, 0, - gettext ("cannot get section header string table index")); - -+ GElf_Shdr glink_mem; -+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), -+ &glink_mem); -+ if (glink == NULL) -+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), -+ elf_ndxscn (scn)); -+ - int class = gelf_getclass (ebl->elf); -- GElf_Shdr glink; - printf (ngettext ("\ - \nVersion definition section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", - "\ -@@ -2130,9 +2150,7 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G - class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, - shdr->sh_offset, - (unsigned int) shdr->sh_link, -- elf_strptr (ebl->elf, shstrndx, -- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), -- &glink)->sh_name)); -+ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); - - unsigned int offset = 0; - for (int cnt = shdr->sh_info; --cnt >= 0; ) -@@ -2394,8 +2412,14 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G - filename = NULL; - } - -+ GElf_Shdr glink_mem; -+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), -+ &glink_mem); -+ if (glink == NULL) -+ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), -+ elf_ndxscn (scn)); -+ - /* Print the header. */ -- GElf_Shdr glink; - printf (ngettext ("\ - \nVersion symbols section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'", - "\ -@@ -2407,9 +2431,7 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G - class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, - shdr->sh_offset, - (unsigned int) shdr->sh_link, -- elf_strptr (ebl->elf, shstrndx, -- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), -- &glink)->sh_name)); -+ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); - - /* 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) -@@ -2461,7 +2483,17 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn, - for (Elf32_Word cnt = 0; cnt < nbucket; ++cnt) - ++counts[lengths[cnt]]; - -- GElf_Shdr glink; -+ GElf_Shdr glink_mem; -+ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, -+ shdr->sh_link), -+ &glink_mem); -+ if (glink == NULL) -+ { -+ error (0, 0, gettext ("invalid sh_link value in section %Zu"), -+ elf_ndxscn (scn)); -+ return; -+ } -+ - 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", - "\ -@@ -2474,9 +2506,7 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn, - shdr->sh_addr, - shdr->sh_offset, - (unsigned int) shdr->sh_link, -- elf_strptr (ebl->elf, shstrndx, -- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), -- &glink)->sh_name)); -+ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); - - if (extrastr != NULL) - fputs (extrastr, stdout); -@@ -3875,6 +3905,16 @@ print_debug_aranges_section (Dwfl_Module - return; - } - -+ GElf_Shdr glink_mem; -+ GElf_Shdr *glink; -+ glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem); -+ if (glink == NULL) -+ { -+ error (0, 0, gettext ("invalid sh_link value in section %Zu"), -+ elf_ndxscn (scn)); -+ return; -+ } -+ - printf (ngettext ("\ - \nDWARF section '%s' at offset %#" PRIx64 " contains %zu entry:\n", - "\ ---- elfutils-0.132/src/strip.c.robustify -+++ elfutils-0.132/src/strip.c -@@ -543,6 +543,11 @@ handle_elf (int fd, Elf *elf, const char - goto fail_close; - } - -+ if (shstrndx >= shnum) -+ goto illformed; -+ -+#define elf_assert(test) do { if (!(test)) goto illformed; } while (0) -+ - /* 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. -@@ -564,7 +569,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). */ -- assert (elf_ndxscn (scn) == cnt); -+ elf_assert (elf_ndxscn (scn) == cnt); - - shdr_info[cnt].scn = scn; - -@@ -577,6 +582,7 @@ handle_elf (int fd, Elf *elf, const char - shdr_info[cnt].shdr.sh_name); - if (shdr_info[cnt].name == NULL) - { -+ illformed: - error (0, 0, gettext ("illformed file '%s'"), fname); - goto fail_close; - } -@@ -586,6 +592,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; -+ if (shdr_info[cnt].old_sh_link >= shnum) -+ goto illformed; - - /* Sections in files other than relocatable object files which - are not loaded can be freely moved by us. In relocatable -@@ -598,7 +606,7 @@ handle_elf (int fd, Elf *elf, const char - appropriate reference. */ - if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX)) - { -- assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0); -+ elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0); - shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt; - } - else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP)) -@@ -615,7 +623,12 @@ handle_elf (int fd, Elf *elf, const char - for (inner = 1; - inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); - ++inner) -+ { -+ if (grpref[inner] < shnum) - shdr_info[grpref[inner]].group_idx = cnt; -+ else -+ goto illformed; -+ } - - if (inner == 1 || (inner == 2 && (grpref[0] & GRP_COMDAT) == 0)) - /* If the section group contains only one element and this -@@ -626,7 +639,7 @@ handle_elf (int fd, Elf *elf, const char - } - else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym)) - { -- assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0); -+ elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0); - shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt; - } - -@@ -634,7 +647,7 @@ handle_elf (int fd, Elf *elf, const char - discarded right away. */ - if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0) - { -- assert (shdr_info[cnt].group_idx != 0); -+ elf_assert (shdr_info[cnt].group_idx != 0); - - if (shdr_info[shdr_info[cnt].group_idx].idx == 0) - { -@@ -709,11 +722,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. */ -- if ((shdr_info[cnt].shdr.sh_type == SHT_REL -+ if (shdr_info[cnt].shdr.sh_type == SHT_REL - || shdr_info[cnt].shdr.sh_type == SHT_RELA) -- && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) -+ { -+ if (shdr_info[cnt].shdr.sh_info >= shnum) -+ goto illformed; -+ else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) - shdr_info[cnt].idx = 1; - } -+ } - - if (shdr_info[cnt].idx == 1) - { -@@ -738,7 +755,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) - { -- assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB); -+ elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB); - - shdr_info[shdr_info[cnt].symtab_idx].data - = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, -@@ -778,6 +795,9 @@ handle_elf (int fd, Elf *elf, const char - else if (scnidx == SHN_XINDEX) - scnidx = xndx; - -+ if (scnidx >= shnum) -+ goto illformed; -+ - if (shdr_info[scnidx].idx == 0) - { - /* Mark this section as used. */ -@@ -809,12 +829,16 @@ handle_elf (int fd, Elf *elf, const char - } - - /* Handle references through sh_info. */ -- if (SH_INFO_LINK_P (&shdr_info[cnt].shdr) -- && shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0) -+ if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) -+ { -+ if (shdr_info[cnt].shdr.sh_info >= shnum) -+ goto illformed; -+ else if ( shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0) - { - shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1; - changes |= shdr_info[cnt].shdr.sh_info < cnt; - } -+ } - - /* Mark the section as investigated. */ - shdr_info[cnt].idx = 2; -@@ -914,7 +938,7 @@ handle_elf (int fd, Elf *elf, const char - error (EXIT_FAILURE, 0, gettext ("while generating output file: %s"), - elf_errmsg (-1)); - -- assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); -+ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); - - /* Add this name to the section header string table. */ - shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0); -@@ -951,7 +975,7 @@ handle_elf (int fd, Elf *elf, const char - error (EXIT_FAILURE, 0, - gettext ("while create section header section: %s"), - elf_errmsg (-1)); -- assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); -+ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); - - shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn); - if (shdr_info[cnt].data == NULL) -@@ -1007,7 +1031,7 @@ handle_elf (int fd, Elf *elf, const char - error (EXIT_FAILURE, 0, - gettext ("while create section header section: %s"), - elf_errmsg (-1)); -- assert (elf_ndxscn (shdr_info[cnt].newscn) == idx); -+ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == idx); - - /* Finalize the string table and fill in the correct indices in the - section headers. */ -@@ -1097,20 +1121,20 @@ handle_elf (int fd, Elf *elf, const char - shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, - NULL); - -- assert ((versiondata->d_size / sizeof (Elf32_Word)) -+ elf_assert ((versiondata->d_size / sizeof (Elf32_Word)) - >= shdr_info[cnt].data->d_size / elsize); - } - - if (shdr_info[cnt].version_idx != 0) - { -- assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM); -+ elf_assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM); - /* This section has associated version - information. We have to modify that - information, too. */ - versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn, - NULL); - -- assert ((versiondata->d_size / sizeof (GElf_Versym)) -+ elf_assert ((versiondata->d_size / sizeof (GElf_Versym)) - >= shdr_info[cnt].data->d_size / elsize); - } - -@@ -1165,7 +1189,7 @@ handle_elf (int fd, Elf *elf, const char - sec = shdr_info[sym->st_shndx].idx; - else - { -- assert (shndxdata != NULL); -+ elf_assert (shndxdata != NULL); - - sec = shdr_info[xshndx].idx; - } -@@ -1186,7 +1210,7 @@ handle_elf (int fd, Elf *elf, const char - nxshndx = sec; - } - -- assert (sec < SHN_LORESERVE || shndxdata != NULL); -+ elf_assert (sec < SHN_LORESERVE || shndxdata != NULL); - - if ((inner != destidx || nshndx != sym->st_shndx - || (shndxdata != NULL && nxshndx != xshndx)) -@@ -1209,7 +1233,7 @@ handle_elf (int fd, Elf *elf, const char - else - /* This is a section symbol for a section which has - been removed. */ -- assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION); -+ elf_assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION); - } - - if (destidx != inner) -@@ -1388,11 +1412,11 @@ handle_elf (int fd, Elf *elf, const char - { - GElf_Sym sym_mem; - GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem); -- assert (sym != NULL); -+ elf_assert (sym != NULL); - - const char *name = elf_strptr (elf, strshndx, - sym->st_name); -- assert (name != NULL); -+ elf_assert (name != NULL); - size_t hidx = elf_hash (name) % nbucket; - - if (bucket[hidx] == 0) -@@ -1411,7 +1435,7 @@ handle_elf (int fd, Elf *elf, const char - else - { - /* Alpha and S390 64-bit use 64-bit SHT_HASH entries. */ -- assert (shdr_info[cnt].shdr.sh_entsize -+ elf_assert (shdr_info[cnt].shdr.sh_entsize - == sizeof (Elf64_Xword)); - - Elf64_Xword *bucket = (Elf64_Xword *) hashd->d_buf; -@@ -1442,11 +1466,11 @@ handle_elf (int fd, Elf *elf, const char - { - GElf_Sym sym_mem; - GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem); -- assert (sym != NULL); -+ elf_assert (sym != NULL); - - const char *name = elf_strptr (elf, strshndx, - sym->st_name); -- assert (name != NULL); -+ elf_assert (name != NULL); - size_t hidx = elf_hash (name) % nbucket; - - if (bucket[hidx] == 0) ---- elfutils-0.132/libelf/gelf_getdyn.c.robustify -+++ elfutils-0.132/libelf/gelf_getdyn.c -@@ -93,7 +93,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; -@@ -114,7 +115,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; ---- elfutils-0.132/libelf/gelf_getrel.c.robustify -+++ elfutils-0.132/libelf/gelf_getrel.c -@@ -71,12 +71,6 @@ gelf_getrel (data, ndx, dst) - if (data_scn == NULL) - return NULL; - -- if (unlikely (ndx < 0)) -- { -- __libelf_seterrno (ELF_E_INVALID_INDEX); -- return NULL; -- } -- - if (unlikely (data_scn->d.d_type != ELF_T_REL)) - { - __libelf_seterrno (ELF_E_INVALID_HANDLE); -@@ -93,7 +87,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - result = NULL; -@@ -113,7 +108,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - result = NULL; ---- elfutils-0.132/libelf/gelf_getversym.c.robustify -+++ elfutils-0.132/libelf/gelf_getversym.c -@@ -92,7 +92,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - result = NULL; ---- elfutils-0.132/libelf/elf_newscn.c.robustify -+++ elfutils-0.132/libelf/elf_newscn.c -@@ -104,10 +104,18 @@ elf_newscn (elf) - else - { - /* We must allocate a new element. */ -- Elf_ScnList *newp; -+ Elf_ScnList *newp = NULL; - - assert (elf->state.elf.scnincr > 0); - -+ if ( -+#if SIZE_MAX <= 4294967295U -+ likely (elf->state.elf.scnincr -+ < SIZE_MAX / 2 / sizeof (Elf_Scn) - sizeof (Elf_ScnList)) -+#else -+ 1 -+#endif -+ ) - newp = (Elf_ScnList *) calloc (sizeof (Elf_ScnList) - + ((elf->state.elf.scnincr *= 2) - * sizeof (Elf_Scn)), 1); ---- elfutils-0.132/libelf/elf32_getshdr.c.robustify -+++ elfutils-0.132/libelf/elf32_getshdr.c -@@ -101,7 +101,8 @@ elfw2(LIBELFBITS,getshdr) (scn) - goto out; - - size_t shnum; -- if (INTUSE (elf_getshnum) (elf, &shnum) != 0) -+ if (INTUSE (elf_getshnum) (elf, &shnum) != 0 -+ || shnum > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Shdr))) - goto out; - size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr)); - -@@ -118,6 +119,16 @@ elfw2(LIBELFBITS,getshdr) (scn) ++ * libelfP.h (INVALID_NDX): Define. ++ * gelf_getdyn.c (gelf_getdyn): Use it. Remove ndx < 0 test if any. ++ * gelf_getlib.c (gelf_getlib): Likewise. ++ * gelf_getmove.c (gelf_getmove): Likewise. ++ * gelf_getrel.c (gelf_getrel): Likewise. ++ * gelf_getrela.c (gelf_getrela): Likewise. ++ * gelf_getsym.c (gelf_getsym): Likewise. ++ * gelf_getsyminfo.c (gelf_getsyminfo): Likewise. ++ * gelf_getsymshndx.c (gelf_getsymshndx): Likewise. ++ * gelf_getversym.c (gelf_getversym): Likewise. ++ * gelf_update_dyn.c (gelf_update_dyn): Likewise. ++ * gelf_update_lib.c (gelf_update_lib): Likewise. ++ * gelf_update_move.c (gelf_update_move): Likewise. ++ * gelf_update_rel.c (gelf_update_rel): Likewise. ++ * gelf_update_rela.c (gelf_update_rela): Likewise. ++ * gelf_update_sym.c (gelf_update_sym): Likewise. ++ * gelf_update_syminfo.c (gelf_update_syminfo): Likewise. ++ * gelf_update_symshndx.c (gelf_update_symshndx): Likewise. ++ * gelf_update_versym.c (gelf_update_versym): Likewise. ++ * elf_newscn.c (elf_newscn): Check for overflow. ++ * elf32_updatefile.c (__elfw2(LIBELFBITS,updatemmap)): Likewise. ++ (__elfw2(LIBELFBITS,updatefile)): Likewise. ++ * elf_begin.c (file_read_elf): Likewise. ++ * elf32_newphdr.c (elfw2(LIBELFBITS,newphdr)): Likewise. ++ * elf_getarsym.c (elf_getarsym): Likewise. ++ * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)): Likewise. + 2005-05-11 Ulrich Drepper + + * elf.h: Update again. +--- elfutils/libelf/elf32_getphdr.c ++++ elfutils/libelf/elf32_getphdr.c +@@ -105,6 +105,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_shoff >= elf->maximum_size) -+ || unlikely (ehdr->e_shoff + size > elf->maximum_size)) ++ if (unlikely (ehdr->e_phoff >= elf->maximum_size) ++ || unlikely (ehdr->e_phoff + size > elf->maximum_size)) + { + /* Something is wrong. */ -+ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); -+ goto free_and_out; ++ __libelf_seterrno (ELF_E_INVALID_PHDR); ++ goto out; + } + - ElfW2(LIBELFBITS,Shdr) *notcvt; + /* All the data is already mapped. Use it. */ + void *file_phdr = ((char *) elf->map_address + + elf->start_offset + ehdr->e_phoff); +--- 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 Red Hat, Inc. ++ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2008 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 1998. - /* All the data is already mapped. If we could use it ---- elfutils-0.132/libelf/gelf_getsymshndx.c.robustify -+++ elfutils-0.132/libelf/gelf_getsymshndx.c -@@ -90,7 +90,9 @@ gelf_getsymshndx (symdata, shndxdata, nd - section index table. */ - if (likely (shndxdata_scn != NULL)) +@@ -81,7 +81,8 @@ load_shdr_wrlock (Elf_Scn *scn) + goto out; + + size_t shnum; +- if (__elf_getshnum_rdlock (elf, &shnum) != 0) ++ if (__elf_getshnum_rdlock (elf, &shnum) != 0 ++ || shnum > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Shdr))) + goto out; + size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr)); + +@@ -98,6 +99,16 @@ load_shdr_wrlock (Elf_Scn *scn) + + if (elf->map_address != 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; -@@ -110,7 +112,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; -@@ -139,7 +142,8 @@ gelf_getsymshndx (symdata, shndxdata, nd ++ /* 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)) ++ { ++ /* Something is wrong. */ ++ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); ++ goto free_and_out; ++ } ++ + ElfW2(LIBELFBITS,Shdr) *notcvt; - /* 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; ---- elfutils-0.132/libelf/gelf_update_versym.c.robustify -+++ elfutils-0.132/libelf/gelf_update_versym.c -@@ -75,7 +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)) + /* All the data is already mapped. If we could use it +--- elfutils/libelf/elf32_newphdr.c ++++ elfutils/libelf/elf32_newphdr.c +@@ -124,6 +124,12 @@ elfw2(LIBELFBITS,newphdr) (elf, count) + else if (elf->state.ELFW(elf,LIBELFBITS).ehdr->e_phnum != count + || elf->state.ELFW(elf,LIBELFBITS).phdr == NULL) { - __libelf_seterrno (ELF_E_INVALID_INDEX); ---- elfutils-0.132/libelf/elf_getshstrndx.c.robustify -+++ elfutils-0.132/libelf/elf_getshstrndx.c ++ if (unlikely (count > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Phdr)))) ++ { ++ result = NULL; ++ goto out; ++ } ++ + /* Allocate a new program header with the appropriate number of + elements. */ + result = (ElfW2(LIBELFBITS,Phdr) *) +--- elfutils/libelf/elf32_updatefile.c ++++ elfutils/libelf/elf32_updatefile.c +@@ -220,6 +220,9 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf + /* Write all the sections. Well, only those which are modified. */ + if (shnum > 0) + { ++ if (unlikely (shnum > SIZE_MAX / sizeof (Elf_Scn *))) ++ return 1; ++ + 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 +@@ -633,6 +636,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf + /* Write all the sections. Well, only those which are modified. */ + if (shnum > 0) + { ++ if (unlikely (shnum > SIZE_MAX / (sizeof (Elf_Scn *) ++ + sizeof (ElfW2(LIBELFBITS,Shdr))))) ++ return 1; ++ + 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]; +--- 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)) + /* Cannot read the first section header. */ + return 0; + +@@ -213,7 +214,8 @@ get_shnum (void *map_address, unsigned c + + if (unlikely (result == 0) && ehdr.e64->e_shoff != 0) + { +- if (ehdr.e64->e_shoff + sizeof (Elf64_Shdr) > maxsize) ++ if (unlikely (ehdr.e64->e_shoff >= maxsize) ++ || unlikely (ehdr.e64->e_shoff + sizeof (Elf64_Shdr) > maxsize)) + /* Cannot read the first section header. */ + return 0; + +@@ -285,6 +287,15 @@ file_read_elf (int fildes, void *map_add + /* Could not determine the number of sections. */ + return NULL; + ++ /* Check for too many sections. */ ++ if (e_ident[EI_CLASS] == ELFCLASS32) ++ { ++ if (scncnt > SIZE_MAX / (sizeof (Elf_Scn) + sizeof (Elf32_Shdr))) ++ return NULL; ++ } ++ 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 @@ 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)) ++ { ++ free_and_out: ++ free (elf); ++ __libelf_seterrno (ELF_E_INVALID_FILE); ++ return NULL; ++ } + 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 @@ file_read_elf (int fildes, void *map_add + { + /* We can use the mmapped memory. */ + elf->state.elf64.ehdr = ehdr; ++ ++ if (unlikely (ehdr->e_shoff >= maxsize) ++ || unlikely (ehdr->e_shoff ++ + scncnt * sizeof (Elf32_Shdr) > maxsize)) ++ 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) + { +--- 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 ++#if SIZE_MAX <= 4294967295U ++ || n >= SIZE_MAX / sizeof (Elf_Arsym) ++#endif + || n * sizeof (uint32_t) > index_size) + { + /* This index table cannot be right since it does not fit into +--- elfutils/libelf/elf_getshstrndx.c ++++ elfutils/libelf/elf_getshstrndx.c @@ -125,10 +125,25 @@ elf_getshstrndx (elf, dst) if (elf->map_address != NULL && elf->state.elf32.ehdr->e_ident[EI_DATA] == MY_ELFDATA @@ -1024,103 +310,52 @@ src/ else { /* We avoid reading in all the section headers. Just read ---- elfutils-0.132/libelf/libelfP.h.robustify -+++ elfutils-0.132/libelf/libelfP.h -@@ -596,4 +596,13 @@ 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 -+ - #endif /* libelfP.h */ ---- elfutils-0.132/libelf/gelf_getmove.c.robustify -+++ elfutils-0.132/libelf/gelf_getmove.c -@@ -83,7 +83,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; ---- elfutils-0.132/libelf/elf32_updatefile.c.robustify -+++ elfutils-0.132/libelf/elf32_updatefile.c -@@ -212,6 +212,9 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf - /* Write all the sections. Well, only those which are modified. */ - if (shnum > 0) - { -+ if (unlikely (shnum > SIZE_MAX / sizeof (Elf_Scn *))) -+ return 1; -+ - 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 -@@ -582,6 +585,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf - /* Write all the sections. Well, only those which are modified. */ - if (shnum > 0) - { -+ if (unlikely (shnum > SIZE_MAX / (sizeof (Elf_Scn *) -+ + sizeof (ElfW2(LIBELFBITS,Shdr))))) -+ return 1; -+ - 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]; ---- elfutils-0.132/libelf/gelf_update_lib.c.robustify -+++ elfutils-0.132/libelf/gelf_update_lib.c -@@ -68,12 +68,6 @@ gelf_update_lib (data, ndx, src) - if (data == NULL) - return 0; - -- if (unlikely (ndx < 0)) -- { -- __libelf_seterrno (ELF_E_INVALID_INDEX); -- return 0; -- } -- - Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data; - if (unlikely (data_scn->d.d_type != ELF_T_LIB)) - { -@@ -87,7 +81,8 @@ 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)) - __libelf_seterrno (ELF_E_INVALID_INDEX); +--- elfutils/libelf/elf_newscn.c ++++ elfutils/libelf/elf_newscn.c +@@ -104,10 +104,18 @@ elf_newscn (elf) else { ---- elfutils-0.132/libelf/elf32_getphdr.c.robustify -+++ elfutils-0.132/libelf/elf32_getphdr.c -@@ -116,6 +116,16 @@ elfw2(LIBELFBITS,getphdr) (elf) + /* We must allocate a new element. */ +- Elf_ScnList *newp; ++ Elf_ScnList *newp = NULL; - if (elf->map_address != NULL) + assert (elf->state.elf.scnincr > 0); + ++ if ( ++#if SIZE_MAX <= 4294967295U ++ likely (elf->state.elf.scnincr ++ < SIZE_MAX / 2 / sizeof (Elf_Scn) - sizeof (Elf_ScnList)) ++#else ++ 1 ++#endif ++ ) + newp = (Elf_ScnList *) calloc (sizeof (Elf_ScnList) + + ((elf->state.elf.scnincr *= 2) + * sizeof (Elf_Scn)), 1); +--- elfutils/libelf/gelf_getdyn.c ++++ elfutils/libelf/gelf_getdyn.c +@@ -93,7 +93,8 @@ 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)) { -+ /* 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)) -+ { -+ /* Something is wrong. */ -+ __libelf_seterrno (ELF_E_INVALID_PHDR); -+ goto out; -+ } -+ - /* All the data is already mapped. Use it. */ - void *file_phdr = ((char *) elf->map_address - + elf->start_offset + ehdr->e_phoff); ---- elfutils-0.132/libelf/gelf_getlib.c.robustify -+++ elfutils-0.132/libelf/gelf_getlib.c + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -114,7 +115,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils/libelf/gelf_getlib.c ++++ elfutils/libelf/gelf_getlib.c @@ -86,7 +86,8 @@ gelf_getlib (data, ndx, dst) /* The data is already in the correct form. Just make sure the index is OK. */ @@ -1131,377 +366,20 @@ src/ __libelf_seterrno (ELF_E_INVALID_INDEX); else { ---- elfutils-0.132/libelf/elf32_newphdr.c.robustify -+++ elfutils-0.132/libelf/elf32_newphdr.c -@@ -124,6 +124,12 @@ elfw2(LIBELFBITS,newphdr) (elf, count) - else if (elf->state.ELFW(elf,LIBELFBITS).ehdr->e_phnum != count - || elf->state.ELFW(elf,LIBELFBITS).phdr == NULL) - { -+ if (unlikely (count > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Phdr)))) -+ { -+ result = NULL; -+ goto out; -+ } -+ - /* Allocate a new program header with the appropriate number of - elements. */ - result = (ElfW2(LIBELFBITS,Phdr) *) ---- elfutils-0.132/libelf/gelf_update_rela.c.robustify -+++ elfutils-0.132/libelf/gelf_update_rela.c -@@ -68,12 +68,6 @@ gelf_update_rela (Elf_Data *dst, int ndx - if (dst == NULL) - return 0; - -- if (unlikely (ndx < 0)) -- { -- __libelf_seterrno (ELF_E_INVALID_INDEX); -- return 0; -- } -- - if (unlikely (data_scn->d.d_type != ELF_T_RELA)) - { - /* The type of the data better should match. */ -@@ -101,7 +95,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; -@@ -117,7 +112,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; ---- elfutils-0.132/libelf/gelf_update_syminfo.c.robustify -+++ elfutils-0.132/libelf/gelf_update_syminfo.c -@@ -72,12 +72,6 @@ gelf_update_syminfo (data, ndx, src) - if (data == NULL) - return 0; - -- if (unlikely (ndx < 0)) -- { -- __libelf_seterrno (ELF_E_INVALID_INDEX); -- return 0; -- } -- - if (unlikely (data_scn->d.d_type != ELF_T_SYMINFO)) - { - /* The type of the data better should match. */ -@@ -93,7 +87,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; ---- elfutils-0.132/libelf/gelf_update_sym.c.robustify -+++ elfutils-0.132/libelf/gelf_update_sym.c -@@ -72,12 +72,6 @@ gelf_update_sym (data, ndx, src) - if (data == NULL) - return 0; - -- if (unlikely (ndx < 0)) -- { -- __libelf_seterrno (ELF_E_INVALID_INDEX); -- return 0; -- } -- - if (unlikely (data_scn->d.d_type != ELF_T_SYM)) - { - /* The type of the data better should match. */ -@@ -102,7 +96,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; -@@ -125,7 +120,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; ---- elfutils-0.132/libelf/gelf_getsyminfo.c.robustify -+++ elfutils-0.132/libelf/gelf_getsyminfo.c -@@ -84,7 +84,8 @@ gelf_getsyminfo (data, ndx, dst) +--- elfutils/libelf/gelf_getmove.c ++++ elfutils/libelf/gelf_getmove.c +@@ -83,7 +83,8 @@ 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_Syminfo) > data->d_size)) -+ if (INVALID_NDX (ndx, GElf_Syminfo) -+ || unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data->d_size)) +- 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)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; ---- elfutils-0.132/libelf/gelf_update_symshndx.c.robustify -+++ elfutils-0.132/libelf/gelf_update_symshndx.c -@@ -77,12 +77,6 @@ gelf_update_symshndx (symdata, shndxdata - if (symdata == NULL) - return 0; - -- if (unlikely (ndx < 0)) -- { -- __libelf_seterrno (ELF_E_INVALID_INDEX); -- return 0; -- } -- - if (unlikely (symdata_scn->d.d_type != ELF_T_SYM)) - { - /* The type of the data better should match. */ -@@ -128,7 +122,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; -@@ -151,7 +146,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; ---- elfutils-0.132/libelf/elf_getarsym.c.robustify -+++ elfutils-0.132/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 -+#if SIZE_MAX <= 4294967295U -+ || n >= SIZE_MAX / sizeof (Elf_Arsym) -+#endif - || n * sizeof (uint32_t) > index_size) - { - /* This index table cannot be right since it does not fit into ---- elfutils-0.132/libelf/gelf_getsym.c.robustify -+++ elfutils-0.132/libelf/gelf_getsym.c -@@ -90,7 +90,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; -@@ -119,7 +120,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; ---- elfutils-0.132/libelf/elf_begin.c.robustify -+++ elfutils-0.132/libelf/elf_begin.c -@@ -155,7 +155,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)) - /* Cannot read the first section header. */ - return 0; - -@@ -203,7 +204,8 @@ get_shnum (void *map_address, unsigned c - - if (unlikely (result == 0) && ehdr.e64->e_shoff != 0) - { -- if (ehdr.e64->e_shoff + sizeof (Elf64_Shdr) > maxsize) -+ if (unlikely (ehdr.e64->e_shoff >= maxsize) -+ || unlikely (ehdr.e64->e_shoff + sizeof (Elf64_Shdr) > maxsize)) - /* Cannot read the first section header. */ - return 0; - -@@ -275,6 +277,15 @@ file_read_elf (int fildes, void *map_add - /* Could not determine the number of sections. */ - return NULL; - -+ /* Check for too many sections. */ -+ if (e_ident[EI_CLASS] == ELFCLASS32) -+ { -+ if (scncnt > SIZE_MAX / (sizeof (Elf_Scn) + sizeof (Elf32_Shdr))) -+ return NULL; -+ } -+ 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)); -@@ -308,13 +319,31 @@ 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)) -+ { -+ free_and_out: -+ free (elf); -+ __libelf_seterrno (ELF_E_INVALID_FILE); -+ return NULL; -+ } - 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) - { -@@ -396,13 +425,26 @@ file_read_elf (int fildes, void *map_add - { - /* We can use the mmapped memory. */ - elf->state.elf64.ehdr = ehdr; -+ -+ if (unlikely (ehdr->e_shoff >= maxsize) -+ || unlikely (ehdr->e_shoff -+ + scncnt * sizeof (Elf32_Shdr) > maxsize)) -+ 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) - { ---- elfutils-0.132/libelf/gelf_update_rel.c.robustify -+++ elfutils-0.132/libelf/gelf_update_rel.c -@@ -68,12 +68,6 @@ gelf_update_rel (Elf_Data *dst, int ndx, - if (dst == NULL) - return 0; - -- if (unlikely (ndx < 0)) -- { -- __libelf_seterrno (ELF_E_INVALID_INDEX); -- return 0; -- } -- - if (unlikely (data_scn->d.d_type != ELF_T_REL)) - { - /* The type of the data better should match. */ -@@ -99,7 +93,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; -@@ -114,7 +109,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; ---- elfutils-0.132/libelf/gelf_update_move.c.robustify -+++ elfutils-0.132/libelf/gelf_update_move.c -@@ -75,7 +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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); ---- elfutils-0.132/libelf/gelf_update_dyn.c.robustify -+++ elfutils-0.132/libelf/gelf_update_dyn.c -@@ -71,12 +71,6 @@ gelf_update_dyn (data, ndx, src) - if (data == NULL) - return 0; - -- if (unlikely (ndx < 0)) -- { -- __libelf_seterrno (ELF_E_INVALID_INDEX); -- return 0; -- } -- - if (unlikely (data_scn->d.d_type != ELF_T_DYN)) - { - /* The type of the data better should match. */ -@@ -102,7 +96,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; -@@ -116,7 +111,8 @@ 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)) - { - __libelf_seterrno (ELF_E_INVALID_INDEX); - goto out; ---- elfutils-0.132/libelf/gelf_getrela.c.robustify -+++ elfutils-0.132/libelf/gelf_getrela.c +--- elfutils/libelf/gelf_getrela.c ++++ elfutils/libelf/gelf_getrela.c @@ -71,12 +71,6 @@ gelf_getrela (data, ndx, dst) if (data_scn == NULL) return NULL; @@ -1535,3 +413,1156 @@ src/ { __libelf_seterrno (ELF_E_INVALID_INDEX); result = NULL; +--- elfutils/libelf/gelf_getrel.c ++++ elfutils/libelf/gelf_getrel.c +@@ -71,12 +71,6 @@ gelf_getrel (data, ndx, dst) + if (data_scn == NULL) + return NULL; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return NULL; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_REL)) + { + __libelf_seterrno (ELF_E_INVALID_HANDLE); +@@ -93,7 +87,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + result = NULL; +@@ -113,7 +108,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + result = NULL; +--- elfutils/libelf/gelf_getsym.c ++++ elfutils/libelf/gelf_getsym.c +@@ -90,7 +90,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -119,7 +120,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils/libelf/gelf_getsyminfo.c ++++ elfutils/libelf/gelf_getsyminfo.c +@@ -84,7 +84,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils/libelf/gelf_getsymshndx.c ++++ elfutils/libelf/gelf_getsymshndx.c +@@ -90,7 +90,9 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -110,7 +112,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -139,7 +142,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils/libelf/gelf_getversym.c ++++ elfutils/libelf/gelf_getversym.c +@@ -92,7 +92,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + result = NULL; +--- elfutils/libelf/gelf_update_dyn.c ++++ elfutils/libelf/gelf_update_dyn.c +@@ -71,12 +71,6 @@ gelf_update_dyn (data, ndx, src) + if (data == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_DYN)) + { + /* The type of the data better should match. */ +@@ -102,7 +96,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -116,7 +111,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils/libelf/gelf_update_lib.c ++++ elfutils/libelf/gelf_update_lib.c +@@ -68,12 +68,6 @@ gelf_update_lib (data, ndx, src) + if (data == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data; + if (unlikely (data_scn->d.d_type != ELF_T_LIB)) + { +@@ -87,7 +81,8 @@ 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)) + __libelf_seterrno (ELF_E_INVALID_INDEX); + else + { +--- elfutils/libelf/gelf_update_move.c ++++ elfutils/libelf/gelf_update_move.c +@@ -75,7 +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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); +--- elfutils/libelf/gelf_update_rela.c ++++ elfutils/libelf/gelf_update_rela.c +@@ -68,12 +68,6 @@ gelf_update_rela (Elf_Data *dst, int ndx + if (dst == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_RELA)) + { + /* The type of the data better should match. */ +@@ -101,7 +95,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -117,7 +112,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils/libelf/gelf_update_rel.c ++++ elfutils/libelf/gelf_update_rel.c +@@ -68,12 +68,6 @@ gelf_update_rel (Elf_Data *dst, int ndx, + if (dst == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_REL)) + { + /* The type of the data better should match. */ +@@ -99,7 +93,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -114,7 +109,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils/libelf/gelf_update_sym.c ++++ elfutils/libelf/gelf_update_sym.c +@@ -72,12 +72,6 @@ gelf_update_sym (data, ndx, src) + if (data == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_SYM)) + { + /* The type of the data better should match. */ +@@ -102,7 +96,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -125,7 +120,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils/libelf/gelf_update_syminfo.c ++++ elfutils/libelf/gelf_update_syminfo.c +@@ -72,12 +72,6 @@ gelf_update_syminfo (data, ndx, src) + if (data == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_SYMINFO)) + { + /* The type of the data better should match. */ +@@ -93,7 +87,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils/libelf/gelf_update_symshndx.c ++++ elfutils/libelf/gelf_update_symshndx.c +@@ -77,12 +77,6 @@ gelf_update_symshndx (symdata, shndxdata + if (symdata == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (symdata_scn->d.d_type != ELF_T_SYM)) + { + /* The type of the data better should match. */ +@@ -128,7 +122,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -151,7 +146,8 @@ 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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils/libelf/gelf_update_versym.c ++++ elfutils/libelf/gelf_update_versym.c +@@ -75,7 +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)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); +--- elfutils/libelf/libelfP.h ++++ elfutils/libelf/libelfP.h +@@ -611,4 +611,13 @@ 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 ++ + #endif /* libelfP.h */ +--- elfutils/src/ChangeLog ++++ elfutils/src/ChangeLog +@@ -1376,6 +1376,16 @@ + object symbols or symbols with unknown type. + (check_rel): Likewise. + ++2005-06-09 Roland McGrath ++ ++ * readelf.c (handle_dynamic, handle_symtab): Check for bogus sh_link. ++ (handle_verneed, handle_verdef, handle_versym, handle_hash): Likewise. ++ (handle_scngrp): Check for bogus sh_info. ++ ++ * strip.c (handle_elf): Check for bogus values in sh_link, sh_info, ++ st_shndx, e_shstrndx, and SHT_GROUP or SHT_SYMTAB_SHNDX data. ++ Don't use assert on input values, instead bail with "illformed" error. ++ + 2005-06-08 Roland McGrath + + * readelf.c (print_ops): Add consts. +@@ -1421,6 +1431,19 @@ + + * readelf.c (dwarf_tag_string): Add new tags. + ++2005-05-17 Jakub Jelinek ++ ++ * elflint.c (check_hash): Don't check entries beyond end of section. ++ (check_note): Don't crash if gelf_rawchunk fails. ++ (section_name): Return if gelf_getshdr returns NULL. ++ ++2005-05-14 Jakub Jelinek ++ ++ * elflint.c (section_name): Return "" instead of ++ crashing on invalid section name. ++ (check_symtab, is_rel_dyn, check_rela, check_rel, check_dynamic, ++ check_symtab_shndx, check_hash, check_versym): Robustify. ++ + 2005-05-08 Roland McGrath + + * strip.c (handle_elf): Don't translate hash and versym data formats, +--- elfutils/src/elflint.c ++++ elfutils/src/elflint.c +@@ -130,6 +130,9 @@ static uint32_t shstrndx; + /* Array to count references in section groups. */ + static int *scnref; + ++/* Number of sections. */ ++static unsigned int shnum; ++ + + int + main (int argc, char *argv[]) +@@ -318,10 +321,19 @@ section_name (Ebl *ebl, int idx) + { + GElf_Shdr shdr_mem; + GElf_Shdr *shdr; ++ const char *ret; ++ ++ if ((unsigned int) idx > shnum) ++ return ""; + + shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem); ++ if (shdr == NULL) ++ return ""; + +- return elf_strptr (ebl->elf, shstrndx, shdr->sh_name); ++ ret = elf_strptr (ebl->elf, shstrndx, shdr->sh_name); ++ if (ret == NULL) ++ return ""; ++ return ret; + } + + +@@ -343,10 +355,6 @@ static const int valid_e_machine[] = + (sizeof (valid_e_machine) / sizeof (valid_e_machine[0])) + + +-/* Number of sections. */ +-static unsigned int shnum; +- +- + static void + check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size) + { +@@ -611,7 +619,8 @@ section [%2d] '%s': symbol table cannot + } + } + +- if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT)) ++ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT); ++ if (shdr->sh_entsize != sh_entsize) + ERROR (gettext ("\ + section [%2u] '%s': entry size is does not match ElfXX_Sym\n"), + idx, section_name (ebl, idx)); +@@ -649,7 +658,7 @@ section [%2d] '%s': XINDEX for zeroth en + xndxscnidx, section_name (ebl, xndxscnidx)); + } + +- for (size_t cnt = 1; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) ++ for (size_t cnt = 1; cnt < shdr->sh_size / sh_entsize; ++cnt) + { + sym = gelf_getsymshndx (data, xndxdata, cnt, &sym_mem, &xndx); + if (sym == NULL) +@@ -669,7 +678,8 @@ section [%2d] '%s': symbol %zu: invalid + else + { + name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name); +- assert (name != NULL); ++ assert (name != NULL ++ || strshdr->sh_type != SHT_STRTAB); + } + + if (sym->st_shndx == SHN_XINDEX) +@@ -999,9 +1009,11 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e + { + GElf_Shdr rcshdr_mem; + const GElf_Shdr *rcshdr = gelf_getshdr (scn, &rcshdr_mem); +- assert (rcshdr != NULL); + +- if (rcshdr->sh_type == SHT_DYNAMIC) ++ if (rcshdr == NULL) ++ break; ++ ++ if (rcshdr->sh_type == SHT_DYNAMIC && rcshdr->sh_entsize) + { + /* Found the dynamic section. Look through it. */ + Elf_Data *d = elf_getdata (scn, NULL); +@@ -1011,7 +1023,9 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e + { + GElf_Dyn dyn_mem; + GElf_Dyn *dyn = gelf_getdyn (d, cnt, &dyn_mem); +- assert (dyn != NULL); ++ ++ if (dyn == NULL) ++ break; + + if (dyn->d_tag == DT_RELCOUNT) + { +@@ -1025,7 +1039,9 @@ section [%2d] '%s': DT_RELCOUNT used for + /* Does the number specified number of relative + relocations exceed the total number of + relocations? */ +- if (dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize) ++ if (shdr->sh_entsize != 0 ++ && dyn->d_un.d_val > (shdr->sh_size ++ / shdr->sh_entsize)) + ERROR (gettext ("\ + section [%2d] '%s': DT_RELCOUNT value %d too high for this section\n"), + idx, section_name (ebl, idx), +@@ -1185,7 +1201,8 @@ section [%2d] '%s': no relocations for m + } + } + +- if (shdr->sh_entsize != gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT)) ++ size_t sh_entsize = gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT); ++ if (shdr->sh_entsize != sh_entsize) + 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"), +@@ -1408,7 +1425,8 @@ check_rela (Ebl *ebl, GElf_Ehdr *ehdr, G + Elf_Data *symdata = elf_getdata (symscn, NULL); + enum load_state state = state_undecided; + +- for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) ++ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT); ++ for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) + { + GElf_Rela rela_mem; + GElf_Rela *rela = gelf_getrela (data, cnt, &rela_mem); +@@ -1458,7 +1476,8 @@ check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GE + Elf_Data *symdata = elf_getdata (symscn, NULL); + enum load_state state = state_undecided; + +- for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) ++ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT); ++ for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) + { + GElf_Rel rel_mem; + GElf_Rel *rel = gelf_getrel (data, cnt, &rel_mem); +@@ -1561,7 +1580,8 @@ section [%2d] '%s': referenced as string + shdr->sh_link, section_name (ebl, shdr->sh_link), + idx, section_name (ebl, idx)); + +- if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT)) ++ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT); ++ if (shdr->sh_entsize != sh_entsize) + ERROR (gettext ("\ + section [%2d] '%s': section entry size does not match ElfXX_Dyn\n"), + idx, section_name (ebl, idx)); +@@ -1571,7 +1591,7 @@ section [%2d] '%s': section entry size d + idx, section_name (ebl, idx)); + + bool non_null_warned = false; +- for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) ++ for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) + { + GElf_Dyn dyn_mem; + GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dyn_mem); +@@ -1852,6 +1872,8 @@ section [%2d] '%s': entry size does not + idx, section_name (ebl, idx)); + + if (symshdr != NULL ++ && shdr->sh_entsize ++ && symshdr->sh_entsize + && (shdr->sh_size / shdr->sh_entsize + < symshdr->sh_size / symshdr->sh_entsize)) + ERROR (gettext ("\ +@@ -1878,6 +1900,12 @@ section [%2d] '%s': extended section ind + } + + Elf_Data *data = elf_getdata (elf_getscn (ebl->elf, idx), NULL); ++ if (data == NULL) ++ { ++ ERROR (gettext ("section [%2d] '%s': cannot get section data\n"), ++ idx, section_name (ebl, idx)); ++ return; ++ } + + if (*((Elf32_Word *) data->d_buf) != 0) + ERROR (gettext ("symbol 0 should have zero extended section index\n")); +@@ -1920,7 +1948,7 @@ section [%2d] '%s': hash table section i + + size_t maxidx = nchain; + +- if (symshdr != NULL) ++ if (symshdr != NULL && symshdr->sh_entsize != 0) + { + size_t symsize = symshdr->sh_size / symshdr->sh_entsize; + +@@ -1931,18 +1959,28 @@ section [%2d] '%s': hash table section i + maxidx = symsize; + } + ++ Elf32_Word *buf = (Elf32_Word *) data->d_buf; ++ Elf32_Word *end = (Elf32_Word *) ((char *) data->d_buf + shdr->sh_size); + size_t cnt; + for (cnt = 2; cnt < 2 + nbucket; ++cnt) +- if (((Elf32_Word *) data->d_buf)[cnt] >= maxidx) ++ { ++ if (buf + cnt >= end) ++ break; ++ else if (buf[cnt] >= maxidx) + ERROR (gettext ("\ + section [%2d] '%s': hash bucket reference %zu out of bounds\n"), + idx, section_name (ebl, idx), cnt - 2); ++ } + + for (; cnt < 2 + nbucket + nchain; ++cnt) +- if (((Elf32_Word *) data->d_buf)[cnt] >= maxidx) ++ { ++ if (buf + cnt >= end) ++ break; ++ else if (buf[cnt] >= maxidx) + ERROR (gettext ("\ + section [%2d] '%s': hash chain reference %zu out of bounds\n"), + idx, section_name (ebl, idx), cnt - 2 - nbucket); ++ } + } + + +@@ -1972,18 +2010,28 @@ section [%2d] '%s': hash table section i + maxidx = symsize; + } + ++ Elf64_Xword *buf = (Elf64_Xword *) data->d_buf; ++ Elf64_Xword *end = (Elf64_Xword *) ((char *) data->d_buf + shdr->sh_size); + size_t cnt; + for (cnt = 2; cnt < 2 + nbucket; ++cnt) +- if (((Elf64_Xword *) data->d_buf)[cnt] >= maxidx) ++ { ++ if (buf + cnt >= end) ++ break; ++ else if (buf[cnt] >= maxidx) + ERROR (gettext ("\ + section [%2d] '%s': hash bucket reference %zu out of bounds\n"), + idx, section_name (ebl, idx), cnt - 2); ++ } + + for (; cnt < 2 + nbucket + nchain; ++cnt) +- if (((Elf64_Xword *) data->d_buf)[cnt] >= maxidx) ++ { ++ if (buf + cnt >= end) ++ break; ++ else if (buf[cnt] >= maxidx) + ERROR (gettext ("\ + section [%2d] '%s': hash chain reference %" PRIu64 " out of bounds\n"), +- idx, section_name (ebl, idx), (uint64_t) (cnt - 2 - nbucket)); ++ idx, section_name (ebl, idx), (uint64_t) cnt - 2 - nbucket); ++ } + } + + +@@ -2008,7 +2056,7 @@ section [%2d] '%s': bitmask size not pow + if (shdr->sh_size < (4 + bitmask_words + nbuckets) * sizeof (Elf32_Word)) + { + ERROR (gettext ("\ +-section [%2d] '%s': hash table section is too small (is %ld, expected at least%ld)\n"), ++section [%2d] '%s': hash table section is too small (is %ld, expected at least %ld)\n"), + idx, section_name (ebl, idx), (long int) shdr->sh_size, + (long int) ((4 + bitmask_words + nbuckets) * sizeof (Elf32_Word))); + return; +@@ -2680,8 +2728,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. */ +- if (shdr->sh_size / shdr->sh_entsize +- != symshdr->sh_size / symshdr->sh_entsize) ++ if (shdr->sh_entsize && symshdr->sh_entsize ++ && (shdr->sh_size / shdr->sh_entsize ++ != symshdr->sh_size / symshdr->sh_entsize)) + ERROR (gettext ("\ + section [%2d] '%s' has different number of entries than symbol table [%2d] '%s'\n"), + idx, section_name (ebl, idx), +--- elfutils/src/readelf.c ++++ elfutils/src/readelf.c +@@ -1136,6 +1136,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G + Elf32_Word *grpref = (Elf32_Word *) data->d_buf; + + GElf_Sym sym_mem; ++ GElf_Sym *sym = gelf_getsym (symdata, shdr->sh_info, &sym_mem); ++ + printf ((grpref[0] & GRP_COMDAT) + ? ngettext ("\ + \nCOMDAT section group [%2zu] '%s' with signature '%s' contains %zu entry:\n", +@@ -1148,8 +1150,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), +- elf_strptr (ebl->elf, symshdr->sh_link, +- gelf_getsym (symdata, shdr->sh_info, &sym_mem)->st_name) ++ (sym == NULL ? NULL ++ : elf_strptr (ebl->elf, symshdr->sh_link, sym->st_name)) + ?: gettext (""), + data->d_size / sizeof (Elf32_Word) - 1); + +@@ -1300,7 +1302,8 @@ static void + handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) + { + int class = gelf_getclass (ebl->elf); +- GElf_Shdr glink; ++ GElf_Shdr glink_mem; ++ GElf_Shdr *glink; + Elf_Data *data; + size_t cnt; + size_t shstrndx; +@@ -1315,6 +1318,11 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, + error (EXIT_FAILURE, 0, + gettext ("cannot get section header string table index")); + ++ glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem); ++ if (glink == NULL) ++ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), ++ elf_ndxscn (scn)); ++ + printf (ngettext ("\ + \nDynamic segment contains %lu entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", + "\ +@@ -1324,9 +1332,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, + class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, + shdr->sh_offset, + (int) shdr->sh_link, +- elf_strptr (ebl->elf, shstrndx, +- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), +- &glink)->sh_name)); ++ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); + fputs_unlocked (gettext (" Type Value\n"), stdout); + + for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) +@@ -1826,6 +1832,13 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G + error (EXIT_FAILURE, 0, + gettext ("cannot get section header string table index")); + ++ GElf_Shdr glink_mem; ++ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), ++ &glink_mem); ++ if (glink == NULL) ++ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), ++ elf_ndxscn (scn)); ++ + /* Now we can compute the number of entries in the section. */ + unsigned int nsyms = data->d_size / (class == ELFCLASS32 + ? sizeof (Elf32_Sym) +@@ -1836,15 +1849,12 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G + nsyms), + (unsigned int) elf_ndxscn (scn), + elf_strptr (ebl->elf, shstrndx, shdr->sh_name), nsyms); +- GElf_Shdr glink; + printf (ngettext (" %lu local symbol String table: [%2u] '%s'\n", + " %lu local symbols String table: [%2u] '%s'\n", + shdr->sh_info), + (unsigned long int) shdr->sh_info, + (unsigned int) shdr->sh_link, +- elf_strptr (ebl->elf, shstrndx, +- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), +- &glink)->sh_name)); ++ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); + + fputs_unlocked (class == ELFCLASS32 + ? gettext ("\ +@@ -2080,7 +2090,13 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn, + error (EXIT_FAILURE, 0, + gettext ("cannot get section header string table index")); + +- GElf_Shdr glink; ++ GElf_Shdr glink_mem; ++ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), ++ &glink_mem); ++ if (glink == NULL) ++ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), ++ elf_ndxscn (scn)); ++ + printf (ngettext ("\ + \nVersion needs section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", + "\ +@@ -2091,9 +2107,7 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn, + class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, + shdr->sh_offset, + (unsigned int) shdr->sh_link, +- elf_strptr (ebl->elf, shstrndx, +- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), +- &glink)->sh_name)); ++ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); + + unsigned int offset = 0; + for (int cnt = shdr->sh_info; --cnt >= 0; ) +@@ -2146,8 +2160,14 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G + error (EXIT_FAILURE, 0, + gettext ("cannot get section header string table index")); + ++ GElf_Shdr glink_mem; ++ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), ++ &glink_mem); ++ if (glink == NULL) ++ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), ++ elf_ndxscn (scn)); ++ + int class = gelf_getclass (ebl->elf); +- GElf_Shdr glink; + printf (ngettext ("\ + \nVersion definition section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", + "\ +@@ -2159,9 +2179,7 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G + class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, + shdr->sh_offset, + (unsigned int) shdr->sh_link, +- elf_strptr (ebl->elf, shstrndx, +- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), +- &glink)->sh_name)); ++ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); + + unsigned int offset = 0; + for (int cnt = shdr->sh_info; --cnt >= 0; ) +@@ -2423,8 +2441,14 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G + filename = NULL; + } + ++ GElf_Shdr glink_mem; ++ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), ++ &glink_mem); ++ if (glink == NULL) ++ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), ++ elf_ndxscn (scn)); ++ + /* Print the header. */ +- GElf_Shdr glink; + printf (ngettext ("\ + \nVersion symbols section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'", + "\ +@@ -2436,9 +2460,7 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G + class == ELFCLASS32 ? 10 : 18, shdr->sh_addr, + shdr->sh_offset, + (unsigned int) shdr->sh_link, +- elf_strptr (ebl->elf, shstrndx, +- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), +- &glink)->sh_name)); ++ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); + + /* 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) +@@ -2490,7 +2512,17 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn, + for (Elf32_Word cnt = 0; cnt < nbucket; ++cnt) + ++counts[lengths[cnt]]; + +- GElf_Shdr glink; ++ GElf_Shdr glink_mem; ++ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, ++ shdr->sh_link), ++ &glink_mem); ++ if (glink == NULL) ++ { ++ error (0, 0, gettext ("invalid sh_link value in section %Zu"), ++ elf_ndxscn (scn)); ++ return; ++ } ++ + 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", + "\ +@@ -2503,9 +2535,7 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn, + shdr->sh_addr, + shdr->sh_offset, + (unsigned int) shdr->sh_link, +- elf_strptr (ebl->elf, shstrndx, +- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), +- &glink)->sh_name)); ++ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); + + if (extrastr != NULL) + fputs (extrastr, stdout); +@@ -4107,6 +4137,16 @@ print_debug_aranges_section (Dwfl_Module + return; + } + ++ GElf_Shdr glink_mem; ++ GElf_Shdr *glink; ++ glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem); ++ if (glink == NULL) ++ { ++ error (0, 0, gettext ("invalid sh_link value in section %Zu"), ++ elf_ndxscn (scn)); ++ return; ++ } ++ + printf (ngettext ("\ + \nDWARF section [%2zu] '%s' at offset %#" PRIx64 " contains %zu entry:\n", + "\ +--- elfutils/src/strip.c ++++ elfutils/src/strip.c +@@ -544,6 +544,11 @@ handle_elf (int fd, Elf *elf, const char + goto fail_close; + } + ++ if (shstrndx >= shnum) ++ goto illformed; ++ ++#define elf_assert(test) do { if (!(test)) goto illformed; } while (0) ++ + /* 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. +@@ -565,7 +570,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). */ +- assert (elf_ndxscn (scn) == cnt); ++ elf_assert (elf_ndxscn (scn) == cnt); + + shdr_info[cnt].scn = scn; + +@@ -578,6 +583,7 @@ handle_elf (int fd, Elf *elf, const char + shdr_info[cnt].shdr.sh_name); + if (shdr_info[cnt].name == NULL) + { ++ illformed: + error (0, 0, gettext ("illformed file '%s'"), fname); + goto fail_close; + } +@@ -587,6 +593,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; ++ if (shdr_info[cnt].old_sh_link >= shnum) ++ goto illformed; + + /* Sections in files other than relocatable object files which + are not loaded can be freely moved by us. In relocatable +@@ -599,7 +607,7 @@ handle_elf (int fd, Elf *elf, const char + appropriate reference. */ + if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX)) + { +- assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0); ++ elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0); + shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt; + } + else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP)) +@@ -616,7 +624,12 @@ handle_elf (int fd, Elf *elf, const char + for (inner = 1; + inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); + ++inner) ++ { ++ if (grpref[inner] < shnum) + shdr_info[grpref[inner]].group_idx = cnt; ++ else ++ goto illformed; ++ } + + if (inner == 1 || (inner == 2 && (grpref[0] & GRP_COMDAT) == 0)) + /* If the section group contains only one element and this +@@ -627,7 +640,7 @@ handle_elf (int fd, Elf *elf, const char + } + else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym)) + { +- assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0); ++ elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0); + shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt; + } + +@@ -635,7 +648,7 @@ handle_elf (int fd, Elf *elf, const char + discarded right away. */ + if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0) + { +- assert (shdr_info[cnt].group_idx != 0); ++ elf_assert (shdr_info[cnt].group_idx != 0); + + if (shdr_info[shdr_info[cnt].group_idx].idx == 0) + { +@@ -710,11 +723,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. */ +- if ((shdr_info[cnt].shdr.sh_type == SHT_REL ++ if (shdr_info[cnt].shdr.sh_type == SHT_REL + || shdr_info[cnt].shdr.sh_type == SHT_RELA) +- && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) ++ { ++ if (shdr_info[cnt].shdr.sh_info >= shnum) ++ goto illformed; ++ else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) + shdr_info[cnt].idx = 1; + } ++ } + + if (shdr_info[cnt].idx == 1) + { +@@ -741,7 +758,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) + { +- assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB); ++ elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB); + + shdr_info[shdr_info[cnt].symtab_idx].data + = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, +@@ -781,6 +798,9 @@ handle_elf (int fd, Elf *elf, const char + else if (scnidx == SHN_XINDEX) + scnidx = xndx; + ++ if (scnidx >= shnum) ++ goto illformed; ++ + if (shdr_info[scnidx].idx == 0) + /* This symbol table has a real symbol in + a discarded section. So preserve the +@@ -811,12 +831,16 @@ handle_elf (int fd, Elf *elf, const char + } + + /* Handle references through sh_info. */ +- if (SH_INFO_LINK_P (&shdr_info[cnt].shdr) +- && shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0) ++ if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) ++ { ++ if (shdr_info[cnt].shdr.sh_info >= shnum) ++ goto illformed; ++ else if ( shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0) + { + shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1; + changes |= shdr_info[cnt].shdr.sh_info < cnt; + } ++ } + + /* Mark the section as investigated. */ + shdr_info[cnt].idx = 2; +@@ -955,7 +979,7 @@ handle_elf (int fd, Elf *elf, const char + error (EXIT_FAILURE, 0, gettext ("while generating output file: %s"), + elf_errmsg (-1)); + +- assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); ++ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); + + /* Add this name to the section header string table. */ + shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0); +@@ -992,7 +1016,7 @@ handle_elf (int fd, Elf *elf, const char + error (EXIT_FAILURE, 0, + gettext ("while create section header section: %s"), + elf_errmsg (-1)); +- assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); ++ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); + + shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn); + if (shdr_info[cnt].data == NULL) +@@ -1048,7 +1072,7 @@ handle_elf (int fd, Elf *elf, const char + error (EXIT_FAILURE, 0, + gettext ("while create section header section: %s"), + elf_errmsg (-1)); +- assert (elf_ndxscn (shdr_info[cnt].newscn) == idx); ++ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == idx); + + /* Finalize the string table and fill in the correct indices in the + section headers. */ +@@ -1138,20 +1162,20 @@ handle_elf (int fd, Elf *elf, const char + shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, + NULL); + +- assert ((versiondata->d_size / sizeof (Elf32_Word)) ++ elf_assert ((versiondata->d_size / sizeof (Elf32_Word)) + >= shdr_info[cnt].data->d_size / elsize); + } + + if (shdr_info[cnt].version_idx != 0) + { +- assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM); ++ elf_assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM); + /* This section has associated version + information. We have to modify that + information, too. */ + versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn, + NULL); + +- assert ((versiondata->d_size / sizeof (GElf_Versym)) ++ elf_assert ((versiondata->d_size / sizeof (GElf_Versym)) + >= shdr_info[cnt].data->d_size / elsize); + } + +@@ -1206,7 +1230,7 @@ handle_elf (int fd, Elf *elf, const char + sec = shdr_info[sym->st_shndx].idx; + else + { +- assert (shndxdata != NULL); ++ elf_assert (shndxdata != NULL); + + sec = shdr_info[xshndx].idx; + } +@@ -1227,7 +1251,7 @@ handle_elf (int fd, Elf *elf, const char + nxshndx = sec; + } + +- assert (sec < SHN_LORESERVE || shndxdata != NULL); ++ elf_assert (sec < SHN_LORESERVE || shndxdata != NULL); + + if ((inner != destidx || nshndx != sym->st_shndx + || (shndxdata != NULL && nxshndx != xshndx)) +@@ -1251,7 +1275,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. */ +- assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION); ++ elf_assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION); + } + + if (destidx != inner) +@@ -1438,11 +1462,11 @@ handle_elf (int fd, Elf *elf, const char + { + GElf_Sym sym_mem; + GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem); +- assert (sym != NULL); ++ elf_assert (sym != NULL); + + const char *name = elf_strptr (elf, strshndx, + sym->st_name); +- assert (name != NULL); ++ elf_assert (name != NULL); + size_t hidx = elf_hash (name) % nbucket; + + if (bucket[hidx] == 0) +@@ -1461,7 +1485,7 @@ handle_elf (int fd, Elf *elf, const char + else + { + /* Alpha and S390 64-bit use 64-bit SHT_HASH entries. */ +- assert (shdr_info[cnt].shdr.sh_entsize ++ elf_assert (shdr_info[cnt].shdr.sh_entsize + == sizeof (Elf64_Xword)); + + Elf64_Xword *bucket = (Elf64_Xword *) hashd->d_buf; +@@ -1492,11 +1516,11 @@ handle_elf (int fd, Elf *elf, const char + { + GElf_Sym sym_mem; + GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem); +- assert (sym != NULL); ++ elf_assert (sym != NULL); + + const char *name = elf_strptr (elf, strshndx, + sym->st_name); +- assert (name != NULL); ++ elf_assert (name != NULL); + size_t hidx = elf_hash (name) % nbucket; + + if (bucket[hidx] == 0) diff --git a/elfutils-strip-copy-symtab.patch b/elfutils-strip-copy-symtab.patch deleted file mode 100644 index 35cc6b8..0000000 --- a/elfutils-strip-copy-symtab.patch +++ /dev/null @@ -1,199 +0,0 @@ -2006-09-19 Jakub Jelinek - - * strip.c (handle_elf): Formatting. If any relocation sections - stripped into separate debug info reference symtab that is kept, - emit symtab/strtab also into the separate debug info file. - ---- elfutils/src/strip.c -+++ elfutils/src/strip.c -@@ -399,6 +399,7 @@ handle_elf (int fd, Elf *elf, const char - Elf_Scn *newscn; - struct Ebl_Strent *se; - Elf32_Word *newsymidx; -+ void *debug_data; - } *shdr_info = NULL; - Elf_Scn *scn; - size_t cnt; -@@ -826,6 +827,37 @@ handle_elf (int fd, Elf *elf, const char - The ones that are not removed in the stripped file are SHT_NOBITS. */ - if (debug_fname != NULL) - { -+ /* libbfd and apps using it don't cope with separate debuginfo objects -+ with relocation sections against SHT_NOBITS .symtab/.strtab -+ - libbfd isn't able to look up the .symtab/.strtab in the stripped -+ object instead. As a workaround, emit .symtab/.strtab in both -+ places. */ -+ for (cnt = 1; cnt < shnum; ++cnt) -+ { -+ if (shdr_info[cnt].idx == 0 -+ && (shdr_info[cnt].shdr.sh_type == SHT_REL -+ || shdr_info[cnt].shdr.sh_type == SHT_RELA) -+ && (shdr_info[cnt].shdr.sh_flags & SHF_ALLOC) == 0) -+ { -+ Elf32_Word symtabidx = shdr_info[cnt].old_sh_link; -+ struct shdr_info *si = &shdr_info[symtabidx]; -+ si->debug_data = ""; -+ shdr_info[si->old_sh_link].debug_data = ""; -+ if (si->symtab_idx) -+ shdr_info[si->symtab_idx].debug_data = ""; -+ -+ if (si->shdr.sh_type != SHT_SYMTAB -+ || (si->shdr.sh_flags & SHF_ALLOC) -+ || shdr_info[si->old_sh_link].shdr.sh_type != SHT_STRTAB -+ || (shdr_info[si->old_sh_link].shdr.sh_flags & SHF_ALLOC) -+ || (si->symtab_idx -+ && (shdr_info[si->symtab_idx].shdr.sh_flags -+ & SHF_ALLOC))) -+ error (EXIT_FAILURE, 0, -+ gettext ("invalid symtab/strtab referenced by nonallocated section")); -+ } -+ } -+ - for (cnt = 1; cnt < shnum; ++cnt) - { - scn = elf_newscn (debugelf); -@@ -835,6 +867,7 @@ handle_elf (int fd, Elf *elf, const char - elf_errmsg (-1)); - - bool discard_section = (shdr_info[cnt].idx > 0 -+ && shdr_info[cnt].debug_data == NULL - && shdr_info[cnt].shdr.sh_type != SHT_NOTE - && cnt != ehdr->e_shstrndx); - -@@ -865,6 +898,13 @@ handle_elf (int fd, Elf *elf, const char - *debugdata = *shdr_info[cnt].data; - if (discard_section) - debugdata->d_buf = NULL; -+ else if (shdr_info[cnt].debug_data != NULL) -+ { -+ shdr_info[cnt].debug_data = xmalloc (debugdata->d_size); -+ memcpy (shdr_info[cnt].debug_data, debugdata->d_buf, -+ debugdata->d_size); -+ debugdata->d_buf = shdr_info[cnt].debug_data; -+ } - } - - /* Finish the ELF header. Fill in the fields not handled by -@@ -1056,7 +1096,7 @@ handle_elf (int fd, Elf *elf, const char - shdr_info[shdr_info[cnt].shdr.sh_info].idx; - - /* Get the data from the old file if necessary. We already -- created the data for the section header string table. */ -+ created the data for the section header string table. */ - if (cnt < shnum) - { - if (shdr_info[cnt].data == NULL) -@@ -1283,6 +1323,13 @@ handle_elf (int fd, Elf *elf, const char - if (shdr_info[shdr_info[cnt].old_sh_link].newsymidx == NULL) - continue; - -+ /* If the symbol table is not discarded, but additionally -+ duplicated in separate debug file and this section -+ is discarded, don't adjust anything. */ -+ if (shdr_info[cnt].idx == 0 -+ && shdr_info[shdr_info[cnt].old_sh_link].debug_data != NULL) -+ continue; -+ - Elf32_Word *newsymidx - = shdr_info[shdr_info[cnt].old_sh_link].newsymidx; - Elf_Data *d = elf_getdata (shdr_info[cnt].idx == 0 -@@ -1341,6 +1388,13 @@ handle_elf (int fd, Elf *elf, const char - if (shdr_info[symtabidx].newsymidx == NULL) - continue; - -+ /* If the symbol table is not discarded, but additionally -+ duplicated in separate debug file and this section -+ is discarded, don't adjust anything. */ -+ if (shdr_info[cnt].idx == 0 -+ && shdr_info[symtabidx].debug_data != NULL) -+ continue; -+ - assert (shdr_info[cnt].idx > 0); - - /* The hash section in the new file. */ -@@ -1460,7 +1514,7 @@ handle_elf (int fd, Elf *elf, const char - chain[hidx] = inner; - } - } -- } -+ } - } - else if (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym) - { -@@ -1473,6 +1527,13 @@ handle_elf (int fd, Elf *elf, const char - if (shdr_info[symtabidx].newsymidx == NULL) - continue; - -+ /* If the symbol table is not discarded, but additionally -+ duplicated in separate debug file and this section -+ is discarded, don't adjust anything. */ -+ if (shdr_info[cnt].idx == 0 -+ && shdr_info[symtabidx].debug_data != NULL) -+ continue; -+ - assert (shdr_info[cnt].idx > 0); - - /* The symbol version section in the new file. */ -@@ -1515,20 +1576,27 @@ handle_elf (int fd, Elf *elf, const char - else if (shdr_info[cnt].shdr.sh_type == SHT_GROUP) - { - /* Check whether the associated symbol table changed. */ -- if (shdr_info[shdr_info[cnt].old_sh_link].newsymidx != NULL) -- { -- /* Yes the symbol table changed. Update the section -- header of the section group. */ -- scn = elf_getscn (newelf, shdr_info[cnt].idx); -- GElf_Shdr shdr_mem; -- GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); -- assert (shdr != NULL); -+ if (shdr_info[shdr_info[cnt].old_sh_link].newsymidx == NULL) -+ continue; - -- size_t stabidx = shdr_info[cnt].old_sh_link; -- shdr->sh_info = shdr_info[stabidx].newsymidx[shdr->sh_info]; -+ /* If the symbol table is not discarded, but additionally -+ duplicated in separate debug file and this section -+ is discarded, don't adjust anything. */ -+ if (shdr_info[cnt].idx == 0 -+ && shdr_info[shdr_info[cnt].old_sh_link].debug_data != NULL) -+ continue; - -- (void) gelf_update_shdr (scn, shdr); -- } -+ /* Yes the symbol table changed. Update the section -+ header of the section group. */ -+ scn = elf_getscn (newelf, shdr_info[cnt].idx); -+ GElf_Shdr shdr_mem; -+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); -+ assert (shdr != NULL); -+ -+ size_t stabidx = shdr_info[cnt].old_sh_link; -+ shdr->sh_info = shdr_info[stabidx].newsymidx[shdr->sh_info]; -+ -+ (void) gelf_update_shdr (scn, shdr); - } - } - } -@@ -1658,7 +1726,10 @@ handle_elf (int fd, Elf *elf, const char - table indices. */ - if (any_symtab_changes) - for (cnt = 1; cnt <= shdridx; ++cnt) -- free (shdr_info[cnt].newsymidx); -+ { -+ free (shdr_info[cnt].newsymidx); -+ free (shdr_info[cnt].debug_data); -+ } - - /* Free the memory. */ - if ((shnum + 2) * sizeof (struct shdr_info) > MAX_STACK_ALLOC) ---- elfutils/tests/run-strip-test5.sh.~1~ -+++ elfutils/tests/run-strip-test5.sh -@@ -1,5 +1,5 @@ - original=testfile8 --stripped=testfile16 --debugfile=testfile16.debug -+stripped=testfile16.symtab -+debugfile=testfile16.symtab.debug - - . $srcdir/run-strip-test.sh - diff --git a/elfutils.spec b/elfutils.spec index b6bd50b..7b51df8 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,4 +1,4 @@ -%define eu_version 0.134 +%define eu_version 0.141 %define eu_release 1 %if %{?_with_compat:1}%{!?_with_compat:0} @@ -7,17 +7,17 @@ %define compat 0 %endif -%if "%fedora" >= "8" +%if 0%{?fedora} >= 8 %define scanf_has_m 1 %endif -%if "%rhel" >= "6" +%if 0%{?rhel} >= 6 %define scanf_has_m 1 %endif -%if "%fedora" >= "7" +%if 0%{?fedora} >= 7 %define separate_devel_static 1 %endif -%if "%rhel" >= "6" +%if 0%{?rhel} >= 6 %define separate_devel_static 1 %endif @@ -27,22 +27,17 @@ Version: %{eu_version} %if !%{compat} Release: %{eu_release}%{?dist} %else -Release: 0.%{eu_release} +Release: 0.%{eu_release}.1 %endif License: GPLv2 with exceptions Group: Development/Tools URL: https://fedorahosted.org/elfutils/ -Source: http://fedorahosted.org/releases/e/l/elfutils/%{name}-%{version}.tar.gz -Patch1: elfutils-portability.patch -Patch2: elfutils-robustify.patch +Source: http://fedorahosted.org/releases/e/l/elfutils/%{name}-%{version}.tar.bz2 +Patch1: elfutils-robustify.patch +Patch2: elfutils-portability.patch Requires: elfutils-libelf-%{_arch} = %{version}-%{release} Requires: elfutils-libs-%{_arch} = %{version}-%{release} -Patch0: elfutils-strip-copy-symtab.patch -Source2: testfile16.symtab.bz2 -Source3: testfile16.symtab.debug.bz2 - - BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: bison >= 1.875 BuildRequires: flex >= 2.5.4a @@ -55,6 +50,19 @@ BuildRequires: glibc-headers >= 2.3.4-11 BuildRequires: gcc >= 3.2 %endif +%define use_zlib 0 +%if 0%{?fedora} >= 5 +%define use_zlib 1 +%endif +%if 0%{?rhel} >= 5 +%define use_zlib 1 +%endif + +%if %{use_zlib} +BuildRequires: zlib-devel >= 1.2.2.3 +BuildRequires: bzip2-devel +%endif + %define _gnu %{nil} %define _program_prefix eu- @@ -147,22 +155,19 @@ for libelf. %prep %setup -q -%patch0 -p1 -ln -f %{SOURCE2} %{SOURCE3} tests || cp -f %{SOURCE2} %{SOURCE3} tests - -%if !0%{?scanf_has_m} -sed -i.scanf-m -e 's/%m/%a/' tests/line2addr.c -%endif +%patch1 -p1 -b .robustify %if %{compat} -%patch1 -p1 +%patch2 -p1 -b .portability sleep 1 find . \( -name Makefile.in -o -name aclocal.m4 \) -print | xargs touch sleep 1 find . \( -name configure -o -name config.h.in \) -print | xargs touch +%else +%if !0%{?scanf_has_m} +sed -i.scanf-m -e 's/%m/%a/g' src/addr2line.c tests/line2addr.c +%endif %endif - -%patch2 -p1 find . -name \*.sh ! -perm -0100 -print | xargs chmod +x @@ -189,9 +194,9 @@ chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/lib*.so* chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/elfutils/lib*.so* # XXX Nuke unpackaged files -{ cd ${RPM_BUILD_ROOT} - rm -f .%{_bindir}/eu-ld -} +(cd ${RPM_BUILD_ROOT} + rm -f .%{_bindir}/eu-ld +) %check make -s check @@ -244,6 +249,7 @@ rm -rf ${RPM_BUILD_ROOT} %{_includedir}/elfutils/libebl.h %{_includedir}/elfutils/libdw.h %{_includedir}/elfutils/libdwfl.h +%{_includedir}/elfutils/version.h %{_libdir}/libebl.a %{_libdir}/libasm.so %{_libdir}/libdw.so @@ -270,6 +276,63 @@ rm -rf ${RPM_BUILD_ROOT} %{_libdir}/libelf.a %changelog +* Thu Apr 23 2009 Roland McGrath - 0.141-1 +- Update to 0.141 + - libebl: sparc backend fixes (#490585) + some more arm backend support + - libdwfl: fix dwfl_module_build_id for prelinked DSO case (#489439) + fixes in core file support (#494858) + dwfl_module_getsym interface improved for non-address symbols + - eu-strip: fix infinite loop on strange inputs with -f + - eu-addr2line: take -j/--section=NAME option for binutils compatibility + (same effect as '(NAME)0x123' syntax already supported) +- Resolves: RHBZ #495213, RHBZ #465872, RHBZ #470055, RHBZ #484623 + +* Tue Feb 24 2009 Fedora Release Engineering - 0.140-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Sun Feb 15 2009 Roland McGrath - 0.140-1 +- Update to 0.140 + - libelf: Fix regression in creation of section header. (#484946) + +* Fri Jan 23 2009 Roland McGrath - 0.139-1 +- Update to 0.139 + - libcpu: Add Intel SSE4 disassembler support + - readelf: Implement call frame information and exception handling dumping. + Add -e option. Enable it implicitly for -a. + - elflint: Check PT_GNU_EH_FRAME program header entry. + - libdwfl: Support automatic gzip/bzip2 decompression of ELF files. (#472136) + +* Thu Jan 1 2009 Roland McGrath - 0.138-2 +- Fix libelf regression. + +* Wed Dec 31 2008 Roland McGrath - 0.138-1 +- Update to 0.138 + - Install header file for applications to use in + source version compatibility checks. + - libebl: backend fixes for i386 TLS relocs; backend support for NT_386_IOPERM + - libcpu: disassembler fixes (#469739) + - libdwfl: bug fixes (#465878) + - libelf: bug fixes + - eu-nm: bug fixes for handling corrupt input files (#476136) + +* Wed Oct 1 2008 Roland McGrath - 0.137-3 +- fix libdwfl regression (#462689) + +* Thu Aug 28 2008 Roland McGrath - 0.137-2 +- Update to 0.137 + - libdwfl: bug fixes; new segment interfaces; + all the libdwfl-based tools now support --core=COREFILE option +- Resolves: RHBZ #325021, RHBZ #447416 + +* Mon Jul 7 2008 Tom "spot" Callaway - 0.135-2 +- fix conditional comparison + +* Mon May 12 2008 Roland McGrath - 0.135-1 +- Update to 0.135 + - libdwfl: bug fixes + - eu-strip: changed handling of ET_REL files wrt symbol tables and relocs + * Wed Apr 9 2008 Roland McGrath - 0.134-1 - Update to 0.134 - elflint: backend improvements for sparc, alpha (#204170) @@ -349,7 +412,6 @@ rm -rf ${RPM_BUILD_ROOT} - New program eu-ar. - libdw: fix missing dwarf_getelf (#227206) - libdwfl: dwfl_module_addrname for st_size=0 symbols (#227167, #227231) -- Resolves: RHBZ #227206, RHBZ #227167, RHBZ #227231 * Wed Jan 10 2007 Roland McGrath - 0.125-3 - Fix overeager warn_unused_result build failures. diff --git a/sources b/sources index 6ae75e8..7e662e2 100644 --- a/sources +++ b/sources @@ -1,3 +1 @@ -07a924423a05b1bf6d0f9fe8b35dbe6b testfile16.symtab.bz2 -bd40d1aaca8eaf1c7aea54bf4b29bda2 testfile16.symtab.debug.bz2 -17b6dde57fec341ae785d5b7123da7c4 elfutils-0.134.tar.gz +2d0fe5651c0de1fd28e7dd006effe7d1 elfutils-0.141.tar.bz2 diff --git a/systemtap-elfutils.repo b/systemtap-elfutils.repo deleted file mode 100644 index 96d326b..0000000 --- a/systemtap-elfutils.repo +++ /dev/null @@ -1,5 +0,0 @@ -[systemtap-elfutils] -name=FOR SYSTEMTAP DEVELOPMENT ONLY -baseurl=ftp://sources.redhat.com/pub/systemtap/elfutils/ -enabled=1 -gpgcheck=0 diff --git a/upstream-key.gpg b/upstream-key.gpg index 850e6e6..5ba3b5d 100644 --- a/upstream-key.gpg +++ b/upstream-key.gpg @@ -1,123 +1,109 @@ +pub 1024D/7EBBD625 2003-01-10 +uid Roland McGrath +uid Roland McGrath +uid Roland McGrath +uid Roland McGrath +sub 2048g/17998A93 2003-01-10 + pub 1024D/79FF4474 2001-08-24 uid Ulrich Drepper uid Ulrich Drepper -uid [jpeg image of size 2203] sub 2048g/07FA6550 2001-08-24 -----BEGIN PGP PUBLIC KEY BLOCK----- -Version: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