]> git.pld-linux.org Git - packages/elfutils.git/commitdiff
- updated from FC devel
authorJakub Bogusz <qboosh@pld-linux.org>
Tue, 1 Nov 2005 02:01:22 +0000 (02:01 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    elfutils-portability.patch -> 1.2
    elfutils-robustify.patch -> 1.2

elfutils-portability.patch
elfutils-robustify.patch

index c4b85fa38526f9203ff9f0525b85ee6ba2171028..f21629ca7ea43bd047420679279d3c31989bbbdc 100644 (file)
@@ -1,35 +1,26 @@
 --- elfutils/ChangeLog
 +++ elfutils/ChangeLog
-@@ -1,3 +1,16 @@
-+2005-02-07  Roland McGrath  <roland@frob.com>
+@@ -23,6 +23,17 @@
+       * Makefile.am (all_SUBDIRS): Add libdwfl.
+       * configure.ac: Write libdwfl/Makefile.
++2005-05-31  Roland McGrath  <roland@redhat.com>
 +
 +      * configure.ac (WEXTRA): Check for -Wextra and set this substitution.
 +
-+2003-08-12  Roland McGrath  <roland@redhat.com>
-+
-+      * 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-02-22  Ulrich Drepper  <drepper@redhat.com>
+ 2005-05-19  Roland McGrath  <roland@redhat.com>
  
-       * Makefile.am (all_SUBDIRS): Don't add doc subdir for now.
---- elfutils/Makefile.in
-+++ elfutils/Makefile.in
-@@ -127,6 +127,7 @@ SHELL = @SHELL@
- STRIP = @STRIP@
- USE_NLS = @USE_NLS@
- VERSION = @VERSION@
-+WEXTRA = @WEXTRA@
- XGETTEXT = @XGETTEXT@
- YACC = @YACC@
- ac_ct_CC = @ac_ct_CC@
+       * configure.ac [AH_BOTTOM] (INTDECL, _INTDECL): New macros.
 --- elfutils/config/Makefile.in
 +++ elfutils/config/Makefile.in
-@@ -105,6 +105,7 @@ SHELL = @SHELL@
+@@ -113,6 +113,7 @@ SHELL = @SHELL@
  STRIP = @STRIP@
  USE_NLS = @USE_NLS@
  VERSION = @VERSION@
  ac_ct_CC = @ac_ct_CC@
 --- elfutils/configure
 +++ elfutils/configure
-@@ -277,7 +277,7 @@ PACKAGE_STRING='Red Hat elfutils 0.108'
+@@ -276,7 +276,7 @@ PACKAGE_STRING='Red Hat elfutils 0.115'
  PACKAGE_BUGREPORT='http://bugzilla.redhat.com/bugzilla/'
  
  ac_unique_file="libelf/libelf.h"
--ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE RANLIB ac_ct_RANLIB YACC LEX LEXLIB LEX_OUTPUT_ROOT LOCALEDIR DATADIRNAME NATIVE_LD_TRUE NATIVE_LD_FALSE base_cpu MUDFLAP_TRUE MUDFLAP_FALSE USE_NLS MKINSTALLDIRS MSGFMT GMSGFMT XGETTEXT MSGMERGE LIBOBJS LTLIBOBJS'
-+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE RANLIB ac_ct_RANLIB YACC LEX LEXLIB LEX_OUTPUT_ROOT WEXTRA LOCALEDIR DATADIRNAME NATIVE_LD_TRUE NATIVE_LD_FALSE base_cpu MUDFLAP_TRUE MUDFLAP_FALSE USE_NLS MKINSTALLDIRS MSGFMT GMSGFMT XGETTEXT MSGMERGE LIBOBJS LTLIBOBJS'
+-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MODVERSION build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE RANLIB ac_ct_RANLIB YACC LEX LEXLIB LEX_OUTPUT_ROOT LOCALEDIR DATADIRNAME NATIVE_LD_TRUE NATIVE_LD_FALSE base_cpu MUDFLAP_TRUE MUDFLAP_FALSE GPROF_TRUE GPROF_FALSE GCOV_TRUE GCOV_FALSE BUILD_STATIC_TRUE BUILD_STATIC_FALSE LIBEBL_SUBDIR USE_NLS MKINSTALLDIRS MSGFMT GMSGFMT XGETTEXT MSGMERGE LIBOBJS LTLIBOBJS'
++ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MODVERSION build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE RANLIB ac_ct_RANLIB YACC LEX LEXLIB LEX_OUTPUT_ROOT WEXTRA LOCALEDIR DATADIRNAME NATIVE_LD_TRUE NATIVE_LD_FALSE base_cpu MUDFLAP_TRUE MUDFLAP_FALSE GPROF_TRUE GPROF_FALSE GCOV_TRUE GCOV_FALSE BUILD_STATIC_TRUE BUILD_STATIC_FALSE LIBEBL_SUBDIR USE_NLS MKINSTALLDIRS MSGFMT GMSGFMT XGETTEXT MSGMERGE LIBOBJS LTLIBOBJS'
  ac_subst_files=''
  
  # Initialize some variables set by options.
-@@ -3373,6 +3373,58 @@ echo "$as_me: error: gcc with C99 suppor
+@@ -3384,6 +3384,58 @@ echo "$as_me: error: gcc with C99 suppor
  fi
  
  
@@ -97,7 +88,7 @@
 +echo "$as_me:$LINENO: result: $ac_cv_cc_wextra" >&5
 +echo "${ECHO_T}$ac_cv_cc_wextra" >&6
 +
-+if test "x$ac_cv_cc_wextra" = yes; then
++if test "x$ac_cv_cc_wextra" = xyes; then
 +  WEXTRA=-Wextra
 +else
 +  WEXTRA=-W
  LOCALEDIR=$datadir
  
  cat >>confdefs.h <<_ACEOF
-@@ -4818,6 +4870,7 @@ s,@YACC@,$YACC,;t t
+@@ -4925,6 +4977,7 @@ s,@YACC@,$YACC,;t t
  s,@LEX@,$LEX,;t t
  s,@LEXLIB@,$LEXLIB,;t t
  s,@LEX_OUTPUT_ROOT@,$LEX_OUTPUT_ROOT,;t t
  s,@NATIVE_LD_TRUE@,$NATIVE_LD_TRUE,;t t
 --- elfutils/configure.ac
 +++ elfutils/configure.ac
-@@ -64,6 +64,15 @@ CFLAGS="$old_CFLAGS"])
+@@ -69,6 +69,15 @@ CFLAGS="$old_CFLAGS"])
  AS_IF([test "x$ac_cv_c99" != xyes],
        AC_MSG_ERROR([gcc with C99 support required]))
  
 +                ac_cv_cc_wextra=yes, ac_cv_cc_wextra=no)
 +CFLAGS="$old_CFLAGS"])
 +AC_SUBST(WEXTRA)
-+AS_IF([test "x$ac_cv_cc_wextra" = yes], [WEXTRA=-Wextra], [WEXTRA=-W])
++AS_IF([test "x$ac_cv_cc_wextra" = xyes], [WEXTRA=-Wextra], [WEXTRA=-W])
 +
  LOCALEDIR=$datadir
  AC_SUBST(LOCALEDIR)
  AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR")
 --- elfutils/lib/ChangeLog
 +++ elfutils/lib/ChangeLog
-@@ -4,6 +4,11 @@
+@@ -12,6 +12,11 @@
        * Makefile.am (libeu_a_SOURCES): Add it.
        * system.h: Declare crc32_file.
  
  noinst_LIBRARIES = libeu.a
 --- elfutils/lib/Makefile.in
 +++ elfutils/lib/Makefile.in
-@@ -127,6 +127,7 @@ SHELL = @SHELL@
+@@ -135,6 +135,7 @@ SHELL = @SHELL@
  STRIP = @STRIP@
  USE_NLS = @USE_NLS@
  VERSION = @VERSION@
  XGETTEXT = @XGETTEXT@
  YACC = @YACC@
  ac_ct_CC = @ac_ct_CC@
-@@ -169,9 +170,9 @@ sharedstatedir = @sharedstatedir@
+@@ -177,9 +178,9 @@ sharedstatedir = @sharedstatedir@
  sysconfdir = @sysconfdir@
  target_alias = @target_alias@
  @MUDFLAP_FALSE@AM_CFLAGS = -fpic -Wall -Wshadow -Werror -Wunused \
  INCLUDES = -I$(srcdir)/../libelf -I..
  noinst_LIBRARIES = libeu.a
  libeu_a_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c \
+--- elfutils/libasm/ChangeLog
++++ elfutils/libasm/ChangeLog
+@@ -24,6 +24,11 @@
+       * asm_error.c: Add new error ASM_E_IOERROR.
+       * libasmP.h: Add ASM_E_IOERROR definition.
++2005-05-31  Roland McGrath  <roland@redhat.com>
++
++      * Makefile.am (WEXTRA): New variable, substituted by configure.
++      (AM_CFLAGS): Use it in place of -Wextra.
++
+ 2005-02-15  Ulrich Drepper  <drepper@redhat.com>
+       * Makefile.am (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2.
 --- elfutils/libasm/Makefile.am
 +++ elfutils/libasm/Makefile.am
 @@ -13,12 +13,13 @@
  else
  AM_CFLAGS =
  endif
--AM_CFLAGS += -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2
-+AM_CFLAGS += -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2
+-AM_CFLAGS += -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2
++AM_CFLAGS += -std=gnu99 -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2
  INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl \
           -I$(top_srcdir)/lib
  GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
 --- elfutils/libasm/Makefile.in
 +++ elfutils/libasm/Makefile.in
-@@ -159,6 +159,7 @@ SHELL = @SHELL@
+@@ -167,6 +167,7 @@ SHELL = @SHELL@
  STRIP = @STRIP@
  USE_NLS = @USE_NLS@
  VERSION = 1
  XGETTEXT = @XGETTEXT@
  YACC = @YACC@
  ac_ct_CC = @ac_ct_CC@
-@@ -200,10 +201,10 @@ sbindir = @sbindir@
- sharedstatedir = @sharedstatedir@
+@@ -209,9 +210,9 @@ sharedstatedir = @sharedstatedir@
  sysconfdir = @sysconfdir@
  target_alias = @target_alias@
--@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Wshadow -Werror -Wunused -Wextra \
-+@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Wshadow -Werror -Wunused $(WEXTRA) \
- @MUDFLAP_FALSE@       -Wformat=2
- @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -Wall -Wshadow -Werror -Wunused \
--@MUDFLAP_TRUE@        -Wextra -Wformat=2
-+@MUDFLAP_TRUE@        $(WEXTRA) -Wformat=2
+ @MUDFLAP_FALSE@AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Werror -Wunused \
+-@MUDFLAP_FALSE@       -Wextra -Wformat=2
++@MUDFLAP_FALSE@       $(WEXTRA) -Wformat=2
+ @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -std=gnu99 -Wall -Wshadow -Werror \
+-@MUDFLAP_TRUE@        -Wunused -Wextra -Wformat=2
++@MUDFLAP_TRUE@        -Wunused $(WEXTRA) -Wformat=2
  INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl \
           -I$(top_srcdir)/lib
  
  noinst_LIBRARIES = libcpu_i386.a
 --- elfutils/libcpu/Makefile.in
 +++ elfutils/libcpu/Makefile.in
-@@ -122,6 +122,7 @@ SHELL = @SHELL@
+@@ -130,6 +130,7 @@ SHELL = @SHELL@
  STRIP = @STRIP@
  USE_NLS = @USE_NLS@
  VERSION = @VERSION@
  XGETTEXT = @XGETTEXT@
  YACC = @YACC@
  ac_ct_CC = @ac_ct_CC@
-@@ -163,7 +164,7 @@ sbindir = @sbindir@
+@@ -171,7 +172,7 @@ sbindir = @sbindir@
  sharedstatedir = @sharedstatedir@
  sysconfdir = @sysconfdir@
  target_alias = @target_alias@
  INCLUDES = -I$(srcdir)
  noinst_LIBRARIES = libcpu_i386.a
  libcpu_i386_a_SOURCES = i386_dis.c
+--- elfutils/libdw/ChangeLog
++++ elfutils/libdw/ChangeLog
+@@ -140,6 +140,11 @@
+ 2005-05-31  Roland McGrath  <roland@redhat.com>
++      * Makefile.am (WEXTRA): New variable, substituted by configure.
++      (AM_CFLAGS): Use it in place of -Wextra.
++
++2005-05-31  Roland McGrath  <roland@redhat.com>
++
+       * dwarf_formref_die.c (dwarf_formref_die): Add CU header offset to
+       formref offset.
 --- elfutils/libdw/Makefile.am
 +++ elfutils/libdw/Makefile.am
 @@ -13,12 +13,13 @@
  ## 3001 King Ranch Road, Ukiah, CA 95482.
  ##
- DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
+ DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DIS_LIBDW
 +WEXTRA = @WEXTRA@
  if MUDFLAP
  AM_CFLAGS = -fmudflap
  
 --- elfutils/libdw/Makefile.in
 +++ elfutils/libdw/Makefile.in
-@@ -190,6 +190,7 @@ SHELL = @SHELL@
+@@ -207,6 +207,7 @@ SHELL = @SHELL@
  STRIP = @STRIP@
  USE_NLS = @USE_NLS@
  VERSION = 1
  XGETTEXT = @XGETTEXT@
  YACC = @YACC@
  ac_ct_CC = @ac_ct_CC@
-@@ -232,9 +233,9 @@ sharedstatedir = @sharedstatedir@
+@@ -249,9 +250,9 @@ sharedstatedir = @sharedstatedir@
  sysconfdir = @sysconfdir@
  target_alias = @target_alias@
  @MUDFLAP_FALSE@AM_CFLAGS = -Wall -Werror -Wshadow -Wunused -Wformat=2 \
 -@MUDFLAP_TRUE@        -Wformat=2 -Wextra -std=gnu99
 +@MUDFLAP_TRUE@        -Wformat=2 $(WEXTRA) -std=gnu99
  INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib
- lib_LIBRARIES = libdw.a
- @MUDFLAP_FALSE@noinst_LIBRARIES = libdw_pic.a
+ COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
+                                                      $(COMPILE)))
+--- elfutils/libdwfl/ChangeLog
++++ elfutils/libdwfl/ChangeLog
+@@ -192,6 +192,11 @@
+ 2005-07-21  Roland McGrath  <roland@redhat.com>
++      * Makefile.am (WEXTRA): New variable, substituted by configure.
++      (AM_CFLAGS): Use it in place of -Wextra.
++
++2005-07-21  Roland McGrath  <roland@redhat.com>
++
+       * Makefile.am (noinst_HEADERS): Add loc2c.c.
+       * test2.c (main): Check sscanf result to quiet warning.
+--- elfutils/libdwfl/Makefile.am
++++ elfutils/libdwfl/Makefile.am
+@@ -15,12 +15,13 @@
+ ## 3001 King Ranch Road, Ukiah, CA 95482.
+ ##
+ DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
++WEXTRA = @WEXTRA@
+ if MUDFLAP
+ AM_CFLAGS = -fmudflap
+ else
+ AM_CFLAGS =
+ endif
+-AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99
++AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 $(WEXTRA) -std=gnu99
+ INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
+          -I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib
+ VERSION = 1
+--- elfutils/libdwfl/Makefile.in
++++ elfutils/libdwfl/Makefile.in
+@@ -163,6 +163,7 @@ SHELL = @SHELL@
+ STRIP = @STRIP@
+ USE_NLS = @USE_NLS@
+ VERSION = 1
++WEXTRA = @WEXTRA@
+ XGETTEXT = @XGETTEXT@
+ YACC = @YACC@
+ ac_ct_CC = @ac_ct_CC@
+@@ -205,9 +206,9 @@ sharedstatedir = @sharedstatedir@
+ sysconfdir = @sysconfdir@
+ target_alias = @target_alias@
+ @MUDFLAP_FALSE@AM_CFLAGS = -Wall -Werror -Wshadow -Wunused -Wformat=2 \
+-@MUDFLAP_FALSE@       -Wextra -std=gnu99
++@MUDFLAP_FALSE@       $(WEXTRA) -std=gnu99
+ @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -Wall -Werror -Wshadow -Wunused \
+-@MUDFLAP_TRUE@        -Wformat=2 -Wextra -std=gnu99
++@MUDFLAP_TRUE@        -Wformat=2 $(WEXTRA) -std=gnu99
+ INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
+          -I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib
+--- elfutils/libebl/ChangeLog
++++ elfutils/libebl/ChangeLog
+@@ -152,6 +152,11 @@
+       * Makefile.am (libebl_*_so_SOURCES): Set to $(*_SRCS) so dependency
+       tracking works right.
++2005-05-31  Roland McGrath  <roland@redhat.com>
++
++      * Makefile.am (WEXTRA): New variable, substituted by configure.
++      (AM_CFLAGS): Use it in place of -Wextra.
++
+ 2005-05-21  Ulrich Drepper  <drepper@redhat.com>
+       * libebl_x86_64.map: Add x86_64_core_note.
 --- elfutils/libebl/Makefile.am
 +++ elfutils/libebl/Makefile.am
 @@ -13,12 +13,13 @@
  INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/lib -I..
 --- elfutils/libebl/Makefile.in
 +++ elfutils/libebl/Makefile.in
-@@ -236,6 +236,7 @@ SHELL = @SHELL@
+@@ -258,6 +258,7 @@ SHELL = @SHELL@
  STRIP = @STRIP@
  USE_NLS = @USE_NLS@
  VERSION = 1
  XGETTEXT = @XGETTEXT@
  YACC = @YACC@
  ac_ct_CC = @ac_ct_CC@
-@@ -278,9 +279,9 @@ sharedstatedir = @sharedstatedir@
+@@ -300,9 +301,9 @@ sharedstatedir = @sharedstatedir@
  sysconfdir = @sysconfdir@
  target_alias = @target_alias@
  @MUDFLAP_FALSE@AM_CFLAGS = -fpic -Wall -Wshadow -Werror -Wunused \
 +@MUDFLAP_TRUE@        -Wunused $(WEXTRA) -Wformat=2 -std=gnu99
  INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/lib -I..
  lib_LIBRARIES = libebl.a
- modules = i386 sh mips x86_64 ia64 alpha arm sparc ppc ppc64
+ modules = i386 sh x86_64 ia64 alpha arm sparc ppc ppc64
+--- elfutils/libelf/ChangeLog
++++ elfutils/libelf/ChangeLog
+@@ -86,6 +86,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.
++2005-05-31  Roland McGrath  <roland@redhat.com>
++
++      * Makefile.am (WEXTRA): New variable, substituted by configure.
++      (AM_CFLAGS): Use it in place of -Wextra.
++
+ 2005-05-11  Ulrich Drepper  <drepper@redhat.com>
+       * elf.h: Update again.
+--- elfutils/libelf/common.h
++++ elfutils/libelf/common.h
+@@ -122,7 +122,7 @@ libelf_release_all (Elf *elf)
+   (Var) = (sizeof (Var) == 1                                                \
+          ? (unsigned char) (Var)                                            \
+          : (sizeof (Var) == 2                                               \
+-            ? bswap_16 (Var)                                                \
++            ? (unsigned short int) bswap_16 (Var)                           \
+             : (sizeof (Var) == 4                                            \
+                ? bswap_32 (Var)                                             \
+                : bswap_64 (Var))))
+@@ -131,7 +131,7 @@ libelf_release_all (Elf *elf)
+   (Dst) = (sizeof (Var) == 1                                                \
+          ? (unsigned char) (Var)                                            \
+          : (sizeof (Var) == 2                                               \
+-            ? bswap_16 (Var)                                                \
++            ? (unsigned short int) bswap_16 (Var)                           \
+             : (sizeof (Var) == 4                                            \
+                ? bswap_32 (Var)                                             \
+                : bswap_64 (Var))))
 --- elfutils/libelf/Makefile.am
 +++ elfutils/libelf/Makefile.am
-@@ -16,12 +16,13 @@
+@@ -16,6 +16,7 @@
  ## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  ##
  DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
 +WEXTRA = @WEXTRA@
  if MUDFLAP
- AM_CFLAGS = -fpic -fmudflap
+ AM_CFLAGS = -fmudflap
  else
- AM_CFLAGS =
+@@ -24,7 +25,10 @@ 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
-@@ -199,6 +199,7 @@ SHELL = @SHELL@
+@@ -40,7 +40,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
+@@ -210,6 +210,7 @@ SHELL = @SHELL@
  STRIP = @STRIP@
  USE_NLS = @USE_NLS@
  VERSION = 1
  XGETTEXT = @XGETTEXT@
  YACC = @YACC@
  ac_ct_CC = @ac_ct_CC@
-@@ -240,10 +241,10 @@ sbindir = @sbindir@
- sharedstatedir = @sharedstatedir@
+@@ -252,10 +253,10 @@ sharedstatedir = @sharedstatedir@
  sysconfdir = @sysconfdir@
  target_alias = @target_alias@
--@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Wshadow -Werror -Wunused -Wextra \
-+@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Wshadow -Werror -Wunused $(WEXTRA) \
- @MUDFLAP_FALSE@       -Wformat=2 -std=gnu99 $($(*F)_CFLAGS)
- @MUDFLAP_TRUE@AM_CFLAGS = -fpic -fmudflap -Wall -Wshadow -Werror \
--@MUDFLAP_TRUE@        -Wunused -Wextra -Wformat=2 -std=gnu99 \
-+@MUDFLAP_TRUE@        -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 \
+ @MUDFLAP_FALSE@AM_CFLAGS = $(am__append_1) -Wall -Wshadow -Werror \
+-@MUDFLAP_FALSE@       -Wunused -Wextra -Wformat=2 -std=gnu99 \
++@MUDFLAP_FALSE@       -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 \
+ @MUDFLAP_FALSE@       $($(*F)_CFLAGS)
+ @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap $(am__append_1) -Wall -Wshadow \
+-@MUDFLAP_TRUE@        -Werror -Wunused -Wextra -Wformat=2 -std=gnu99 \
++@MUDFLAP_TRUE@        -Werror -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 \
  @MUDFLAP_TRUE@        $($(*F)_CFLAGS)
  INCLUDES = -I$(srcdir) -I$(top_srcdir)/lib -I..
  GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
 --- elfutils/m4/Makefile.in
 +++ elfutils/m4/Makefile.in
-@@ -103,6 +103,7 @@ SHELL = @SHELL@
+@@ -111,6 +111,7 @@ SHELL = @SHELL@
  STRIP = @STRIP@
  USE_NLS = @USE_NLS@
  VERSION = @VERSION@
  XGETTEXT = @XGETTEXT@
  YACC = @YACC@
  ac_ct_CC = @ac_ct_CC@
---- elfutils/src/Makefile.am
-+++ elfutils/src/Makefile.am
-@@ -14,14 +14,15 @@
- ##
- DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) \
-        -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
-+WEXTRA = @WEXTRA@
- if MUDFLAP
--AM_CFLAGS = -Wall -Wshadow -Wunused -Wextra -std=gnu99 -fmudflap \
-+AM_CFLAGS = -Wall -Wshadow -Wunused $(WEXTRA) -std=gnu99 -fmudflap \
-           $(native_ld_cflags) $(if $($(*F)_no_Wunused),,-Wunused) \
-           $(if $($(*F)_no_Wformat),,-Wformat=2)
- else
- AM_CFLAGS = -Wall -Wshadow -std=gnu99 $(native_ld_cflags) \
-           $(if $($(*F)_no_Werror),,-Werror) \
--          $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
-+          $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \
-           $(if $($(*F)_no_Wformat),,-Wformat=2)
- endif
- if MUDFLAP
---- elfutils/src/Makefile.in
-+++ elfutils/src/Makefile.in
-@@ -194,6 +194,7 @@ SHELL = @SHELL@
+--- elfutils/Makefile.in
++++ elfutils/Makefile.in
+@@ -135,6 +135,7 @@ SHELL = @SHELL@
  STRIP = @STRIP@
  USE_NLS = @USE_NLS@
  VERSION = @VERSION@
 +WEXTRA = @WEXTRA@
  XGETTEXT = @XGETTEXT@
- YACC = @YACC@ -d
+ YACC = @YACC@
  ac_ct_CC = @ac_ct_CC@
-@@ -237,10 +238,10 @@ sysconfdir = @sysconfdir@
- target_alias = @target_alias@
- @MUDFLAP_FALSE@AM_CFLAGS = -Wall -Wshadow -std=gnu99 $(native_ld_cflags) \
- @MUDFLAP_FALSE@           $(if $($(*F)_no_Werror),,-Werror) \
--@MUDFLAP_FALSE@           $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
-+@MUDFLAP_FALSE@           $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \
- @MUDFLAP_FALSE@           $(if $($(*F)_no_Wformat),,-Wformat=2)
+--- elfutils/src/ChangeLog
++++ elfutils/src/ChangeLog
+@@ -216,6 +216,11 @@
+       * readelf.c (print_debug_loc_section): Fix indentation for larger
+       address size.
  
--@MUDFLAP_TRUE@AM_CFLAGS = -Wall -Wshadow -Wunused -Wextra -std=gnu99 -fmudflap \
-+@MUDFLAP_TRUE@AM_CFLAGS = -Wall -Wshadow -Wunused $(WEXTRA) -std=gnu99 -fmudflap \
- @MUDFLAP_TRUE@            $(native_ld_cflags) $(if $($(*F)_no_Wunused),,-Wunused) \
- @MUDFLAP_TRUE@            $(if $($(*F)_no_Wformat),,-Wformat=2)
++2005-05-31  Roland McGrath  <roland@redhat.com>
++
++      * Makefile.am (WEXTRA): New variable, substituted by configure.
++      (AM_CFLAGS): Use it in place of -Wextra.
++
+ 2005-05-30  Roland McGrath  <roland@redhat.com>
  
+       * readelf.c (print_debug_line_section): Print section offset of each
 --- elfutils/src/findtextrel.c
 +++ elfutils/src/findtextrel.c
 @@ -476,7 +476,11 @@ ptrcompare (const void *p1, const void *
           GElf_Addr addr, Elf *elf, Elf_Scn *symscn, Dwarf *dw,
           const char *fname, bool more_than_one, void **knownsrcs)
  {
+--- elfutils/src/Makefile.am
++++ elfutils/src/Makefile.am
+@@ -14,6 +14,7 @@
+ ##
+ DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) \
+        -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
++WEXTRA = @WEXTRA@
+ if MUDFLAP
+ AM_CFLAGS = -fmudflap
+ else
+@@ -21,7 +22,7 @@ AM_CFLAGS =
+ endif
+ AM_CFLAGS += -Wall -Wshadow -std=gnu99 $(native_ld_cflags) \
+            $(if $($(*F)_no_Werror),,-Werror) \
+-           $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
++           $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \
+            $(if $($(*F)_no_Wformat),,-Wformat=2)
+ INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
+--- elfutils/src/Makefile.in
++++ elfutils/src/Makefile.in
+@@ -221,6 +221,7 @@ SHELL = @SHELL@
+ STRIP = @STRIP@
+ USE_NLS = @USE_NLS@
+ VERSION = @VERSION@
++WEXTRA = @WEXTRA@
+ XGETTEXT = @XGETTEXT@
+ YACC = @YACC@ -d
+ ac_ct_CC = @ac_ct_CC@
+@@ -265,12 +266,12 @@ target_alias = @target_alias@
+ @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_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)
+ INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
+          -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \
 --- elfutils/src/strip.c
 +++ elfutils/src/strip.c
 @@ -40,6 +40,12 @@
  
  /* Name and version of program.  */
  static void print_version (FILE *stream, struct argp_state *state);
-@@ -269,8 +275,18 @@ process_file (const char *fname)
+@@ -288,8 +294,18 @@ process_file (const char *fname)
  
        /* If we have to preserve the timestamp, we need it in the
         format utimes() understands.  */
      }
  
    /* Open the file.  */
-@@ -1677,7 +1693,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1679,7 +1695,7 @@ handle_elf (int fd, Elf *elf, const char
    /* If requested, preserve the timestamp.  */
    if (tvp != NULL)
      {
        {
          error (0, errno, gettext ("\
  cannot set access and modification date of '%s'"),
-@@ -1734,7 +1750,7 @@ handle_ar (int fd, Elf *elf, const char 
+@@ -1736,7 +1752,7 @@ handle_ar (int fd, Elf *elf, const char 
  
    if (tvp != NULL)
      {
        {
          error (0, errno, gettext ("\
  cannot set access and modification date of '%s'"), fname);
+--- elfutils/tests/ChangeLog
++++ elfutils/tests/ChangeLog
+@@ -161,6 +161,11 @@
+       * Makefile.am (TESTS): Add run-elflint-test.sh.
+       (EXTRA_DIST): Add run-elflint-test.sh and testfile18.bz2.
++2005-05-31  Roland McGrath  <roland@redhat.com>
++
++      * Makefile.am (WEXTRA): New variable, substituted by configure.
++      (AM_CFLAGS): Use it in place of -Wextra.
++
+ 2005-05-24  Ulrich Drepper  <drepper@redhat.com>
+       * get-files.c (main): Use correct format specifier.
+--- elfutils/tests/Makefile.am
++++ elfutils/tests/Makefile.am
+@@ -13,12 +13,13 @@
+ ## 3001 King Ranch Road, Ukiah, CA 95482.
+ ##
+ DEFS = -DHAVE_CONFIG_H -D_GNU_SOURCE
++WEXTRA = @WEXTRA@
+ if MUDFLAP
+-AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 -fmudflap\
++AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 -fmudflap\
+           $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2)
+ AM_LDFLAGS = -Wl,-rpath,\$$ORIGIN/../libebl
+ else
+-AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 \
++AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 \
+           $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2)
+ AM_LDFLAGS = -Wl,-rpath,\$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../libebl:\$$ORIGIN/../libelf
+ endif
 --- elfutils/tests/Makefile.in
 +++ elfutils/tests/Makefile.in
-@@ -266,6 +266,7 @@ SHELL = @SHELL@
+@@ -287,6 +287,7 @@ SHELL = @SHELL@
  STRIP = @STRIP@
  USE_NLS = @USE_NLS@
  VERSION = @VERSION@
  XGETTEXT = @XGETTEXT@
  YACC = @YACC@
  ac_ct_CC = @ac_ct_CC@
+@@ -328,10 +329,10 @@ sbindir = @sbindir@
+ sharedstatedir = @sharedstatedir@
+ sysconfdir = @sysconfdir@
+ target_alias = @target_alias@
+-@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 \
++@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 \
+ @MUDFLAP_FALSE@           $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2)
+-@MUDFLAP_TRUE@AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 -fmudflap\
++@MUDFLAP_TRUE@AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 -fmudflap\
+ @MUDFLAP_TRUE@            $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2)
+ @MUDFLAP_FALSE@AM_LDFLAGS = -Wl,-rpath,\$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../libebl:\$$ORIGIN/../libelf
index 1e6396e55bd725e242b6b7cabe442aa85a1344e0..a5ab1fa29c0860fa9c091e05d2a99b7583821340 100644 (file)
@@ -19,8 +19,8 @@ libelf/
        bounds.
        * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)): Fix comment pasto.
        Check if section header table fits into object's bounds.
-       * elf_begin.c (get_shnum): Fail if maxsize is smaller than ELF headers.
-       Ensure first section header 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.
@@ -65,121 +65,385 @@ src/
        (check_symtab, is_rel_dyn, check_rela, check_rel, check_dynamic,
        check_symtab_shndx, check_hash, check_versym): Robustify.
 
---- elfutils-0.108/libelf/gelf_getrel.c.jj     2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_getrel.c        2005-05-14 01:31:25.000000000 +0200
+--- elfutils-0.115/libelf/elf32_getphdr.c
++++ elfutils-0.115/libelf/elf32_getphdr.c
+@@ -82,6 +82,16 @@ elfw2(LIBELFBITS,getphdr) (elf)
+       if (elf->map_address != NULL)
+       {
++        /* First see whether the information in the ELF header is
++           valid and it does not ask for too much.  */
++        if (unlikely (ehdr->e_phoff >= elf->maximum_size)
++            || unlikely (ehdr->e_phoff + size > elf->maximum_size))
++          {
++            /* Something is wrong.  */
++            __libelf_seterrno (ELF_E_INVALID_PHDR);
++            goto out;
++          }
++
+         /* All the data is already mapped.  Use it.  */
+         if (ehdr->e_ident[EI_DATA] == MY_ELFDATA
+             && (ALLOW_UNALIGNED
+--- elfutils-0.115/libelf/elf32_getshdr.c
++++ elfutils-0.115/libelf/elf32_getshdr.c
+@@ -68,11 +68,12 @@ 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));
+-      /* Allocate memory for the program headers.  We know the number
++      /* Allocate memory for the section headers.  We know the number
+        of entries from the ELF header.  */
+       ElfW2(LIBELFBITS,Shdr) *shdr = elf->state.ELFW(elf,LIBELFBITS).shdr =
+       (ElfW2(LIBELFBITS,Shdr) *) malloc (size);
+@@ -94,6 +95,16 @@ elfw2(LIBELFBITS,getshdr) (scn)
+                     && (ehdr->e_shoff
+                         & (__alignof__ (ElfW2(LIBELFBITS,Shdr)) - 1)) != 0));
++        /* 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;
++          }
++
+         /* Now copy the data and at the same time convert the byte
+            order.  */
+         if (ALLOW_UNALIGNED
+--- elfutils-0.115/libelf/elf32_newphdr.c
++++ elfutils-0.115/libelf/elf32_newphdr.c
 @@ -1,5 +1,5 @@
- /* Get REL relocation information at given index.
--   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
-+   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
-    Written by Ulrich Drepper <drepper@redhat.com>, 2000.
+ /* Create new ELF program header table.
+-   Copyright (C) 1999, 2000, 2002 Red Hat, Inc.
++   Copyright (C) 1999, 2000, 2002, 2005 Red Hat, Inc.
+    Written by Ulrich Drepper <drepper@redhat.com>, 1998.
  
     This program is free software; you can redistribute it and/or modify
-@@ -38,12 +38,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))
+@@ -91,6 +91,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_HANDLE);
-@@ -60,7 +54,8 @@ gelf_getrel (data, ndx, dst)
-   if (scn->elf->class == ELFCLASS32)
++      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.115/libelf/elf32_updatefile.c
++++ elfutils-0.115/libelf/elf32_updatefile.c
+@@ -166,6 +166,9 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf
+   /* Write all the sections.  Well, only those which are modified.  */
+   if (shnum > 0)
      {
-       /* We have to convert the data.  */
--      if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
-+      if (INVALID_NDX (ndx, Elf32_Rel)
-+        || unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
++      if (unlikely (shnum > SIZE_MAX / sizeof (Elf_Scn *)))
++      return 1;
++
+       ElfW2(LIBELFBITS,Shdr) *shdr_dest;
+       Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns;
+       Elf_Scn **scns = (Elf_Scn **) alloca (shnum * sizeof (Elf_Scn *));
+@@ -470,6 +473,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.115/libelf/elf_begin.c
++++ elfutils-0.115/libelf/elf_begin.c
+@@ -122,7 +122,8 @@ get_shnum (void *map_address, unsigned c
+       if (unlikely (result == 0) && ehdr.e32->e_shoff != 0)
        {
-         __libelf_seterrno (ELF_E_INVALID_INDEX);
-         result = NULL;
-@@ -80,7 +75,8 @@ gelf_getrel (data, ndx, dst)
+-        if (offset + 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 (size_t) -1l;
+@@ -165,7 +166,8 @@ get_shnum (void *map_address, unsigned c
+       if (unlikely (result == 0) && ehdr.e64->e_shoff != 0)
+       {
+-        if (offset + 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 (size_t) -1l;
+@@ -232,6 +234,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));
+@@ -265,13 +276,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.  */
+-          elf->state.elf32.phdr
+-            = (Elf32_Phdr *) ((char *) ehdr + ehdr->e_phoff);
++          {
++            /* 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)
+           {
+@@ -340,13 +369,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.  */
+-          elf->state.elf64.phdr
+-            = (Elf64_Phdr *) ((char *) ehdr + ehdr->e_phoff);
++          {
++            /* 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.115/libelf/elf_getarsym.c
++++ elfutils-0.115/libelf/elf_getarsym.c
+@@ -146,6 +146,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.115/libelf/elf_getshstrndx.c
++++ elfutils-0.115/libelf/elf_getshstrndx.c
+@@ -92,10 +92,25 @@ elf_getshstrndx (elf, dst)
+             if (elf->map_address != NULL
+                 && elf->state.elf32.ehdr->e_ident[EI_DATA] == MY_ELFDATA
+                 && (ALLOW_UNALIGNED
+-                    || (((size_t) ((char *) elf->map_address + offset))
++                    || (((size_t) ((char *) elf->map_address
++                         + elf->start_offset + offset))
+                         & (__alignof__ (Elf32_Shdr) - 1)) == 0))
+-              /* We can directly access the memory.  */
+-              num = ((Elf32_Shdr *) (elf->map_address + offset))->sh_link;
++              {
++                /* First see whether the information in the ELF header is
++                   valid and it does not ask for too much.  */
++                if (unlikely (offset + sizeof (Elf32_Shdr)
++                              > elf->maximum_size))
++                  {
++                    /* Something is wrong.  */
++                    __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
++                    result = -1;
++                    goto out;
++                  }
++
++                /* We can directly access the memory.  */
++                num = ((Elf32_Shdr *) (elf->map_address + elf->start_offset
++                                       + offset))->sh_link;
++              }
+             else
+               {
+                 /* We avoid reading in all the section headers.  Just read
+@@ -130,10 +145,25 @@ elf_getshstrndx (elf, dst)
+             if (elf->map_address != NULL
+                 && elf->state.elf64.ehdr->e_ident[EI_DATA] == MY_ELFDATA
+                 && (ALLOW_UNALIGNED
+-                    || (((size_t) ((char *) elf->map_address + offset))
++                    || (((size_t) ((char *) elf->map_address
++                         + elf->start_offset + offset))
+                         & (__alignof__ (Elf64_Shdr) - 1)) == 0))
+-              /* We can directly access the memory.  */
+-              num = ((Elf64_Shdr *) (elf->map_address + offset))->sh_link;
++              {
++                /* First see whether the information in the ELF header is
++                   valid and it does not ask for too much.  */
++                if (unlikely (offset + sizeof (Elf64_Shdr)
++                              > elf->maximum_size))
++                  {
++                    /* Something is wrong.  */
++                    __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
++                    result = -1;
++                    goto out;
++                  }
++
++                /* We can directly access the memory.  */
++                num = ((Elf64_Shdr *) (elf->map_address
++                       + elf->start_offset + offset))->sh_link;
++              }
+             else
+               {
+                 /* We avoid reading in all the section headers.  Just read
+--- elfutils-0.115/libelf/elf_newscn.c
++++ elfutils-0.115/libelf/elf_newscn.c
+@@ -1,5 +1,5 @@
+ /* Append new section.
+-   Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
++   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005 Red Hat, Inc.
+    Written by Ulrich Drepper <drepper@redhat.com>, 1998.
+    This program is free software; you can redistribute it and/or modify
+@@ -71,13 +71,21 @@ elf_newscn (elf)
+   else
      {
-       /* 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))
+       /* We must allocate a new element.  */
+-      Elf_ScnList *newp;
++      Elf_ScnList *newp = NULL;
+       assert (elf->state.elf.scnincr > 0);
+-      newp = (Elf_ScnList *) calloc (sizeof (Elf_ScnList)
+-                                   + ((elf->state.elf.scnincr *= 2)
+-                                      * sizeof (Elf_Scn)), 1);
++      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);
+       if (newp == NULL)
        {
-         __libelf_seterrno (ELF_E_INVALID_INDEX);
-         result = NULL;
---- elfutils-0.108/libelf/gelf_getsym.c.jj     2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_getsym.c        2005-05-14 01:31:25.000000000 +0200
+         __libelf_seterrno (ELF_E_NOMEM);
+--- elfutils-0.115/libelf/gelf_getdyn.c
++++ elfutils-0.115/libelf/gelf_getdyn.c
 @@ -1,5 +1,5 @@
- /* Get symbol information from symbol table at the given index.
--   Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
-+   Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat, Inc.
-    Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+ /* Get information from dynamic table at the given index.
+-   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
++   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
+    Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     This program is free software; you can redistribute it and/or modify
-@@ -57,7 +57,8 @@ gelf_getsym (data, ndx, dst)
+@@ -60,7 +60,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_Sym) > data->d_size))
-+      if (INVALID_NDX (ndx, Elf32_Sym)
-+        || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data->d_size))
+-      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;
-@@ -86,7 +87,8 @@ gelf_getsym (data, ndx, dst)
+@@ -81,7 +82,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_Sym) > data->d_size))
-+      if (INVALID_NDX (ndx, GElf_Sym)
-+        || unlikely ((ndx + 1) * sizeof (GElf_Sym) > data->d_size))
+-      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.108/libelf/gelf_update_sym.c.jj 2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_update_sym.c    2005-05-14 01:31:25.000000000 +0200
+--- elfutils-0.115/libelf/gelf_getlib.c
++++ elfutils-0.115/libelf/gelf_getlib.c
 @@ -1,5 +1,5 @@
- /* Update symbol information in symbol table at the given index.
+ /* Get library from table at the given index.
+-   Copyright (C) 2004 Red Hat, Inc.
++   Copyright (C) 2004, 2005 Red Hat, Inc.
+    Written by Ulrich Drepper <drepper@redhat.com>, 2004.
+    This program is free software; you can redistribute it and/or modify
+@@ -53,7 +53,8 @@ gelf_getlib (data, ndx, dst)
+   /* The data is already in the correct form.  Just make sure the
+      index is OK.  */
+   GElf_Lib *result = NULL;
+-  if (unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size))
++  if (INVALID_NDX (ndx, GElf_Lib)
++      || unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size))
+     __libelf_seterrno (ELF_E_INVALID_INDEX);
+   else
+     {
+--- elfutils-0.115/libelf/gelf_getmove.c
++++ elfutils-0.115/libelf/gelf_getmove.c
+@@ -1,5 +1,5 @@
+ /* Get move structure at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     This program is free software; you can redistribute it and/or modify
-@@ -39,12 +39,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.  */
-@@ -69,7 +63,8 @@ gelf_update_sym (data, ndx, src)
-       }
+@@ -50,7 +50,8 @@ gelf_getmove (data, ndx, dst)
  
-       /* 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;
-@@ -92,7 +87,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.108/libelf/gelf_getrela.c.jj    2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_getrela.c       2005-05-14 01:31:25.000000000 +0200
+   /* 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.115/libelf/gelf_getrela.c
++++ elfutils-0.115/libelf/gelf_getrela.c
 @@ -1,5 +1,5 @@
  /* Get RELA relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
@@ -220,168 +484,98 @@ src/
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          result = NULL;
---- elfutils-0.108/libelf/gelf_update_syminfo.c.jj     2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_update_syminfo.c        2005-05-14 01:31:25.000000000 +0200
+--- elfutils-0.115/libelf/gelf_getrel.c
++++ elfutils-0.115/libelf/gelf_getrel.c
 @@ -1,5 +1,5 @@
- /* Update additional symbol information in symbol table at the given index.
+ /* Get REL relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     This program is free software; you can redistribute it and/or modify
-@@ -39,12 +39,6 @@ gelf_update_syminfo (data, ndx, src)
-   if (data == NULL)
-     return 0;
+@@ -38,12 +38,6 @@ gelf_getrel (data, ndx, dst)
+   if (data_scn == NULL)
+     return NULL;
  
 -  if (unlikely (ndx < 0))
 -    {
 -      __libelf_seterrno (ELF_E_INVALID_INDEX);
--      return 0;
+-      return NULL;
 -    }
 -
-   if (unlikely (data_scn->d.d_type != ELF_T_SYMINFO))
-     {
-       /* The type of the data better should match.  */
-@@ -60,7 +54,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))
+   if (unlikely (data_scn->d.d_type != ELF_T_REL))
      {
-       __libelf_seterrno (ELF_E_INVALID_INDEX);
-       goto out;
---- elfutils-0.108/libelf/gelf_getsyminfo.c.jj 2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_getsyminfo.c    2005-05-14 01:31:25.000000000 +0200
-@@ -1,5 +1,5 @@
- /* Get additional symbol information from symbol table at the given index.
--   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
-+   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
-    Written by Ulrich Drepper <drepper@redhat.com>, 2000.
-    This program is free software; you can redistribute it and/or modify
-@@ -51,7 +51,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_HANDLE);
+@@ -60,7 +54,8 @@ gelf_getrel (data, ndx, dst)
+   if (scn->elf->class == ELFCLASS32)
      {
-       __libelf_seterrno (ELF_E_INVALID_INDEX);
-       goto out;
---- elfutils-0.108/libelf/elf_newscn.c.jj      2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/elf_newscn.c 2005-05-14 01:38:35.000000000 +0200
-@@ -1,5 +1,5 @@
- /* Append new section.
--   Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
-+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005 Red Hat, Inc.
-    Written by Ulrich Drepper <drepper@redhat.com>, 1998.
-    This program is free software; you can redistribute it and/or modify
-@@ -71,13 +71,21 @@ elf_newscn (elf)
-   else
+       /* 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;
+@@ -80,7 +75,8 @@ gelf_getrel (data, ndx, dst)
      {
-       /* We must allocate a new element.  */
--      Elf_ScnList *newp;
-+      Elf_ScnList *newp = NULL;
-       assert (elf->state.elf.scnincr > 0);
--      newp = (Elf_ScnList *) calloc (sizeof (Elf_ScnList)
--                                   + ((elf->state.elf.scnincr *= 2)
--                                      * sizeof (Elf_Scn)), 1);
-+      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);
-       if (newp == NULL)
+       /* 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_NOMEM);
---- elfutils-0.108/libelf/gelf_update_lib.c.jj 2004-01-23 19:23:03.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_update_lib.c    2005-05-14 01:31:25.000000000 +0200
+         __libelf_seterrno (ELF_E_INVALID_INDEX);
+         result = NULL;
+--- elfutils-0.115/libelf/gelf_getsym.c
++++ elfutils-0.115/libelf/gelf_getsym.c
 @@ -1,5 +1,5 @@
- /* Update library in table at the given index.
--   Copyright (C) 2004 Red Hat, Inc.
-+   Copyright (C) 2004, 2005 Red Hat, Inc.
-    Written by Ulrich Drepper <drepper@redhat.com>, 2004.
+ /* Get symbol information from symbol table at the given index.
+-   Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
++   Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat, Inc.
+    Written by Ulrich Drepper <drepper@redhat.com>, 1999.
  
     This program is free software; you can redistribute it and/or modify
-@@ -35,12 +35,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))
-     {
-@@ -54,7 +48,8 @@ gelf_update_lib (data, ndx, src)
+@@ -57,7 +57,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;
+@@ -86,7 +87,8 @@ gelf_getsym (data, ndx, dst)
  
-   /* 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-0.108/libelf/gelf_getmove.c.jj    2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_getmove.c       2005-05-14 01:31:25.000000000 +0200
+       /* 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.115/libelf/gelf_getsyminfo.c
++++ elfutils-0.115/libelf/gelf_getsyminfo.c
 @@ -1,5 +1,5 @@
- /* Get move structure at the given index.
+ /* Get additional symbol information from symbol table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     This program is free software; you can redistribute it and/or modify
-@@ -50,7 +50,8 @@ gelf_getmove (data, ndx, dst)
+@@ -51,7 +51,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_Move) > data->d_size))
-+  if (INVALID_NDX (ndx, GElf_Move)
-+      || unlikely ((ndx + 1) * sizeof (GElf_Move) > data->d_size))
+-  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-0.108/libelf/elf32_updatefile.c.jj        2005-02-06 10:14:52.000000000 +0100
-+++ elfutils-0.108/libelf/elf32_updatefile.c   2005-05-14 00:45:03.000000000 +0200
-@@ -164,6 +164,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;
-+
-       ElfW2(LIBELFBITS,Shdr) *shdr_dest;
-       Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns;
-       Elf_Scn **scns = (Elf_Scn **) alloca (shnum * sizeof (Elf_Scn *));
-@@ -468,6 +471,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.108/libelf/gelf_getsymshndx.c.jj        2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_getsymshndx.c   2005-05-14 01:31:25.000000000 +0200
+--- elfutils-0.115/libelf/gelf_getsymshndx.c
++++ elfutils-0.115/libelf/gelf_getsymshndx.c
 @@ -1,6 +1,6 @@
  /* Get symbol information and separate section index from symbol table
     at the given index.
@@ -421,8 +615,101 @@ src/
        {
          __libelf_seterrno (ELF_E_INVALID_INDEX);
          goto out;
---- elfutils-0.108/libelf/gelf_update_move.c.jj        2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_update_move.c   2005-05-14 01:31:25.000000000 +0200
+--- elfutils-0.115/libelf/gelf_getversym.c
++++ elfutils-0.115/libelf/gelf_getversym.c
+@@ -1,5 +1,5 @@
+ /* Get symbol version information at the given index.
+-   Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
++   Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat, Inc.
+    Written by Ulrich Drepper <drepper@redhat.com>, 1999.
+    This program is free software; you can redistribute it and/or modify
+@@ -59,7 +59,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.115/libelf/gelf_update_dyn.c
++++ elfutils-0.115/libelf/gelf_update_dyn.c
+@@ -1,5 +1,5 @@
+ /* Update information in dynamic table at the given index.
+-   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
++   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
+    Written by Ulrich Drepper <drepper@redhat.com>, 2000.
+    This program is free software; you can redistribute it and/or modify
+@@ -38,12 +38,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.  */
+@@ -69,7 +63,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;
+@@ -83,7 +78,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.115/libelf/gelf_update_lib.c
++++ elfutils-0.115/libelf/gelf_update_lib.c
+@@ -1,5 +1,5 @@
+ /* Update library in table at the given index.
+-   Copyright (C) 2004 Red Hat, Inc.
++   Copyright (C) 2004, 2005 Red Hat, Inc.
+    Written by Ulrich Drepper <drepper@redhat.com>, 2004.
+    This program is free software; you can redistribute it and/or modify
+@@ -35,12 +35,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))
+     {
+@@ -54,7 +48,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-0.115/libelf/gelf_update_move.c
++++ elfutils-0.115/libelf/gelf_update_move.c
 @@ -1,5 +1,5 @@
  /* Update move structure at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
@@ -439,17 +726,17 @@ src/
        || unlikely ((ndx + 1) * sizeof (GElf_Move) > data_scn->d.d_size))
      {
        __libelf_seterrno (ELF_E_INVALID_INDEX);
---- elfutils-0.108/libelf/gelf_update_dyn.c.jj 2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_update_dyn.c    2005-05-14 01:31:25.000000000 +0200
+--- elfutils-0.115/libelf/gelf_update_rela.c
++++ elfutils-0.115/libelf/gelf_update_rela.c
 @@ -1,5 +1,5 @@
- /* Update information in dynamic table at the given index.
+ /* Update RELA relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     This program is free software; you can redistribute it and/or modify
-@@ -38,12 +38,6 @@ gelf_update_dyn (data, ndx, src)
-   if (data == NULL)
+@@ -35,12 +35,6 @@ gelf_update_rela (Elf_Data *dst, int ndx
+   if (dst == NULL)
      return 0;
  
 -  if (unlikely (ndx < 0))
@@ -458,169 +745,40 @@ src/
 -      return 0;
 -    }
 -
-   if (unlikely (data_scn->d.d_type != ELF_T_DYN))
+   if (unlikely (data_scn->d.d_type != ELF_T_RELA))
      {
        /* The type of the data better should match.  */
-@@ -69,7 +63,8 @@ gelf_update_dyn (data, ndx, src)
+@@ -68,7 +62,8 @@ gelf_update_rela (Elf_Data *dst, int ndx
        }
  
        /* Check whether we have to resize the data buffer.  */
--      if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size))
-+      if (INVALID_NDX (ndx, Elf32_Dyn)
-+        || unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size))
+-      if (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;
-@@ -83,7 +78,8 @@ gelf_update_dyn (data, ndx, src)
+@@ -84,7 +79,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_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.108/libelf/elf_begin.c.jj       2005-05-09 06:33:49.000000000 +0200
-+++ elfutils-0.108/libelf/elf_begin.c  2005-05-14 00:29:34.000000000 +0200
-@@ -220,7 +220,7 @@ file_read_elf (int fildes, void *map_add
-   /* Determine the number of sections.  */
-   scncnt = get_shnum (map_address, e_ident, fildes, offset, maxsize);
--  if (scncnt == (size_t) -1l)
-+  if (scncnt == (size_t) -1l || scncnt > SIZE_MAX / sizeof (Elf_Scn))
-     /* Could not determine the number of sections.  */
-     return NULL;
---- elfutils-0.108/libelf/gelf_getversym.c.jj  2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_getversym.c     2005-05-14 01:31:25.000000000 +0200
-@@ -1,5 +1,5 @@
- /* Get symbol version information at the given index.
--   Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
-+   Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat, Inc.
-    Written by Ulrich Drepper <drepper@redhat.com>, 1999.
-    This program is free software; you can redistribute it and/or modify
-@@ -59,7 +59,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.108/libelf/elf32_newphdr.c.jj   2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/elf32_newphdr.c      2005-05-14 01:17:53.000000000 +0200
-@@ -1,5 +1,5 @@
- /* Create new ELF program header table.
--   Copyright (C) 1999, 2000, 2002 Red Hat, Inc.
-+   Copyright (C) 1999, 2000, 2002, 2005 Red Hat, Inc.
-    Written by Ulrich Drepper <drepper@redhat.com>, 1998.
-    This program is free software; you can redistribute it and/or modify
-@@ -91,6 +91,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.108/libelf/gelf_getdyn.c.jj     2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_getdyn.c        2005-05-14 01:31:25.000000000 +0200
-@@ -1,5 +1,5 @@
- /* Get information from dynamic table at the given index.
--   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
-+   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
-    Written by Ulrich Drepper <drepper@redhat.com>, 2000.
-    This program is free software; you can redistribute it and/or modify
-@@ -60,7 +60,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;
-@@ -81,7 +82,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))
+-      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.108/libelf/elf_getarsym.c.jj    2005-02-06 10:14:52.000000000 +0100
-+++ elfutils-0.108/libelf/elf_getarsym.c       2005-05-14 01:37:47.000000000 +0200
-@@ -144,6 +144,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.108/libelf/libelfP.h.jj 2005-03-30 03:42:32.000000000 +0200
-+++ elfutils-0.108/libelf/libelfP.h    2005-05-14 01:28:47.000000000 +0200
-@@ -531,4 +531,13 @@ extern uint32_t __libelf_crc32 (uint32_t
-   } while (0)
- #endif
-+/* 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.108/libelf/gelf_getlib.c.jj     2004-01-23 19:22:56.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_getlib.c        2005-05-14 01:31:25.000000000 +0200
+--- elfutils-0.115/libelf/gelf_update_rel.c
++++ elfutils-0.115/libelf/gelf_update_rel.c
 @@ -1,5 +1,5 @@
- /* Get library from table at the given index.
--   Copyright (C) 2004 Red Hat, Inc.
-+   Copyright (C) 2004, 2005 Red Hat, Inc.
-    Written by Ulrich Drepper <drepper@redhat.com>, 2004.
-    This program is free software; you can redistribute it and/or modify
-@@ -53,7 +53,8 @@ gelf_getlib (data, ndx, dst)
-   /* The data is already in the correct form.  Just make sure the
-      index is OK.  */
-   GElf_Lib *result = NULL;
--  if (unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size))
-+  if (INVALID_NDX (ndx, GElf_Lib)
-+      || unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size))
-     __libelf_seterrno (ELF_E_INVALID_INDEX);
-   else
-     {
---- elfutils-0.108/libelf/gelf_update_symshndx.c.jj    2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_update_symshndx.c       2005-05-14 01:31:25.000000000 +0200
-@@ -1,6 +1,6 @@
- /* Update symbol information and section index in symbol table at the
-    given index.
+ /* Update REL relocation information at given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     This program is free software; you can redistribute it and/or modify
-@@ -44,12 +44,6 @@ gelf_update_symshndx (symdata, shndxdata
-   if (symdata == NULL)
+@@ -35,12 +35,6 @@ gelf_update_rel (Elf_Data *dst, int ndx,
+   if (dst == NULL)
      return 0;
  
 -  if (unlikely (ndx < 0))
@@ -629,52 +787,40 @@ src/
 -      return 0;
 -    }
 -
-   if (unlikely (symdata_scn->d.d_type != ELF_T_SYM))
+   if (unlikely (data_scn->d.d_type != ELF_T_REL))
      {
        /* The type of the data better should match.  */
-@@ -95,7 +89,8 @@ gelf_update_symshndx (symdata, shndxdata
+@@ -66,7 +60,8 @@ gelf_update_rel (Elf_Data *dst, int ndx,
        }
  
        /* Check whether we have to resize the data buffer.  */
--      if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size))
-+      if (INVALID_NDX (ndx, Elf32_Sym)
-+        || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size))
+-      if (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;
-@@ -118,7 +113,8 @@ gelf_update_symshndx (symdata, shndxdata
+@@ -81,7 +76,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_Sym) > symdata_scn->d.d_size))
-+      if (INVALID_NDX (ndx, Elf64_Sym)
-+        || unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size))
+-      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.108/libelf/elf32_getshdr.c.jj   2005-02-06 10:14:52.000000000 +0100
-+++ elfutils-0.108/libelf/elf32_getshdr.c      2005-05-14 00:32:57.000000000 +0200
-@@ -66,7 +66,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));
---- elfutils-0.108/libelf/gelf_update_rela.c.jj        2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_update_rela.c   2005-05-14 01:31:25.000000000 +0200
+--- elfutils-0.115/libelf/gelf_update_sym.c
++++ elfutils-0.115/libelf/gelf_update_sym.c
 @@ -1,5 +1,5 @@
- /* Update RELA relocation information at given index.
+ /* Update symbol information in symbol table at the given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     This program is free software; you can redistribute it and/or modify
-@@ -35,12 +35,6 @@ gelf_update_rela (Elf_Data *dst, int ndx
-   if (dst == NULL)
+@@ -39,12 +39,6 @@ gelf_update_sym (data, ndx, src)
+   if (data == NULL)
      return 0;
  
 -  if (unlikely (ndx < 0))
@@ -683,58 +829,73 @@ src/
 -      return 0;
 -    }
 -
-   if (unlikely (data_scn->d.d_type != ELF_T_RELA))
+   if (unlikely (data_scn->d.d_type != ELF_T_SYM))
      {
        /* The type of the data better should match.  */
-@@ -68,7 +62,8 @@ gelf_update_rela (Elf_Data *dst, int ndx
+@@ -69,7 +63,8 @@ gelf_update_sym (data, ndx, src)
        }
  
        /* Check whether we have to resize the data buffer.  */
--      if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size))
-+      if (INVALID_NDX (ndx, Elf32_Rela)
-+        || unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size))
+-      if (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;
-@@ -84,7 +79,8 @@ gelf_update_rela (Elf_Data *dst, int ndx
+@@ -92,7 +87,8 @@ gelf_update_sym (data, ndx, src)
    else
      {
        /* Check whether we have to resize the data buffer.  */
--      if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size))
-+      if (INVALID_NDX (ndx, Elf64_Rela)
-+        || unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size))
+-      if (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.108/libelf/gelf_update_versym.c.jj      2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_update_versym.c 2005-05-14 01:31:25.000000000 +0200
+--- elfutils-0.115/libelf/gelf_update_syminfo.c
++++ elfutils-0.115/libelf/gelf_update_syminfo.c
 @@ -1,5 +1,5 @@
- /* Update symbol version information.
--   Copyright (C) 2001, 2002 Red Hat, Inc.
-+   Copyright (C) 2001, 2002, 2005 Red Hat, Inc.
-    Written by Ulrich Drepper <drepper@redhat.com>, 2001.
+ /* Update additional symbol information in symbol table at the given index.
+-   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
++   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
+    Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     This program is free software; you can redistribute it and/or modify
-@@ -42,7 +42,7 @@ gelf_update_versym (data, ndx, src)
-   assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym));
+@@ -39,12 +39,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.  */
+@@ -60,7 +54,8 @@ gelf_update_syminfo (data, ndx, src)
+   rwlock_wrlock (scn->elf->lock);
  
    /* 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))
+-  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);
---- elfutils-0.108/libelf/gelf_update_rel.c.jj 2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/gelf_update_rel.c    2005-05-14 01:31:25.000000000 +0200
-@@ -1,5 +1,5 @@
- /* Update REL relocation information at given index.
+       goto out;
+--- elfutils-0.115/libelf/gelf_update_symshndx.c
++++ elfutils-0.115/libelf/gelf_update_symshndx.c
+@@ -1,6 +1,6 @@
+ /* Update symbol information and section index in symbol table at the
+    given index.
 -   Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
 +   Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
     Written by Ulrich Drepper <drepper@redhat.com>, 2000.
  
     This program is free software; you can redistribute it and/or modify
-@@ -35,12 +35,6 @@ gelf_update_rel (Elf_Data *dst, int ndx,
-   if (dst == NULL)
+@@ -44,12 +44,6 @@ gelf_update_symshndx (symdata, shndxdata
+   if (symdata == NULL)
      return 0;
  
 -  if (unlikely (ndx < 0))
@@ -743,31 +904,65 @@ src/
 -      return 0;
 -    }
 -
-   if (unlikely (data_scn->d.d_type != ELF_T_REL))
+   if (unlikely (symdata_scn->d.d_type != ELF_T_SYM))
      {
        /* The type of the data better should match.  */
-@@ -66,7 +60,8 @@ gelf_update_rel (Elf_Data *dst, int ndx,
+@@ -95,7 +89,8 @@ gelf_update_symshndx (symdata, shndxdata
        }
  
        /* Check whether we have to resize the data buffer.  */
--      if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
-+      if (INVALID_NDX (ndx, Elf32_Rel)
-+        || unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
+-      if (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;
-@@ -81,7 +76,8 @@ gelf_update_rel (Elf_Data *dst, int ndx,
+@@ -118,7 +113,8 @@ gelf_update_symshndx (symdata, shndxdata
    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.108/src/elflint.c.jj    2005-05-07 01:46:26.000000000 +0200
-+++ elfutils-0.108/src/elflint.c       2005-05-14 02:22:24.000000000 +0200
+       /* 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.115/libelf/gelf_update_versym.c
++++ elfutils-0.115/libelf/gelf_update_versym.c
+@@ -1,5 +1,5 @@
+ /* Update symbol version information.
+-   Copyright (C) 2001, 2002 Red Hat, Inc.
++   Copyright (C) 2001, 2002, 2005 Red Hat, Inc.
+    Written by Ulrich Drepper <drepper@redhat.com>, 2001.
+    This program is free software; you can redistribute it and/or modify
+@@ -42,7 +42,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-0.115/libelf/libelfP.h
++++ elfutils-0.115/libelf/libelfP.h
+@@ -536,4 +536,13 @@ extern uint32_t __libelf_crc32 (uint32_t
+   } while (0)
+ #endif
++/* 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.115/src/elflint.c
++++ elfutils-0.115/src/elflint.c
 @@ -111,6 +111,9 @@ static uint32_t shstrndx;
  /* Array to count references in section groups.  */
  static int *scnref;
@@ -778,7 +973,7 @@ src/
  
  int
  main (int argc, char *argv[])
-@@ -300,10 +303,17 @@ section_name (Ebl *ebl, int idx)
+@@ -300,10 +303,19 @@ section_name (Ebl *ebl, int idx)
  {
    GElf_Shdr shdr_mem;
    GElf_Shdr *shdr;
@@ -788,6 +983,8 @@ src/
 +    return "<invalid>";
  
    shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem);
++  if (shdr == NULL)
++    return "<invalid>";
  
 -  return elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
 +  ret = elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
@@ -797,7 +994,7 @@ src/
  }
  
  
-@@ -325,10 +335,6 @@ static const int valid_e_machine[] =
+@@ -325,10 +337,6 @@ static const int valid_e_machine[] =
    (sizeof (valid_e_machine) / sizeof (valid_e_machine[0]))
  
  
@@ -808,9 +1005,9 @@ src/
  static void
  check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size)
  {
-@@ -608,7 +614,8 @@ check_symtab (Ebl *ebl, GElf_Ehdr *ehdr,
-       xndxdata = NULL;
-     }
+@@ -591,7 +599,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);
@@ -818,7 +1015,7 @@ src/
      ERROR (gettext ("\
  section [%2zu] '%s': entry size is does not match ElfXX_Sym\n"),
           cnt, section_name (ebl, cnt));
-@@ -646,7 +653,7 @@ section [%2d] '%s': XINDEX for zeroth en
+@@ -629,7 +638,7 @@ section [%2d] '%s': XINDEX for zeroth en
               xndxscnidx, section_name (ebl, xndxscnidx));
      }
  
@@ -827,7 +1024,7 @@ src/
      {
        sym = gelf_getsymshndx (data, xndxdata, cnt, &sym_mem, &xndx);
        if (sym == NULL)
-@@ -664,7 +671,8 @@ section [%2d] '%s': symbol %zu: invalid 
+@@ -647,7 +656,8 @@ section [%2d] '%s': symbol %zu: invalid 
        else
        {
          name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name);
@@ -837,7 +1034,7 @@ src/
        }
  
        if (sym->st_shndx == SHN_XINDEX)
-@@ -954,7 +962,7 @@ is_rel_dyn (Ebl *ebl, GElf_Ehdr *ehdr, i
+@@ -958,7 +968,7 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e
        const GElf_Shdr *rcshdr = gelf_getshdr (scn, &rcshdr_mem);
        assert (rcshdr != NULL);
  
@@ -846,7 +1043,7 @@ src/
        {
          /* Found the dynamic section.  Look through it.  */
          Elf_Data *d = elf_getdata (scn, NULL);
-@@ -964,14 +972,17 @@ is_rel_dyn (Ebl *ebl, GElf_Ehdr *ehdr, i
+@@ -968,14 +978,17 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e
            {
              GElf_Dyn dyn_mem;
              GElf_Dyn *dyn = gelf_getdyn (d, cnt, &dyn_mem);
@@ -866,379 +1063,83 @@ src/
                    ERROR (gettext ("\
  section [%2d] '%s': DT_RELCOUNT value %d too high for this section\n"),
                           idx, section_name (ebl, idx),
-@@ -1048,7 +1059,8 @@ section [%2d] '%s': no relocations for m
-       }
-     }
--  if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT))
-+  size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT);
-+  if (shdr->sh_entsize != sh_entsize)
-     ERROR (gettext ("\
- section [%2d] '%s': section entry size does not match ElfXX_Rela\n"),
-          idx, section_name (ebl, idx));
-@@ -1058,7 +1070,7 @@ section [%2d] '%s': section entry size d
-   GElf_Shdr *symshdr = gelf_getshdr (symscn, &symshdr_mem);
-   Elf_Data *symdata = elf_getdata (symscn, NULL);
--  for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
-+  for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
-     {
-       GElf_Rela rela_mem;
-       GElf_Rela *rela;
-@@ -1183,7 +1195,8 @@ section [%2d] '%s': no relocations for m
+@@ -1050,7 +1063,8 @@ section [%2d] '%s': no relocations for m
        }
      }
  
--  if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT))
-+  size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT);
+-  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 ("\
+     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"),
-          idx, section_name (ebl, idx));
-@@ -1193,7 +1206,7 @@ section [%2d] '%s': section entry size d
-   GElf_Shdr *symshdr = gelf_getshdr (symscn, &symshdr_mem);
+@@ -1258,7 +1272,8 @@ check_rela (Ebl *ebl, GElf_Ehdr *ehdr, G
    Elf_Data *symdata = elf_getdata (symscn, NULL);
+   enum load_state state = state_undecided;
  
--  for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
-+  for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt)
-     {
-       GElf_Rel rel_mem;
-       GElf_Rel *rel;
-@@ -1341,7 +1354,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));
-@@ -1351,7 +1365,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;
-@@ -1502,6 +1516,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 ("\
-@@ -1530,6 +1546,12 @@ section [%2d] '%s': extended section ind
-     }
-   data = elf_getdata (scn, 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"));
-@@ -1613,7 +1635,7 @@ section [%2d] '%s': hash table section i
-          idx, section_name (ebl, idx), (long int) shdr->sh_size,
-          (long int) ((2 + nbucket + nchain) * shdr->sh_entsize));
--  if (symshdr != NULL)
-+  if (symshdr != NULL && symshdr->sh_entsize)
-     {
-       size_t symsize = symshdr->sh_size / symshdr->sh_entsize;
-       size_t cnt;
-@@ -1910,8 +1932,10 @@ section [%2d] '%s' refers in sh_link to 
-       return;
-     }
--  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.108/libelf/elf32_getphdr.c.jj   2005-02-06 10:14:52.000000000 +0100
-+++ elfutils-0.108/libelf/elf32_getphdr.c      2005-05-17 16:53:41.000000000 +0200
-@@ -80,6 +80,16 @@ elfw2(LIBELFBITS,getphdr) (elf)
-       if (elf->map_address != NULL)
-       {
-+        /* First see whether the information in the ELF header is
-+           valid and it does not ask for too much.  */
-+        if (unlikely (ehdr->e_phoff >= elf->maximum_size)
-+            || unlikely (ehdr->e_phoff + size > elf->maximum_size))
-+          {
-+            /* Something is wrong.  */
-+            __libelf_seterrno (ELF_E_INVALID_PHDR);
-+            goto out;
-+          }
-+
-         /* All the data is already mapped.  Use it.  */
-         if (ehdr->e_ident[EI_DATA] == MY_ELFDATA
-             && (ALLOW_UNALIGNED
---- elfutils-0.108/libelf/elf_getshstrndx.c.jj 2004-01-05 21:45:05.000000000 +0100
-+++ elfutils-0.108/libelf/elf_getshstrndx.c    2005-05-17 15:42:32.000000000 +0200
-@@ -1,5 +1,5 @@
- /* Return section index of section header string table.
--   Copyright (C) 2002 Red Hat, Inc.
-+   Copyright (C) 2002, 2005 Red Hat, Inc.
-    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
-    This program is free software; you can redistribute it and/or modify
-@@ -90,10 +90,25 @@ elf_getshstrndx (elf, dst)
-             if (elf->map_address != NULL
-                 && elf->state.elf32.ehdr->e_ident[EI_DATA] == MY_ELFDATA
-                 && (ALLOW_UNALIGNED
--                    || (((size_t) ((char *) elf->map_address + offset))
-+                    || (((size_t) ((char *) elf->map_address
-+                         + elf->start_offset + offset))
-                         & (__alignof__ (Elf32_Shdr) - 1)) == 0))
--              /* We can directly access the memory.  */
--              num = ((Elf32_Shdr *) (elf->map_address + offset))->sh_link;
-+              {
-+                /* First see whether the information in the ELF header is
-+                   valid and it does not ask for too much.  */
-+                if (unlikely (offset + sizeof (Elf32_Shdr)
-+                              > elf->maximum_size))
-+                  {
-+                    /* Something is wrong.  */
-+                    __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
-+                    result = -1;
-+                    goto out;
-+                  }
-+
-+                /* We can directly access the memory.  */
-+                num = ((Elf32_Shdr *) (elf->map_address + elf->start_offset
-+                       + offset))->sh_link;
-+              }
-             else
-               {
-                 /* We avoid reading in all the section headers.  Just read
-@@ -129,10 +144,25 @@ elf_getshstrndx (elf, dst)
-             if (elf->map_address != NULL
-                 && elf->state.elf64.ehdr->e_ident[EI_DATA] == MY_ELFDATA
-                 && (ALLOW_UNALIGNED
--                    || (((size_t) ((char *) elf->map_address + offset))
-+                    || (((size_t) ((char *) elf->map_address
-+                         + elf->start_offset + offset))
-                         & (__alignof__ (Elf64_Shdr) - 1)) == 0))
--              /* We can directly access the memory.  */
--              num = ((Elf64_Shdr *) (elf->map_address + offset))->sh_link;
-+              {
-+                /* First see whether the information in the ELF header is
-+                   valid and it does not ask for too much.  */
-+                if (unlikely (offset + sizeof (Elf64_Shdr)
-+                              > elf->maximum_size))
-+                  {
-+                    /* Something is wrong.  */
-+                    __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
-+                    result = -1;
-+                    goto out;
-+                  }
-+
-+                /* We can directly access the memory.  */
-+                num = ((Elf64_Shdr *) (elf->map_address
-+                       + elf->start_offset + offset))->sh_link;
-+              }
-             else
-               {
-                 /* We avoid reading in all the section headers.  Just read
---- elfutils-0.108/libelf/elf32_getshdr.c.jj   2005-05-14 00:32:57.000000000 +0200
-+++ elfutils-0.108/libelf/elf32_getshdr.c      2005-05-17 15:27:52.000000000 +0200
-@@ -71,7 +71,7 @@ elfw2(LIBELFBITS,getshdr) (scn)
-       goto out;
-       size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr));
--      /* Allocate memory for the program headers.  We know the number
-+      /* Allocate memory for the section headers.  We know the number
-        of entries from the ELF header.  */
-       ElfW2(LIBELFBITS,Shdr) *shdr = elf->state.ELFW(elf,LIBELFBITS).shdr =
-       (ElfW2(LIBELFBITS,Shdr) *) malloc (size);
-@@ -93,6 +93,16 @@ elfw2(LIBELFBITS,getshdr) (scn)
-                     && (ehdr->e_shoff
-                         & (__alignof__ (ElfW2(LIBELFBITS,Shdr)) - 1)) != 0));
-+        /* 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;
-+          }
-+
-         /* Now copy the data and at the same time convert the byte
-            order.  */
-         if (ALLOW_UNALIGNED
---- elfutils-0.108/libelf/elf_begin.c.jj       2005-05-17 16:18:51.000000000 +0200
-+++ elfutils-0.108/libelf/elf_begin.c  2005-05-17 17:31:37.000000000 +0200
-@@ -77,7 +77,11 @@ get_shnum (void *map_address, unsigned c
-         || (((size_t) ((char *) map_address + offset))
-             & ((is32 ? __alignof__ (Elf32_Ehdr) : __alignof__ (Elf64_Ehdr))
-                - 1)) == 0))
--    ehdr.p = (char *) map_address + offset;
-+    {
-+      ehdr.p = (char *) map_address + offset;
-+      if (maxsize < (is32 ? sizeof (Elf32_Ehdr) : sizeof (Elf64_Ehdr)))
-+      return (size_t) -1l;
-+    }
-   else
-     {
-       /* We have to read the data from the file.  */
-@@ -111,7 +115,8 @@ get_shnum (void *map_address, unsigned c
-       if (unlikely (result == 0) && ehdr.e32->e_shoff != 0)
-       {
--        if (offset + 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 (size_t) -1l;
-@@ -147,7 +152,8 @@ get_shnum (void *map_address, unsigned c
-       if (unlikely (result == 0) && ehdr.e64->e_shoff != 0)
-       {
--        if (offset + 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 (size_t) -1l;
-@@ -220,10 +226,19 @@ file_read_elf (int fildes, void *map_add
-   /* Determine the number of sections.  */
-   scncnt = get_shnum (map_address, e_ident, fildes, offset, maxsize);
--  if (scncnt == (size_t) -1l || scncnt > SIZE_MAX / sizeof (Elf_Scn))
-+  if (scncnt == (size_t) -1l)
-     /* 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 = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent,
-                     ELF_K_ELF, scncnt * sizeof (Elf_Scn));
-@@ -255,15 +270,31 @@ file_read_elf (int fildes, void *map_add
-         /* We can use the mmapped memory.  */
-         elf->state.elf32.ehdr =
-           (Elf32_Ehdr *) ((char *) map_address + offset);
-+        if (unlikely (elf->state.elf32.ehdr->e_shoff >= maxsize)
-+            || unlikely (elf->state.elf32.ehdr->e_shoff
-+                         + scncnt * sizeof (Elf32_Shdr) > maxsize))
-+          {
-+          free_and_out:
-+            __libelf_seterrno (ELF_E_INVALID_FILE);
-+            free (elf);
-+            return NULL;
-+          }
-         elf->state.elf32.shdr =
-           (Elf32_Shdr *) ((char *) map_address + offset
-                           + elf->state.elf32.ehdr->e_shoff);
-         if (elf->state.elf32.ehdr->e_phnum)
--          /* Assign a value only if there really is a program
--             header.  Otherwise the value remains NULL.  */
--          elf->state.elf32.phdr
--            = (Elf32_Phdr *) ((char *) map_address + offset
--                              + elf->state.elf32.ehdr->e_phoff);
-+          {
-+            /* Assign a value only if there really is a program
-+               header.  Otherwise the value remains NULL.  */
-+            if (unlikely (elf->state.elf32.ehdr->e_phoff >= maxsize)
-+                || unlikely (elf->state.elf32.ehdr->e_phoff
-+                             + elf->state.elf32.ehdr->e_phnum
-+                             * sizeof (Elf32_Phdr) > maxsize))
-+              goto free_and_out;
-+            elf->state.elf32.phdr
-+              = (Elf32_Phdr *) ((char *) map_address + offset
-+                                + elf->state.elf32.ehdr->e_phoff);
-+          }
-         for (size_t cnt = 0; cnt < scncnt; ++cnt)
-           {
-@@ -285,8 +316,7 @@ file_read_elf (int fildes, void *map_add
-                    sizeof (Elf32_Ehdr), offset) != sizeof (Elf32_Ehdr))
-           {
-             /* We must be able to read the ELF header.  */
--            __libelf_seterrno (ELF_E_INVALID_FILE);
--            return NULL;
-+            goto free_and_out;
-           }
+-  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);
+@@ -1307,7 +1322,8 @@ check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GE
+   Elf_Data *symdata = elf_getdata (symscn, NULL);
+   enum load_state state = state_undecided;
  
-         if (e_ident[EI_DATA] != MY_ELFDATA)
-@@ -340,15 +370,26 @@ file_read_elf (int fildes, void *map_add
-         /* We can use the mmapped memory.  */
-         elf->state.elf64.ehdr =
-           (Elf64_Ehdr *) ((char *) map_address + offset);
-+        if (unlikely (elf->state.elf64.ehdr->e_shoff >= maxsize)
-+            || unlikely (elf->state.elf64.ehdr->e_shoff
-+                         + scncnt * sizeof (Elf64_Shdr) > maxsize))
-+          goto free_and_out;
-         elf->state.elf64.shdr =
-           (Elf64_Shdr *) ((char *) map_address + offset
-                           + elf->state.elf64.ehdr->e_shoff);
-         if (elf->state.elf64.ehdr->e_phnum)
--          /* Assign a value only if there really is a program
--             header.  Otherwise the value remains NULL.  */
--          elf->state.elf64.phdr
--            = (Elf64_Phdr *) ((char *) map_address + offset
--                              + elf->state.elf64.ehdr->e_phoff);
-+          {
-+            /* Assign a value only if there really is a program
-+               header.  Otherwise the value remains NULL.  */
-+            if (unlikely (elf->state.elf64.ehdr->e_phoff >= maxsize)
-+                || unlikely (elf->state.elf64.ehdr->e_phoff
-+                             + elf->state.elf64.ehdr->e_phnum
-+                             * sizeof (Elf64_Phdr) > maxsize))
-+              goto free_and_out;
-+            elf->state.elf64.phdr
-+              = (Elf64_Phdr *) ((char *) map_address + offset
-+                                + elf->state.elf64.ehdr->e_phoff);
-+          }
+-  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);
+@@ -1408,7 +1424,8 @@ section [%2d] '%s': referenced as string
+          shdr->sh_link, section_name (ebl, shdr->sh_link),
+          idx, section_name (ebl, idx));
  
-         for (size_t cnt = 0; cnt < scncnt; ++cnt)
-           {
-@@ -370,8 +411,7 @@ file_read_elf (int fildes, void *map_add
-                    sizeof (Elf64_Ehdr), offset) != sizeof (Elf64_Ehdr))
-           {
-             /* We must be able to read the ELF header.  */
--            __libelf_seterrno (ELF_E_INVALID_FILE);
--            return NULL;
-+            goto free_and_out;
-           }
+-  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));
+@@ -1418,7 +1435,7 @@ section [%2d] '%s': section entry size d
+          idx, section_name (ebl, idx));
  
-         if (e_ident[EI_DATA] != MY_ELFDATA)
---- elfutils-0.108/src/elflint.c.jj    2005-05-14 02:22:24.000000000 +0200
-+++ elfutils-0.108/src/elflint.c       2005-05-17 18:02:00.000000000 +0200
-@@ -309,6 +309,8 @@ section_name (Ebl *ebl, int idx)
-     return "<invalid>";
+   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);
+@@ -1559,6 +1576,8 @@ section [%2d] '%s': entry size does not 
+          idx, section_name (ebl, idx));
  
-   shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem);
-+  if (shdr == NULL)
-+    return "<invalid>";
+   if (symshdr != NULL
++      && shdr->sh_entsize
++      && symshdr->sh_entsize
+       && (shdr->sh_size / shdr->sh_entsize
+         < symshdr->sh_size / symshdr->sh_entsize))
+     ERROR (gettext ("\
+@@ -1585,6 +1604,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"));
+@@ -1665,23 +1690,30 @@ section [%2d] '%s': hash table section i
+          idx, section_name (ebl, idx), (long int) shdr->sh_size,
+          (long int) ((2 + nbucket + nchain) * shdr->sh_entsize));
  
-   ret = elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
-   if (ret == NULL)
-@@ -1639,19 +1641,26 @@ section [%2d] '%s': hash table section i
+-  if (symshdr != NULL)
++  if (symshdr != NULL && symshdr->sh_entsize)
      {
        size_t symsize = symshdr->sh_size / symshdr->sh_entsize;
        size_t cnt;
@@ -1259,26 +1160,274 @@ src/
  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] >= symsize)
-+      if (buf >= end)
-+        return;
-+      else if (*buf++ >= symsize)
-         ERROR (gettext ("\
- section [%2d] '%s': hash chain reference %zu out of bounds\n"),
-                idx, section_name (ebl, idx), cnt - 2 - nbucket);
-@@ -2311,6 +2320,8 @@ phdr[%d]: no note entries defined for th
-     return;
+       for (; cnt < 2 + nbucket + nchain; ++cnt)
+-      if (((Elf32_Word *) data->d_buf)[cnt] >= symsize)
++      if (buf >= end)
++        return;
++      else if (*buf++ >= symsize)
+         ERROR (gettext ("\
+ section [%2d] '%s': hash chain reference %zu out of bounds\n"),
+                idx, section_name (ebl, idx), cnt - 2 - nbucket);
+@@ -2023,8 +2055,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),
+@@ -2928,6 +2961,8 @@ phdr[%d]: no note entries defined for th
+     return;
+   char *notemem = gelf_rawchunk (ebl->elf, phdr->p_offset, phdr->p_filesz);
++  if (notemem == NULL)
++    return;
+   /* ELF64 files often use note section entries in the 32-bit format.
+      The p_align field is set to 8 in case the 64-bit format is used.
+--- elfutils-0.115/src/readelf.c
++++ elfutils-0.115/src/readelf.c
+@@ -947,6 +947,7 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G
+   GElf_Shdr *symshdr;
+   Elf_Data *symdata;
+   GElf_Sym sym_mem;
++  GElf_Sym *sym;
+   size_t cnt;
+   size_t shstrndx;
+@@ -966,6 +967,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G
+     error (EXIT_FAILURE, 0,
+          gettext ("cannot get section header string table index"));
++  sym = gelf_getsym (symdata, shdr->sh_info, &sym_mem);
++
+   grpref = (Elf32_Word *) data->d_buf;
+   printf ((grpref[0] & GRP_COMDAT)
+@@ -980,8 +983,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 ("<INVALID SYMBOL>"),
+         data->d_size / sizeof (Elf32_Word) - 1);
+@@ -1135,7 +1138,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;
+@@ -1150,6 +1154,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",
+                   "\
+@@ -1159,9 +1168,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)
+@@ -1656,7 +1663,8 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
+   unsigned int cnt;
+   Elf32_Word verneed_stridx = 0;
+   Elf32_Word verdef_stridx = 0;
+-  GElf_Shdr glink;
++  GElf_Shdr glink_mem;
++  GElf_Shdr *glink;
+   size_t shstrndx;
+   /* Get the data of the section.  */
+@@ -1701,6 +1709,11 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
+     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));
++
+   /* Now we can compute the number of entries in the section.  */
+   nsyms = data->d_size / (class == ELFCLASS32
+                         ? sizeof (Elf32_Sym) : sizeof (Elf64_Sym));
+@@ -1715,9 +1728,7 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
+                   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 ("\
+@@ -1956,7 +1967,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",
+                   "\
+@@ -1967,9 +1984,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; )
+@@ -2022,8 +2037,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",
+                   "\
+@@ -2035,9 +2056,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; )
+@@ -2086,7 +2105,6 @@ static void
+ handle_versym (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
+ {
+   int class = gelf_getclass (ebl->elf);
+-  GElf_Shdr glink;
+   const char **vername;
+   const char **filename;
+@@ -2312,6 +2330,13 @@ 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.  */
+   printf (ngettext ("\
+ \nVersion symbols section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'",
+@@ -2324,9 +2349,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)
+@@ -2402,7 +2425,6 @@ handle_hash (Ebl *ebl)
+         Elf32_Word maxlength = 0;
+         Elf32_Word nsyms = 0;
+         uint64_t nzero_counts = 0;
+-        GElf_Shdr glink;
+         if (data == NULL)
+           {
+@@ -2411,6 +2433,17 @@ handle_hash (Ebl *ebl)
+             continue;
+           }
++        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));
++            continue;
++          }
++
+         nbucket = ((Elf32_Word *) data->d_buf)[0];
+         nchain = ((Elf32_Word *) data->d_buf)[1];
+         bucket = &((Elf32_Word *) data->d_buf)[2];
+@@ -2428,10 +2461,7 @@ handle_hash (Ebl *ebl)
+                 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));
+         lengths = (uint32_t *) xcalloc (nbucket, sizeof (uint32_t));
  
-   char *notemem = gelf_rawchunk (ebl->elf, phdr->p_offset, phdr->p_filesz);
-+  if (notemem == NULL)
-+    return;
+@@ -3531,6 +3561,16 @@ print_debug_aranges_section (Ebl *ebl __
+       return;
+     }
  
-   /* ELF64 files often use note section entries in the 32-bit format.
-      The p_align field is set to 8 in case the 64-bit format is used.
-
---- elfutils/src/strip.c
-+++ elfutils/src/strip.c
++  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.115/src/strip.c
++++ elfutils-0.115/src/strip.c
 @@ -400,6 +400,7 @@ handle_elf (int fd, Elf *elf, const char
    Elf_Data debuglink_crc_data;
    bool any_symtab_changes = false;
@@ -1287,7 +1436,7 @@ src/
  
    /* Create the full name of the file.  */
    if (prefix != NULL)
-@@ -531,6 +532,11 @@ handle_elf (int fd, Elf *elf, const char
+@@ -530,6 +531,11 @@ handle_elf (int fd, Elf *elf, const char
        goto fail_close;
      }
  
@@ -1299,7 +1448,7 @@ src/
    /* 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.
-@@ -552,7 +558,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -551,7 +557,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).  */
@@ -1308,7 +1457,7 @@ src/
  
        shdr_info[cnt].scn = scn;
  
-@@ -565,6 +571,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -564,6 +570,7 @@ handle_elf (int fd, Elf *elf, const char
                                        shdr_info[cnt].shdr.sh_name);
        if (shdr_info[cnt].name == NULL)
        {
@@ -1316,7 +1465,7 @@ src/
          error (0, 0, gettext ("illformed file '%s'"), fname);
          goto fail_close;
        }
-@@ -574,6 +581,8 @@ handle_elf (int fd, Elf *elf, const char
+@@ -573,6 +580,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;
@@ -1325,7 +1474,7 @@ src/
  
        /* Sections in files other than relocatable object files which
         are not loaded can be freely moved by us.  In relocatable
-@@ -586,7 +595,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -585,7 +594,7 @@ handle_elf (int fd, Elf *elf, const char
         appropriate reference.  */
        if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX))
        {
@@ -1334,7 +1483,7 @@ src/
          shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt;
        }
        else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP))
-@@ -605,7 +614,12 @@ handle_elf (int fd, Elf *elf, const char
+@@ -602,7 +611,12 @@ handle_elf (int fd, Elf *elf, const char
          for (inner = 1;
               inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word);
               ++inner)
@@ -1348,7 +1497,7 @@ src/
  
          if (inner == 1 || (inner == 2 && (grpref[0] & GRP_COMDAT) == 0))
            /* If the section group contains only one element and this
-@@ -616,7 +630,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -613,7 +627,7 @@ handle_elf (int fd, Elf *elf, const char
        }
        else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym))
        {
@@ -1357,7 +1506,7 @@ src/
          shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt;
        }
  
-@@ -624,7 +638,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -621,7 +635,7 @@ handle_elf (int fd, Elf *elf, const char
         discarded right away.  */
        if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0)
        {
@@ -1366,7 +1515,7 @@ src/
  
          if (shdr_info[shdr_info[cnt].group_idx].idx == 0)
            {
-@@ -700,10 +714,14 @@ handle_elf (int fd, Elf *elf, const char
+@@ -696,10 +710,14 @@ 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.  */
@@ -1385,7 +1534,7 @@ src/
            }
  
          if (shdr_info[cnt].idx == 1)
-@@ -733,7 +751,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -725,7 +743,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)
                    {
@@ -1394,7 +1543,7 @@ src/
  
                      shdr_info[shdr_info[cnt].symtab_idx].data
                        = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
-@@ -773,6 +791,9 @@ handle_elf (int fd, Elf *elf, const char
+@@ -765,6 +783,9 @@ handle_elf (int fd, Elf *elf, const char
                      else if (scnidx == SHN_XINDEX)
                        scnidx = xndx;
  
@@ -1404,7 +1553,7 @@ src/
                      if (shdr_info[scnidx].idx == 0)
                        {
                          /* Mark this section as used.  */
-@@ -804,11 +825,15 @@ handle_elf (int fd, Elf *elf, const char
+@@ -796,11 +817,15 @@ handle_elf (int fd, Elf *elf, const char
                }
  
              /* Handle references through sh_info.  */
@@ -1424,7 +1573,7 @@ src/
                }
  
              /* Mark the section as investigated.  */
-@@ -911,7 +936,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -900,7 +925,7 @@ handle_elf (int fd, Elf *elf, const char
          error (EXIT_FAILURE, 0, gettext ("while generating output file: %s"),
                 elf_errmsg (-1));
  
@@ -1433,7 +1582,7 @@ src/
  
        /* Add this name to the section header string table.  */
        shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
-@@ -951,7 +976,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -937,7 +962,7 @@ handle_elf (int fd, Elf *elf, const char
        error (EXIT_FAILURE, 0,
               gettext ("while create section header section: %s"),
               elf_errmsg (-1));
@@ -1442,7 +1591,7 @@ src/
  
        shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn);
        if (shdr_info[cnt].data == NULL)
-@@ -982,7 +1007,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -968,7 +993,7 @@ handle_elf (int fd, Elf *elf, const char
      }
  
    /* Index of the section header table in the shdr_info array.  */
@@ -1451,7 +1600,7 @@ src/
  
    /* Add the section header string table section name.  */
    shdr_info[cnt].se = ebl_strtabadd (shst, ".shstrtab", 10);
-@@ -1007,7 +1032,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -993,7 +1018,7 @@ handle_elf (int fd, Elf *elf, const char
      error (EXIT_FAILURE, 0,
           gettext ("while create section header section: %s"),
           elf_errmsg (-1));
@@ -1460,7 +1609,7 @@ src/
  
    /* Finalize the string table and fill in the correct indices in the
       section headers.  */
-@@ -1097,21 +1122,21 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1083,21 +1108,21 @@ handle_elf (int fd, Elf *elf, const char
                    shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
                                             NULL);
  
@@ -1487,7 +1636,7 @@ src/
                  }
  
                shdr_info[cnt].newsymidx
-@@ -1165,7 +1190,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1151,7 +1176,7 @@ handle_elf (int fd, Elf *elf, const char
                      sec = shdr_info[sym->st_shndx].idx;
                    else
                      {
@@ -1496,7 +1645,7 @@ src/
  
                        sec = shdr_info[xshndx].idx;
                      }
-@@ -1186,7 +1211,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1172,7 +1197,7 @@ handle_elf (int fd, Elf *elf, const char
                            nxshndx = sec;
                          }
  
@@ -1505,7 +1654,7 @@ src/
  
                        if ((inner != destidx || nshndx != sym->st_shndx
                             || (shndxdata != NULL && nxshndx != xshndx))
-@@ -1209,7 +1234,7 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1195,7 +1220,7 @@ handle_elf (int fd, Elf *elf, const char
                    else
                      /* This is a section symbol for a section which has
                         been removed.  */
@@ -1514,7 +1663,7 @@ src/
                  }
  
                if (destidx != inner)
-@@ -1373,11 +1398,11 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1359,11 +1384,11 @@ handle_elf (int fd, Elf *elf, const char
                    {
                      GElf_Sym sym_mem;
                      GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
@@ -1528,7 +1677,7 @@ src/
                      size_t hidx = elf_hash (name) % nbucket;
  
                      if (bucket[hidx] == 0)
-@@ -1396,8 +1421,8 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1382,8 +1407,8 @@ handle_elf (int fd, Elf *elf, const char
              else
                {
                  /* Alpha and S390 64-bit use 64-bit SHT_HASH entries.  */
@@ -1539,7 +1688,7 @@ src/
  
                  Elf64_Xword *bucket = (Elf64_Xword *) hashd->d_buf;
  
-@@ -1430,11 +1455,11 @@ handle_elf (int fd, Elf *elf, const char
+@@ -1416,11 +1441,11 @@ handle_elf (int fd, Elf *elf, const char
                    {
                      GElf_Sym sym_mem;
                      GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem);
@@ -1553,237 +1702,3 @@ src/
                      size_t hidx = elf_hash (name) % nbucket;
  
                      if (bucket[hidx] == 0)
---- elfutils/src/readelf.c
-+++ elfutils/src/readelf.c
-@@ -947,6 +947,7 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G
-   GElf_Shdr *symshdr;
-   Elf_Data *symdata;
-   GElf_Sym sym_mem;
-+  GElf_Sym *sym;
-   size_t cnt;
-   size_t shstrndx;
-@@ -966,6 +967,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G
-     error (EXIT_FAILURE, 0,
-          gettext ("cannot get section header string table index"));
-+  sym = gelf_getsym (symdata, shdr->sh_info, &sym_mem);
-+
-   grpref = (Elf32_Word *) data->d_buf;
-   printf ((grpref[0] & GRP_COMDAT)
-@@ -980,8 +983,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 ("<INVALID SYMBOL>"),
-         data->d_size / sizeof (Elf32_Word) - 1);
-@@ -1135,7 +1138,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;
-@@ -1150,6 +1154,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",
-                   "\
-@@ -1159,9 +1168,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)
-@@ -1656,7 +1663,8 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
-   unsigned int cnt;
-   Elf32_Word verneed_stridx = 0;
-   Elf32_Word verdef_stridx = 0;
--  GElf_Shdr glink;
-+  GElf_Shdr glink_mem;
-+  GElf_Shdr *glink;
-   size_t shstrndx;
-   /* Get the data of the section.  */
-@@ -1701,6 +1709,11 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
-     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));
-+
-   /* Now we can compute the number of entries in the section.  */
-   nsyms = data->d_size / (class == ELFCLASS32
-                         ? sizeof (Elf32_Sym) : sizeof (Elf64_Sym));
-@@ -1715,9 +1728,7 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G
-                   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 ("\
-@@ -1945,7 +1956,8 @@ handle_verneed (Ebl *ebl, Elf_Scn *scn, 
- {
-   Elf_Data *data;
-   int class = gelf_getclass (ebl->elf);
--  GElf_Shdr glink;
-+  GElf_Shdr glink_mem;
-+  GElf_Shdr *glink;
-   int cnt;
-   unsigned int offset;
-   size_t shstrndx;
-@@ -1960,6 +1972,11 @@ handle_verneed (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 ("\
- \nVersion needs section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'\n",
-                   "\
-@@ -1970,9 +1987,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));
-   offset = 0;
-   for (cnt = shdr->sh_info; --cnt >= 0; )
-@@ -2022,7 +2037,8 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G
- {
-   Elf_Data *data;
-   int class = gelf_getclass (ebl->elf);
--  GElf_Shdr glink;
-+  GElf_Shdr glink_mem;
-+  GElf_Shdr *glink;
-   int cnt;
-   unsigned int offset;
-   size_t shstrndx;
-@@ -2037,6 +2053,11 @@ handle_verdef (Ebl *ebl, Elf_Scn *scn, G
-     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 ("\
- \nVersion definition section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 "  Offset: %#08" PRIx64 "  Link to section: [%2u] '%s'\n",
-                   "\
-@@ -2048,9 +2069,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));
-   offset = 0;
-   for (cnt = shdr->sh_info; --cnt >= 0; )
-@@ -2106,7 +2125,8 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G
-   Elf_Data *data;
-   int class = gelf_getclass (ebl->elf);
-   Elf_Scn *verscn;
--  GElf_Shdr glink;
-+  GElf_Shdr glink_mem;
-+  GElf_Shdr *glink;
-   Elf_Scn *defscn;
-   Elf_Scn *needscn;
-   const char **vername;
-@@ -2125,6 +2145,11 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G
-     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));
-+
-   /* We have to find the version definition section and extract the
-      version names.  */
-   defscn = NULL;
-@@ -2347,9 +2372,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 (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt)
-@@ -2425,7 +2448,8 @@ handle_hash (Ebl *ebl)
-         Elf32_Word maxlength = 0;
-         Elf32_Word nsyms = 0;
-         uint64_t nzero_counts = 0;
--        GElf_Shdr glink;
-+        GElf_Shdr glink_mem;
-+        GElf_Shdr *glink;
-         if (data == NULL)
-           {
-@@ -2434,6 +2458,16 @@ handle_hash (Ebl *ebl)
-             continue;
-           }
-+
-+        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));
-+            continue;
-+          }
-+
-         nbucket = ((Elf32_Word *) data->d_buf)[0];
-         nchain = ((Elf32_Word *) data->d_buf)[1];
-         bucket = &((Elf32_Word *) data->d_buf)[2];
-@@ -2451,10 +2485,7 @@ handle_hash (Ebl *ebl)
-                 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));
-         lengths = (uint32_t *) xcalloc (nbucket, sizeof (uint32_t));
This page took 0.319042 seconds and 4 git commands to generate.