diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index bd73909..0000000 --- a/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -elfutils-0.106.tar.gz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0da9d88 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +elfutils-0.137.tar.gz diff --git a/Makefile b/Makefile deleted file mode 100644 index 33e0e36..0000000 --- a/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# Makefile for source rpm: elfutils -# $Id$ -NAME := elfutils -SPECFILE = $(firstword $(wildcard *.spec)) - -include ../common/Makefile.common diff --git a/elfutils-0.137-fixes.patch b/elfutils-0.137-fixes.patch new file mode 100644 index 0000000..d357273 --- /dev/null +++ b/elfutils-0.137-fixes.patch @@ -0,0 +1,174 @@ +--- elfutils-0.137/libdwfl/ChangeLog ++++ elfutils-0.137/libdwfl/ChangeLog +@@ -1,3 +1,17 @@ ++2008-09-29 Roland McGrath ++ ++ * segment.c (insert): Must realloc DWFL->lookup_module here too. ++ (dwfl_report_segment): Clear DWFL->lookup_module before insert calls. ++ ++2008-08-28 Roland McGrath ++ ++ * segment.c (reify_segments): Fix last change. ++ ++2008-08-27 Roland McGrath ++ ++ * linux-proc-maps.c (read_proc_memory): Return 0 for EINVAL or EPERM ++ failure from pread64. ++ + 2008-08-26 Roland McGrath + + * segment.c (reify_segments): Insert a trailing segment for a module +--- elfutils-0.137/libdwfl/linux-proc-maps.c ++++ elfutils-0.137/libdwfl/linux-proc-maps.c +@@ -267,6 +267,9 @@ read_proc_memory (void *arg, void *data, + { + const int fd = *(const int *) arg; + ssize_t nread = pread64 (fd, data, maxread, (off64_t) address); ++ /* Some kernels don't actually let us do this read, ignore those errors. */ ++ if (nread < 0 && (errno == EINVAL || errno == EPERM)) ++ return 0; + if (nread > 0 && (size_t) nread < minread) + nread = 0; + return nread; +--- elfutils-0.137/libdwfl/segment.c ++++ elfutils-0.137/libdwfl/segment.c +@@ -83,12 +83,26 @@ insert (Dwfl *dwfl, size_t i, GElf_Addr + int *nsegndx = realloc (dwfl->lookup_segndx, sizeof nsegndx[0] * n); + if (unlikely (nsegndx == NULL)) + { +- free (naddr); ++ if (naddr != dwfl->lookup_addr) ++ free (naddr); + return true; + } + dwfl->lookup_alloc = n; + dwfl->lookup_addr = naddr; + dwfl->lookup_segndx = nsegndx; ++ ++ if (dwfl->lookup_module != NULL) ++ { ++ /* Make sure this array is big enough too. */ ++ Dwfl_Module **old = dwfl->lookup_module; ++ dwfl->lookup_module = realloc (dwfl->lookup_module, ++ sizeof dwfl->lookup_module[0] * n); ++ if (unlikely (dwfl->lookup_module == NULL)) ++ { ++ free (old); ++ return true; ++ } ++ } + } + + if (unlikely (i < dwfl->lookup_elts)) +@@ -175,9 +189,17 @@ reify_segments (Dwfl *dwfl) + return true; + ++idx; + } ++ else if (dwfl->lookup_addr[idx] < start) ++ { ++ /* The module starts past the end of this segment. ++ Add a new one. */ ++ if (unlikely (insert (dwfl, idx + 1, start, end, -1))) ++ return true; ++ ++idx; ++ } + +- if (((size_t) idx + 1 == dwfl->lookup_elts +- || end < dwfl->lookup_addr[idx + 1]) ++ if ((size_t) idx + 1 < dwfl->lookup_elts ++ && end < dwfl->lookup_addr[idx + 1] + /* The module ends in the middle of this segment. Split it. */ + && unlikely (insert (dwfl, idx + 1, + end, dwfl->lookup_addr[idx + 1], -1))) +@@ -261,6 +283,12 @@ dwfl_report_segment (Dwfl *dwfl, int ndx + phdr->p_align < dwfl->segment_align)) + dwfl->segment_align = phdr->p_align; + ++ if (unlikely (dwfl->lookup_module != NULL)) ++ { ++ free (dwfl->lookup_module); ++ dwfl->lookup_module = NULL; ++ } ++ + GElf_Addr start = segment_start (dwfl, bias + phdr->p_vaddr); + GElf_Addr end = segment_end (dwfl, bias + phdr->p_vaddr + phdr->p_memsz); + +@@ -289,12 +317,6 @@ dwfl_report_segment (Dwfl *dwfl, int ndx + dwfl->lookup_tail_offset = end - bias - phdr->p_vaddr + phdr->p_offset; + dwfl->lookup_tail_ndx = ndx + 1; + +- if (unlikely (dwfl->lookup_module != NULL)) +- { +- free (dwfl->lookup_module); +- dwfl->lookup_module = NULL; +- } +- + return ndx; + } + INTDEF (dwfl_report_segment) +--- elfutils-0.137/libelf/ChangeLog ++++ elfutils-0.137/libelf/ChangeLog +@@ -1,3 +1,9 @@ ++2008-08-27 Roland McGrath ++ ++ * elf_begin.c (get_shnum): Avoid misaligned reads for matching endian. ++ ++ * libelfP.h [!ALLOW_UNALIGNED] (__libelf_type_align): Fix CLASS index. ++ + 2008-08-25 Roland McGrath + + * Makefile.am (libelf_so_LDLIBS): New variable. +--- elfutils-0.137/libelf/elf_begin.c ++++ elfutils-0.137/libelf/elf_begin.c +@@ -111,7 +111,11 @@ get_shnum (void *map_address, unsigned c + bool is32 = e_ident[EI_CLASS] == ELFCLASS32; + + /* Make the ELF header available. */ +- if (e_ident[EI_DATA] == MY_ELFDATA) ++ if (e_ident[EI_DATA] == MY_ELFDATA ++ && (ALLOW_UNALIGNED ++ || (((size_t) e_ident ++ & ((is32 ? __alignof__ (Elf32_Ehdr) : __alignof__ (Elf64_Ehdr)) ++ - 1)) == 0))) + ehdr.p = e_ident; + else + { +@@ -130,8 +134,11 @@ get_shnum (void *map_address, unsigned c + else + memcpy (&ehdr_mem, e_ident, sizeof (Elf32_Ehdr)); + +- CONVERT (ehdr_mem.e32.e_shnum); +- CONVERT (ehdr_mem.e32.e_shoff); ++ if (e_ident[EI_DATA] != MY_ELFDATA) ++ { ++ CONVERT (ehdr_mem.e32.e_shnum); ++ CONVERT (ehdr_mem.e32.e_shoff); ++ } + } + else + { +@@ -143,8 +150,11 @@ get_shnum (void *map_address, unsigned c + else + memcpy (&ehdr_mem, e_ident, sizeof (Elf64_Ehdr)); + +- CONVERT (ehdr_mem.e64.e_shnum); +- CONVERT (ehdr_mem.e64.e_shoff); ++ if (e_ident[EI_DATA] != MY_ELFDATA) ++ { ++ CONVERT (ehdr_mem.e64.e_shnum); ++ CONVERT (ehdr_mem.e64.e_shoff); ++ } + } + } + +--- elfutils-0.137/libelf/libelfP.h ++++ elfutils-0.137/libelf/libelfP.h +@@ -460,7 +460,7 @@ extern const uint_fast8_t __libelf_type_ + version, binary class, and type. */ + extern const uint_fast8_t __libelf_type_aligns[EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] attribute_hidden; + # define __libelf_type_align(class, type) \ +- (__libelf_type_aligns[LIBELF_EV_IDX][class][type] ?: 1) ++ (__libelf_type_aligns[LIBELF_EV_IDX][class - 1][type] ?: 1) + #else + # define __libelf_type_align(class, type) 1 + #endif diff --git a/elfutils-portability.patch b/elfutils-portability.patch index bc436dc..e12a63e 100644 --- a/elfutils-portability.patch +++ b/elfutils-portability.patch @@ -1,59 +1,149 @@ +--- elfutils/backends/ChangeLog ++++ elfutils/backends/ChangeLog +@@ -315,6 +315,11 @@ + * sparc_init.c: Likewise. + * x86_64_init.c: Likewise. + ++2005-11-22 Roland McGrath ++ ++ * Makefile.am (LD_AS_NEEDED): New variable, substituted by configure. ++ (libebl_%.so rule): Use it in place of -Wl,--as-needed. ++ + 2005-11-19 Roland McGrath + + * ppc64_reloc.def: REL30 -> ADDR30. +@@ -337,6 +342,9 @@ + * Makefile.am (uninstall): Don't try to remove $(pkgincludedir). + (CLEANFILES): Add libebl_$(m).so. + ++ * Makefile.am (WEXTRA): New variable, substituted by configure. ++ (AM_CFLAGS): Use it in place of -Wextra. ++ + * ppc_reloc.def: Update bits per Alan Modra . + * ppc64_reloc.def: Likewise. + +--- elfutils/backends/Makefile.am ++++ elfutils/backends/Makefile.am +@@ -25,12 +25,14 @@ + ## . + ## + DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\" ++WEXTRA = @WEXTRA@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + if MUDFLAP + AM_CFLAGS = -fmudflap + else + AM_CFLAGS = + endif +-AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 \ ++AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 \ + -std=gnu99 + INCLUDES = -I$(srcdir) -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \ + -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ +@@ -59,7 +61,6 @@ endif + + textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi + +- + i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c \ + i386_retval.c i386_regs.c i386_auxv.c i386_syscall.c + cpu_i386 = ../libcpu/libcpu_i386.a +--- elfutils/backends/Makefile.in ++++ elfutils/backends/Makefile.in +@@ -155,6 +155,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -184,6 +185,7 @@ SHELL = @SHELL@ + STRIP = @STRIP@ + USE_NLS = @USE_NLS@ + VERSION = @VERSION@ ++WEXTRA = @WEXTRA@ + XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ + YACC = @YACC@ +@@ -239,9 +241,9 @@ target_alias = @target_alias@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ + @MUDFLAP_FALSE@AM_CFLAGS = -fpic -Wall -Wshadow -Werror -Wunused \ +-@MUDFLAP_FALSE@ -Wextra -Wformat=2 -std=gnu99 ++@MUDFLAP_FALSE@ $(WEXTRA) -Wformat=2 -std=gnu99 + @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -fpic -Wall -Wshadow -Werror \ +-@MUDFLAP_TRUE@ -Wunused -Wextra -Wformat=2 -std=gnu99 ++@MUDFLAP_TRUE@ -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 + INCLUDES = -I$(srcdir) -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \ + -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ + -I$(top_srcdir)/lib -I.. --- elfutils/ChangeLog +++ elfutils/ChangeLog -@@ -1,3 +1,16 @@ -+2005-02-07 Roland McGrath +@@ -39,6 +39,10 @@ + * configure.ac: Add dummy automake conditional to get dependencies + for non-generic linker right. See src/Makefile.am. + ++2005-11-22 Roland McGrath ++ ++ * configure.ac: Check for --as-needed linker option. ++ + 2005-11-18 Roland McGrath + + * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): New variable. +@@ -86,6 +90,17 @@ + * Makefile.am (all_SUBDIRS): Add libdwfl. + * configure.ac: Write libdwfl/Makefile. + ++2005-05-31 Roland McGrath + + * configure.ac (WEXTRA): Check for -Wextra and set this substitution. + -+2003-08-12 Roland McGrath ++ * 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 + 2005-05-19 Roland McGrath - * 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@ +@@ -72,6 +72,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -101,6 +102,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ - ac_ct_CC = @ac_ct_CC@ --- elfutils/configure +++ elfutils/configure -@@ -277,7 +277,7 @@ PACKAGE_STRING='Red Hat elfutils 0.106' - 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_files='' - - # Initialize some variables set by options. -@@ -3373,6 +3373,58 @@ echo "$as_me: error: gcc with C99 suppor +@@ -676,6 +676,8 @@ YFLAGS + LEX + LEX_OUTPUT_ROOT + LEXLIB ++WEXTRA ++LD_AS_NEEDED + LOCALEDIR + DATADIRNAME + NATIVE_LD_TRUE +@@ -3894,6 +3896,88 @@ echo "$as_me: error: gcc with C99 suppor fi -+echo "$as_me:$LINENO: checking for -Wextra option to $CC" >&5 -+echo $ECHO_N "checking for -Wextra option to $CC... $ECHO_C" >&6 ++{ echo "$as_me:$LINENO: checking for -Wextra option to $CC" >&5 ++echo $ECHO_N "checking for -Wextra option to $CC... $ECHO_C" >&6; } +if test "${ac_cv_cc_wextra+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else @@ -63,61 +153,112 @@ +void foo (void) { } +_ACEOF +rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 ++if { (ac_try="$ac_compile" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 ++ (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_cc_wextra ++ (exit $ac_status); } && { ++ test -z "$ac_c_werror_flag" || ++ test ! -s conftest.err ++ } && test -s conftest.$ac_objext; then ++ ac_cv_cc_wextra=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + -+ac_cv_cc_wextra=no ++ ac_cv_cc_wextra=no +fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ++ ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$old_CFLAGS" +fi -+echo "$as_me:$LINENO: result: $ac_cv_cc_wextra" >&5 -+echo "${ECHO_T}$ac_cv_cc_wextra" >&6 ++{ 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 +fi + ++ ++{ echo "$as_me:$LINENO: checking for --as-needed linker option" >&5 ++echo $ECHO_N "checking for --as-needed linker option... $ECHO_C" >&6; } ++if test "${ac_cv_as_needed+set}" = set; then ++ echo $ECHO_N "(cached) $ECHO_C" >&6 ++else ++ cat > conftest.c <&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ (exit $ac_status); }; } ++then ++ ac_cv_as_needed=yes ++else ++ ac_cv_as_needed=no ++fi ++rm -f conftest* ++fi ++{ echo "$as_me:$LINENO: result: $ac_cv_as_needed" >&5 ++echo "${ECHO_T}$ac_cv_as_needed" >&6; } ++if test "x$ac_cv_as_needed" = xyes; then ++ LD_AS_NEEDED=-Wl,--as-needed ++else ++ LD_AS_NEEDED= ++fi ++ ++ ++ + LOCALEDIR=$datadir cat >>confdefs.h <<_ACEOF -@@ -4818,6 +4870,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,@WEXTRA@,$WEXTRA,;t t - s,@LOCALEDIR@,$LOCALEDIR,;t t - s,@DATADIRNAME@,$DATADIRNAME,;t t - s,@NATIVE_LD_TRUE@,$NATIVE_LD_TRUE,;t t +@@ -5646,8 +5730,8 @@ YFLAGS!$YFLAGS$ac_delim + LEX!$LEX$ac_delim + LEX_OUTPUT_ROOT!$LEX_OUTPUT_ROOT$ac_delim + LEXLIB!$LEXLIB$ac_delim +-LOCALEDIR!$LOCALEDIR$ac_delim +-DATADIRNAME!$DATADIRNAME$ac_delim ++WEXTRA!$WEXTRA$ac_delim ++LD_AS_NEEDED!$LD_AS_NEEDED$ac_delim + _ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then +@@ -5689,6 +5773,8 @@ _ACEOF + ac_delim='%!_!# ' + for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF ++LOCALEDIR!$LOCALEDIR$ac_delim ++DATADIRNAME!$DATADIRNAME$ac_delim + NATIVE_LD_TRUE!$NATIVE_LD_TRUE$ac_delim + NATIVE_LD_FALSE!$NATIVE_LD_FALSE$ac_delim + base_cpu!$base_cpu$ac_delim +@@ -5722,7 +5808,7 @@ LIBOBJS!$LIBOBJS$ac_delim + LTLIBOBJS!$LTLIBOBJS$ac_delim + _ACEOF + +- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 31; then ++ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 33; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 --- elfutils/configure.ac +++ elfutils/configure.ac -@@ -64,6 +64,15 @@ CFLAGS="$old_CFLAGS"]) +@@ -74,6 +74,34 @@ CFLAGS="$old_CFLAGS"]) AS_IF([test "x$ac_cv_c99" != xyes], AC_MSG_ERROR([gcc with C99 support required])) @@ -125,29 +266,51 @@ +old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wextra" +AC_COMPILE_IFELSE([void foo (void) { }], -+ ac_cv_cc_wextra, ac_cv_cc_wextra=no) ++ 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]) ++ ++AC_CACHE_CHECK([for --as-needed linker option], ++ ac_cv_as_needed, [dnl ++cat > conftest.c <&AS_MESSAGE_LOG_FD]) ++then ++ ac_cv_as_needed=yes ++else ++ ac_cv_as_needed=no ++fi ++rm -f conftest*]) ++AS_IF([test "x$ac_cv_as_needed" = xyes], ++ [LD_AS_NEEDED=-Wl,--as-needed], [LD_AS_NEEDED=]) ++AC_SUBST(LD_AS_NEEDED) ++ + LOCALEDIR=$datadir AC_SUBST(LOCALEDIR) AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR") --- elfutils/lib/ChangeLog +++ elfutils/lib/ChangeLog -@@ -1,3 +1,8 @@ +@@ -41,6 +41,11 @@ + * Makefile.am (libeu_a_SOURCES): Add it. + * system.h: Declare crc32_file. + +2005-02-07 Roland McGrath + + * Makefile.am (WEXTRA): New variable, substituted by configure. + (AM_CFLAGS): Use it in place of -Wextra. + - 2005-02-15 Ulrich Drepper + 2005-04-30 Ulrich Drepper - * dynamicsizehash.c (lookup): Mark val parameter as possibly unused. + * Makefile.am: Use -ffunction-sections for xmalloc.c. --- elfutils/lib/Makefile.am +++ elfutils/lib/Makefile.am -@@ -16,12 +16,13 @@ - ## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +@@ -25,12 +25,13 @@ + ## . ## DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H +WEXTRA = @WEXTRA@ @@ -163,17 +326,25 @@ noinst_LIBRARIES = libeu.a --- elfutils/lib/Makefile.in +++ elfutils/lib/Makefile.in -@@ -126,6 +126,7 @@ SHELL = @SHELL@ +@@ -93,6 +93,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -122,6 +123,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ - ac_ct_CC = @ac_ct_CC@ -@@ -168,9 +169,9 @@ sharedstatedir = @sharedstatedir@ - sysconfdir = @sysconfdir@ - target_alias = @target_alias@ +@@ -177,9 +179,9 @@ target_alias = @target_alias@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ @MUDFLAP_FALSE@AM_CFLAGS = -fpic -Wall -Wshadow -Werror -Wunused \ -@MUDFLAP_FALSE@ -Wextra $($(*F)_CFLAGS) +@MUDFLAP_FALSE@ $(WEXTRA) $($(*F)_CFLAGS) @@ -182,11 +353,25 @@ +@MUDFLAP_TRUE@ -Wunused $(WEXTRA) $($(*F)_CFLAGS) INCLUDES = -I$(srcdir)/../libelf -I.. noinst_LIBRARIES = libeu.a - libeu_a_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c crc32.c + libeu_a_SOURCES = xstrndup.c xmalloc.c next_prime.c \ +--- elfutils/libasm/ChangeLog ++++ elfutils/libasm/ChangeLog +@@ -54,6 +54,11 @@ + * asm_error.c: Add new error ASM_E_IOERROR. + * libasmP.h: Add ASM_E_IOERROR definition. + ++2005-05-31 Roland McGrath ++ ++ * Makefile.am (WEXTRA): New variable, substituted by configure. ++ (AM_CFLAGS): Use it in place of -Wextra. ++ + 2005-02-15 Ulrich Drepper + + * Makefile.am (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2. --- elfutils/libasm/Makefile.am +++ elfutils/libasm/Makefile.am -@@ -13,12 +13,13 @@ - ## 3001 King Ranch Road, Ukiah, CA 95482. +@@ -25,12 +25,13 @@ + ## . ## DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H +WEXTRA = @WEXTRA@ @@ -195,37 +380,47 @@ else AM_CFLAGS = endif --AM_CFLAGS += -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 -+AM_CFLAGS += -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 - INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl \ +-AM_CFLAGS += -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 ++AM_CFLAGS += -std=gnu99 -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 + INCLUDES = -I. -I$(srcdir) -I.. \ + -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl -I$(top_srcdir)/libdw\ -I$(top_srcdir)/lib - GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include) --- elfutils/libasm/Makefile.in +++ elfutils/libasm/Makefile.in -@@ -159,6 +159,7 @@ SHELL = @SHELL@ +@@ -126,6 +126,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -155,6 +156,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ - ac_ct_CC = @ac_ct_CC@ -@@ -200,10 +201,10 @@ sbindir = @sbindir@ - 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 - INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl \ +@@ -210,9 +212,9 @@ target_alias = @target_alias@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ + @MUDFLAP_FALSE@AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Werror -Wunused \ +-@MUDFLAP_FALSE@ -Wextra -Wformat=2 ++@MUDFLAP_FALSE@ $(WEXTRA) -Wformat=2 + @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -std=gnu99 -Wall -Wshadow -Werror \ +-@MUDFLAP_TRUE@ -Wunused -Wextra -Wformat=2 ++@MUDFLAP_TRUE@ -Wunused $(WEXTRA) -Wformat=2 + INCLUDES = -I. -I$(srcdir) -I.. \ + -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl -I$(top_srcdir)/libdw\ -I$(top_srcdir)/lib - --- elfutils/libcpu/ChangeLog +++ elfutils/libcpu/ChangeLog -@@ -1,3 +1,8 @@ +@@ -265,6 +265,11 @@ + * defs/i386.doc: New file. + * defs/x86_64: New file. + +2005-04-04 Roland McGrath + + * Makefile.am (WEXTRA): New variable, substituted by configure. @@ -236,39 +431,130 @@ * Makefile (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2. --- elfutils/libcpu/Makefile.am +++ elfutils/libcpu/Makefile.am -@@ -13,7 +13,8 @@ - ## 3001 King Ranch Road, Ukiah, CA 95482. - ## - DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H --AM_CFLAGS = -Wall -Wshadow -Werror -Wextra -Wformat=2 -Wunused +@@ -30,7 +30,8 @@ AM_CFLAGS = -fmudflap + else + AM_CFLAGS = + endif +-AM_CFLAGS += -Wall -Wshadow -Wunused -Wextra -std=gnu99 -fpic \ +WEXTRA = @WEXTRA@ -+AM_CFLAGS = -Wall -Wshadow -Werror $(WEXTRA) -Wformat=2 -Wunused - INCLUDES = -I$(srcdir) - - noinst_LIBRARIES = libcpu_i386.a ++AM_CFLAGS += -Wall -Wshadow -Wunused $(WEXTRA) -std=gnu99 -fpic \ + $($(*F)_CFLAGS) \ + $(if $($(*F)_no_Werror),,-Werror) + INCLUDES = -I$(srcdir) -I$(srcdir)/../lib -I$(srcdir)/../libelf \ --- elfutils/libcpu/Makefile.in +++ elfutils/libcpu/Makefile.in -@@ -122,6 +122,7 @@ SHELL = @SHELL@ +@@ -109,6 +109,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = lex.$( + ++ * Makefile.am (WEXTRA): New variable, substituted by configure. ++ (AM_CFLAGS): Use it in place of -Wextra. ++ ++2005-05-31 Roland McGrath ++ + * 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. +@@ -25,6 +25,7 @@ + ## . + ## + DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DIS_LIBDW ++WEXTRA = @WEXTRA@ + if MUDFLAP + AM_CFLAGS = -fmudflap + else +@@ -33,7 +34,7 @@ endif + if BUILD_STATIC + AM_CFLAGS += -fpic + endif +-AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99 ++AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 $(WEXTRA) -std=gnu99 + INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib + VERSION = 1 + +--- elfutils/libdw/Makefile.in ++++ elfutils/libdw/Makefile.in +@@ -164,6 +164,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -193,6 +194,7 @@ SHELL = @SHELL@ + STRIP = @STRIP@ + USE_NLS = @USE_NLS@ + VERSION = 1 ++WEXTRA = @WEXTRA@ + XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ + YACC = @YACC@ +@@ -248,9 +250,10 @@ target_alias = @target_alias@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ + @MUDFLAP_FALSE@AM_CFLAGS = $(am__append_1) -Wall -Werror -Wshadow \ +-@MUDFLAP_FALSE@ -Wunused -Wformat=2 -Wextra -std=gnu99 ++@MUDFLAP_FALSE@ -Wunused -Wformat=2 $(WEXTRA) -std=gnu99 + @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap $(am__append_1) -Wall -Werror \ +-@MUDFLAP_TRUE@ -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99 ++@MUDFLAP_TRUE@ -Wshadow -Wunused -Wformat=2 $(WEXTRA) \ ++@MUDFLAP_TRUE@ -std=gnu99 + INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib + COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \ + $(COMPILE))) +--- elfutils/libdwfl/ChangeLog ++++ elfutils/libdwfl/ChangeLog +@@ -885,6 +885,11 @@ + + 2005-07-21 Roland McGrath + ++ * Makefile.am (WEXTRA): New variable, substituted by configure. ++ (AM_CFLAGS): Use it in place of -Wextra. ++ ++2005-07-21 Roland McGrath ++ + * Makefile.am (noinst_HEADERS): Add loc2c.c. + + * test2.c (main): Check sscanf result to quiet warning. +--- elfutils/libdwfl/Makefile.am ++++ elfutils/libdwfl/Makefile.am +@@ -27,12 +27,13 @@ + ## . ## DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H +WEXTRA = @WEXTRA@ @@ -279,35 +565,57 @@ endif -AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99 +AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 $(WEXTRA) -std=gnu99 - INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib + INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ + -I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib VERSION = 1 - ---- elfutils/libdw/Makefile.in -+++ elfutils/libdw/Makefile.in -@@ -190,6 +190,7 @@ SHELL = @SHELL@ +--- elfutils/libdwfl/Makefile.in ++++ elfutils/libdwfl/Makefile.in +@@ -131,6 +131,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -160,6 +161,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ - ac_ct_CC = @ac_ct_CC@ -@@ -232,9 +233,9 @@ sharedstatedir = @sharedstatedir@ - sysconfdir = @sysconfdir@ - target_alias = @target_alias@ +@@ -215,9 +217,9 @@ target_alias = @target_alias@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ @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.. -I$(srcdir)/../lib - lib_LIBRARIES = libdw.a - @MUDFLAP_FALSE@noinst_LIBRARIES = libdw_pic.a + INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ + -I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib + +--- elfutils/libebl/ChangeLog ++++ elfutils/libebl/ChangeLog +@@ -554,6 +554,11 @@ + * Makefile.am (libebl_*_so_SOURCES): Set to $(*_SRCS) so dependency + tracking works right. + ++2005-05-31 Roland McGrath ++ ++ * Makefile.am (WEXTRA): New variable, substituted by configure. ++ (AM_CFLAGS): Use it in place of -Wextra. ++ + 2005-05-21 Ulrich Drepper + + * libebl_x86_64.map: Add x86_64_core_note. --- elfutils/libebl/Makefile.am +++ elfutils/libebl/Makefile.am -@@ -13,12 +13,13 @@ - ## 3001 King Ranch Road, Ukiah, CA 95482. +@@ -25,12 +25,13 @@ + ## . ## DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\" +WEXTRA = @WEXTRA@ @@ -320,40 +628,84 @@ +AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 \ -std=gnu99 - INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/lib -I.. + INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ --- elfutils/libebl/Makefile.in +++ elfutils/libebl/Makefile.in -@@ -236,6 +236,7 @@ SHELL = @SHELL@ +@@ -123,6 +123,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -152,6 +153,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ - ac_ct_CC = @ac_ct_CC@ -@@ -278,9 +279,9 @@ sharedstatedir = @sharedstatedir@ - sysconfdir = @sysconfdir@ - target_alias = @target_alias@ +@@ -207,9 +209,9 @@ target_alias = @target_alias@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ @MUDFLAP_FALSE@AM_CFLAGS = -fpic -Wall -Wshadow -Werror -Wunused \ -@MUDFLAP_FALSE@ -Wextra -Wformat=2 -std=gnu99 +@MUDFLAP_FALSE@ $(WEXTRA) -Wformat=2 -std=gnu99 @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -fpic -Wall -Wshadow -Werror \ -@MUDFLAP_TRUE@ -Wunused -Wextra -Wformat=2 -std=gnu99 +@MUDFLAP_TRUE@ -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 - INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/lib -I.. - lib_LIBRARIES = libebl.a - modules = i386 sh mips x86_64 ia64 alpha arm sparc ppc ppc64 + INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ + -I$(top_srcdir)/lib -I.. -I$(srcdir)/../libasm + +--- elfutils/libelf/ChangeLog ++++ elfutils/libelf/ChangeLog +@@ -408,6 +408,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 ++ ++ * Makefile.am (WEXTRA): New variable, substituted by configure. ++ (AM_CFLAGS): Use it in place of -Wextra. ++ + 2005-05-11 Ulrich Drepper + + * elf.h: Update again. +--- elfutils/libelf/common.h ++++ elfutils/libelf/common.h +@@ -160,7 +160,7 @@ libelf_release_all (Elf *elf) + (Var) = (sizeof (Var) == 1 \ + ? (unsigned char) (Var) \ + : (sizeof (Var) == 2 \ +- ? bswap_16 (Var) \ ++ ? (unsigned short int) bswap_16 (Var) \ + : (sizeof (Var) == 4 \ + ? bswap_32 (Var) \ + : bswap_64 (Var)))) +@@ -169,7 +169,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 @@ - ## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +@@ -25,6 +25,7 @@ + ## . ## DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H +WEXTRA = @WEXTRA@ if MUDFLAP - AM_CFLAGS = -fpic -fmudflap + AM_CFLAGS = -fmudflap else - AM_CFLAGS = +@@ -33,7 +34,7 @@ endif + if BUILD_STATIC + AM_CFLAGS += -fpic endif -AM_CFLAGS += -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 -std=gnu99 \ +AM_CFLAGS += -Wall -Wshadow -Werror -Wunused $(WEXTRA) -Wformat=2 -std=gnu99 \ @@ -362,83 +714,257 @@ GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include) --- elfutils/libelf/Makefile.in +++ elfutils/libelf/Makefile.in -@@ -199,6 +199,7 @@ SHELL = @SHELL@ +@@ -171,6 +171,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -200,6 +201,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ - ac_ct_CC = @ac_ct_CC@ -@@ -240,10 +241,10 @@ sbindir = @sbindir@ - 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 \ +@@ -255,10 +257,10 @@ target_alias = @target_alias@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ + @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@ +@@ -71,6 +71,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -100,6 +101,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ - ac_ct_CC = @ac_ct_CC@ +--- elfutils/Makefile.in ++++ elfutils/Makefile.in +@@ -98,6 +98,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -127,6 +128,7 @@ SHELL = @SHELL@ + STRIP = @STRIP@ + USE_NLS = @USE_NLS@ + VERSION = @VERSION@ ++WEXTRA = @WEXTRA@ + XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ + YACC = @YACC@ +--- elfutils/src/ChangeLog ++++ elfutils/src/ChangeLog +@@ -61,6 +61,11 @@ + that matches its PT_LOAD's p_flags &~ PF_W. On sparc, PF_X really + is valid in RELRO. + ++2008-03-01 Roland McGrath ++ ++ * readelf.c (dump_archive_index): Tweak portability hack ++ to match [__GNUC__ < 4] too. ++ + 2008-02-29 Roland McGrath + + * readelf.c (print_attributes): Add a cast. +@@ -312,6 +317,8 @@ + + * readelf.c (hex_dump): Fix rounding error in whitespace calculation. + ++ * Makefile.am (readelf_no_Werror): New variable. ++ + 2007-10-15 Roland McGrath + + * make-debug-archive.in: New file. +@@ -751,6 +758,10 @@ + * elflint.c (valid_e_machine): Add EM_ALPHA. + Reported by Christian Aichinger . + ++ * strings.c (map_file): Define POSIX_MADV_SEQUENTIAL to ++ MADV_SEQUENTIAL if undefined. Don't call posix_madvise ++ if neither is defined. ++ + 2006-08-08 Ulrich Drepper + + * elflint.c (check_dynamic): Don't require DT_HASH for DT_SYMTAB. +@@ -827,6 +838,10 @@ + * Makefile.am: Add hacks to create dependency files for non-generic + linker. + ++2006-04-05 Roland McGrath ++ ++ * strings.c (MAP_POPULATE): Define to 0 if undefined. ++ + 2006-06-12 Ulrich Drepper + + * ldgeneric.c (ld_generic_generate_sections): Don't create .interp +@@ -1175,6 +1190,11 @@ + * readelf.c (print_debug_loc_section): Fix indentation for larger + address size. + ++2005-05-31 Roland McGrath ++ ++ * Makefile.am (WEXTRA): New variable, substituted by configure. ++ (AM_CFLAGS): Use it in place of -Wextra. ++ + 2005-05-30 Roland McGrath + + * readelf.c (print_debug_line_section): Print section offset of each +--- elfutils/src/findtextrel.c ++++ elfutils/src/findtextrel.c +@@ -488,7 +488,11 @@ ptrcompare (const void *p1, const void * + + + static void +-check_rel (size_t nsegments, struct segments segments[nsegments], ++check_rel (size_t nsegments, struct segments segments[ ++#if __GNUC__ >= 4 ++ nsegments ++#endif ++ ], + 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,14 +14,15 @@ +@@ -26,6 +26,7 @@ ## - DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) \ + DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \ -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) + AM_CFLAGS = -fmudflap 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) +@@ -33,7 +34,7 @@ AM_CFLAGS = endif - if MUDFLAP + 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) $(CFLAGS_$(*F)) + + INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ +@@ -111,6 +112,9 @@ strings_no_Wformat = yes + # XXX While the file is not finished, don't warn about this + ldgeneric_no_Wunused = yes + ++# Buggy old compilers. ++readelf_no_Werror = yes ++ + readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl + nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl + size_LDADD = $(libelf) $(libeu) $(libmudflap) --- elfutils/src/Makefile.in +++ elfutils/src/Makefile.in -@@ -192,6 +192,7 @@ SHELL = @SHELL@ +@@ -201,6 +201,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -230,6 +231,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ -d - ac_ct_CC = @ac_ct_CC@ -@@ -235,10 +236,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) +@@ -287,13 +289,13 @@ top_srcdir = @top_srcdir@ + @MUDFLAP_FALSE@AM_CFLAGS = -Wall -Wshadow -std=gnu99 \ + @MUDFLAP_FALSE@ $(native_ld_cflags) $(if \ + @MUDFLAP_FALSE@ $($(*F)_no_Werror),,-Werror) $(if \ +-@MUDFLAP_FALSE@ $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ ++@MUDFLAP_FALSE@ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ + @MUDFLAP_FALSE@ $($(*F)_no_Wformat),,-Wformat=2) \ + @MUDFLAP_FALSE@ $(CFLAGS_$(*F)) + @MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -Wall -Wshadow -std=gnu99 \ + @MUDFLAP_TRUE@ $(native_ld_cflags) $(if \ + @MUDFLAP_TRUE@ $($(*F)_no_Werror),,-Werror) $(if \ +-@MUDFLAP_TRUE@ $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ ++@MUDFLAP_TRUE@ $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ + @MUDFLAP_TRUE@ $($(*F)_no_Wformat),,-Wformat=2) $(CFLAGS_$(*F)) + INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ + -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \ +@@ -337,6 +339,9 @@ size_no_Wformat = yes + strings_no_Wformat = yes + # XXX While the file is not finished, don't warn about this + ldgeneric_no_Wunused = yes ++ ++# Buggy old compilers. ++readelf_no_Werror = yes + readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl + nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl + size_LDADD = $(libelf) $(libeu) $(libmudflap) +--- elfutils/src/readelf.c ++++ elfutils/src/readelf.c +@@ -6419,7 +6419,7 @@ dump_archive_index (Elf *elf, const char + if (unlikely (elf_rand (elf, as_off) == 0) + || unlikely ((subelf = elf_begin (-1, ELF_C_READ_MMAP, elf)) + == NULL)) +-#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7) ++#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7) || __GNUC__ < 4 + while (1) + #endif + error (EXIT_FAILURE, 0, +--- elfutils/src/strings.c ++++ elfutils/src/strings.c +@@ -51,6 +51,10 @@ --@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) + #include ++#ifndef MAP_POPULATE ++# define MAP_POPULATE 0 ++#endif ++ + + /* Prototypes of local functions. */ + static int read_fd (int fd, const char *fname, off64_t fdlen); +@@ -491,8 +495,13 @@ map_file (int fd, off64_t start_off, off + fd, start_off); + if (mem != MAP_FAILED) + { ++#if !defined POSIX_MADV_SEQUENTIAL && defined MADV_SEQUENTIAL ++# define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL ++#endif ++#ifdef POSIX_MADV_SEQUENTIAL + /* We will go through the mapping sequentially. */ + (void) posix_madvise (mem, map_size, POSIX_MADV_SEQUENTIAL); ++#endif + break; + } + if (errno != EINVAL && errno != ENOMEM) --- elfutils/src/strip.c +++ elfutils/src/strip.c -@@ -40,6 +40,12 @@ +@@ -52,6 +52,12 @@ #include #include @@ -451,7 +977,7 @@ /* Name and version of program. */ static void print_version (FILE *stream, struct argp_state *state); -@@ -245,8 +251,18 @@ process_file (const char *fname) +@@ -300,8 +306,18 @@ process_file (const char *fname) /* If we have to preserve the timestamp, we need it in the format utimes() understands. */ @@ -470,7 +996,7 @@ } /* Open the file. */ -@@ -1677,7 +1693,7 @@ handle_elf (int fd, Elf *elf, const char +@@ -1745,7 +1761,7 @@ handle_elf (int fd, Elf *elf, const char /* If requested, preserve the timestamp. */ if (tvp != NULL) { @@ -478,8 +1004,8 @@ + if (FUTIMES (fd, output_fname, tvp) != 0) { error (0, errno, gettext ("\ - cannot set access and modification date of \"%s\""), -@@ -1734,7 +1750,7 @@ handle_ar (int fd, Elf *elf, const char + cannot set access and modification date of '%s'"), +@@ -1802,7 +1818,7 @@ handle_ar (int fd, Elf *elf, const char if (tvp != NULL) { @@ -487,14 +1013,87 @@ + if (unlikely (FUTIMES (fd, fname, tvp) != 0)) { error (0, errno, gettext ("\ - cannot set access and modification date of \"%s\""), fname); + cannot set access and modification date of '%s'"), fname); +--- elfutils/tests/ChangeLog ++++ elfutils/tests/ChangeLog +@@ -51,6 +51,8 @@ + + 2008-01-21 Roland McGrath + ++ * line2addr.c (main): Revert last change. ++ + * testfile45.S.bz2: Add tests for cltq, cqto. + * testfile45.expect.bz2: Adjust. + +@@ -759,6 +761,11 @@ + * Makefile.am (TESTS): Add run-elflint-test.sh. + (EXTRA_DIST): Add run-elflint-test.sh and testfile18.bz2. + ++2005-05-31 Roland McGrath ++ ++ * Makefile.am (WEXTRA): New variable, substituted by configure. ++ (AM_CFLAGS): Use it in place of -Wextra. ++ + 2005-05-24 Ulrich Drepper + + * get-files.c (main): Use correct format specifier. +--- elfutils/tests/line2addr.c ++++ elfutils/tests/line2addr.c +@@ -132,7 +132,7 @@ main (int argc, char *argv[]) + { + struct args a = { .arg = argv[cnt] }; + +- switch (sscanf (a.arg, "%m[^:]:%d", &a.file, &a.line)) ++ switch (sscanf (a.arg, "%a[^:]:%d", &a.file, &a.line)) + { + default: + case 0: +--- elfutils/tests/Makefile.am ++++ elfutils/tests/Makefile.am +@@ -25,12 +25,13 @@ + ## . + ## + DEFS = -DHAVE_CONFIG_H -D_GNU_SOURCE ++WEXTRA = @WEXTRA@ + if MUDFLAP +-AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 -fmudflap\ ++AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 -fmudflap\ + $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) + BUILD_RPATH = \$$ORIGIN/../backends + else +-AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 \ ++AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 \ + $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) + BUILT_RPATH = \$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../backends:\$$ORIGIN/../libelf + endif --- elfutils/tests/Makefile.in +++ elfutils/tests/Makefile.in -@@ -266,6 +266,7 @@ SHELL = @SHELL@ +@@ -335,6 +335,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ + INSTALL_SCRIPT = @INSTALL_SCRIPT@ + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ + LDFLAGS = @LDFLAGS@ ++LD_AS_NEEDED = @LD_AS_NEEDED@ + LEX = @LEX@ + LEXLIB = @LEXLIB@ + LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +@@ -364,6 +365,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ - ac_ct_CC = @ac_ct_CC@ +@@ -418,10 +420,10 @@ sysconfdir = @sysconfdir@ + target_alias = @target_alias@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ +-@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 \ ++@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 \ + @MUDFLAP_FALSE@ $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) + +-@MUDFLAP_TRUE@AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 -fmudflap\ ++@MUDFLAP_TRUE@AM_CFLAGS = -Wall -Werror $(WEXTRA) -std=gnu99 -fmudflap\ + @MUDFLAP_TRUE@ $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) + + @MUDFLAP_TRUE@BUILD_RPATH = \$$ORIGIN/../backends diff --git a/elfutils-robustify.patch b/elfutils-robustify.patch new file mode 100644 index 0000000..1c3d3e7 --- /dev/null +++ b/elfutils-robustify.patch @@ -0,0 +1,1544 @@ +src/ +2005-06-09 Roland McGrath + + * readelf.c (handle_dynamic, handle_symtab): Check for bogus sh_link. + (handle_verneed, handle_verdef, handle_versym, handle_hash): Likewise. + (handle_scngrp): Check for bogus sh_info. + + * strip.c (handle_elf): Check for bogus values in sh_link, sh_info, + st_shndx, e_shstrndx, and SHT_GROUP or SHT_SYMTAB_SHNDX data. + Don't use assert on input values, instead bail with "illformed" error. + +2005-05-17 Jakub Jelinek + +libelf/ + * elf32_getphdr.c (elfw2(LIBELFBITS,getphdr)): Check if program header + table fits into object's bounds. + * elf_getshstrndx.c (elf_getshstrndx): Add elf->start_offset to + elf->map_address. Check if first section header fits into object's + bounds. + * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)): + Check if section header table fits into object's bounds. + * elf_begin.c (get_shnum): Ensure section headers fits into + object's bounds. + (file_read_elf): Make sure scncnt is small enough to allocate both + ElfXX_Shdr and Elf_Scn array. Make sure section and program header + tables fit into object's bounds. Avoid memory leak on failure. + +src/ + * elflint.c (check_hash): Don't check entries beyond end of section. + (check_note): Don't crash if gelf_rawchunk fails. + (section_name): Return if gelf_getshdr returns NULL. + +2005-05-14 Jakub Jelinek + +libelf/ + * libelfP.h (INVALID_NDX): Define. + * gelf_getdyn.c (gelf_getdyn): Use it. Remove ndx < 0 test if any. + * gelf_getlib.c (gelf_getlib): Likewise. + * gelf_getmove.c (gelf_getmove): Likewise. + * gelf_getrel.c (gelf_getrel): Likewise. + * gelf_getrela.c (gelf_getrela): Likewise. + * gelf_getsym.c (gelf_getsym): Likewise. + * gelf_getsyminfo.c (gelf_getsyminfo): Likewise. + * gelf_getsymshndx.c (gelf_getsymshndx): Likewise. + * gelf_getversym.c (gelf_getversym): Likewise. + * gelf_update_dyn.c (gelf_update_dyn): Likewise. + * gelf_update_lib.c (gelf_update_lib): Likewise. + * gelf_update_move.c (gelf_update_move): Likewise. + * gelf_update_rel.c (gelf_update_rel): Likewise. + * gelf_update_rela.c (gelf_update_rela): Likewise. + * gelf_update_sym.c (gelf_update_sym): Likewise. + * gelf_update_syminfo.c (gelf_update_syminfo): Likewise. + * gelf_update_symshndx.c (gelf_update_symshndx): Likewise. + * gelf_update_versym.c (gelf_update_versym): Likewise. + * elf_newscn.c (elf_newscn): Check for overflow. + * elf32_updatefile.c (__elfw2(LIBELFBITS,updatemmap)): Likewise. + (__elfw2(LIBELFBITS,updatefile)): Likewise. + * elf_begin.c (file_read_elf): Likewise. + * elf32_newphdr.c (elfw2(LIBELFBITS,newphdr)): Likewise. + * elf_getarsym.c (elf_getarsym): Likewise. + * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)): Likewise. +src/ + * elflint.c (section_name): Return "" instead of + crashing on invalid section name. + (check_symtab, is_rel_dyn, check_rela, check_rel, check_dynamic, + check_symtab_shndx, check_hash, check_versym): Robustify. + +--- elfutils-0.136/libelf/elf32_getphdr.c.robustify ++++ elfutils-0.136/libelf/elf32_getphdr.c +@@ -105,6 +105,16 @@ __elfw2(LIBELFBITS,getphdr_wrlock) (elf) + + if (elf->map_address != NULL) + { ++ /* First see whether the information in the ELF header is ++ valid and it does not ask for too much. */ ++ if (unlikely (ehdr->e_phoff >= elf->maximum_size) ++ || unlikely (ehdr->e_phoff + size > elf->maximum_size)) ++ { ++ /* Something is wrong. */ ++ __libelf_seterrno (ELF_E_INVALID_PHDR); ++ goto out; ++ } ++ + /* All the data is already mapped. Use it. */ + void *file_phdr = ((char *) elf->map_address + + elf->start_offset + ehdr->e_phoff); +--- elfutils-0.136/libelf/elf32_getshdr.c.robustify ++++ elfutils-0.136/libelf/elf32_getshdr.c +@@ -1,5 +1,5 @@ + /* Return section header. +- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007 Red Hat, Inc. ++ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2008 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 1998. + +@@ -81,7 +81,8 @@ load_shdr_rwlock (Elf_Scn *scn) + goto out; + + size_t shnum; +- if (__elf_getshnum_rdlock (elf, &shnum) != 0) ++ if (__elf_getshnum_rdlock (elf, &shnum) != 0 ++ || shnum > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Shdr))) + goto out; + size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr)); + +@@ -98,6 +99,16 @@ load_shdr_rwlock (Elf_Scn *scn) + + if (elf->map_address != NULL) + { ++ /* First see whether the information in the ELF header is ++ valid and it does not ask for too much. */ ++ if (unlikely (ehdr->e_shoff >= elf->maximum_size) ++ || unlikely (ehdr->e_shoff + size > elf->maximum_size)) ++ { ++ /* Something is wrong. */ ++ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); ++ goto free_and_out; ++ } ++ + ElfW2(LIBELFBITS,Shdr) *notcvt; + + /* All the data is already mapped. If we could use it +--- elfutils-0.136/libelf/elf32_newphdr.c.robustify ++++ elfutils-0.136/libelf/elf32_newphdr.c +@@ -124,6 +124,12 @@ elfw2(LIBELFBITS,newphdr) (elf, count) + else if (elf->state.ELFW(elf,LIBELFBITS).ehdr->e_phnum != count + || elf->state.ELFW(elf,LIBELFBITS).phdr == NULL) + { ++ if (unlikely (count > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Phdr)))) ++ { ++ result = NULL; ++ goto out; ++ } ++ + /* Allocate a new program header with the appropriate number of + elements. */ + result = (ElfW2(LIBELFBITS,Phdr) *) +--- elfutils-0.136/libelf/elf32_updatefile.c.robustify ++++ elfutils-0.136/libelf/elf32_updatefile.c +@@ -212,6 +212,9 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf + /* Write all the sections. Well, only those which are modified. */ + if (shnum > 0) + { ++ if (unlikely (shnum > SIZE_MAX / sizeof (Elf_Scn *))) ++ return 1; ++ + Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns; + Elf_Scn **scns = (Elf_Scn **) alloca (shnum * sizeof (Elf_Scn *)); + char *const shdr_start = ((char *) elf->map_address + elf->start_offset +@@ -582,6 +585,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf + /* Write all the sections. Well, only those which are modified. */ + if (shnum > 0) + { ++ if (unlikely (shnum > SIZE_MAX / (sizeof (Elf_Scn *) ++ + sizeof (ElfW2(LIBELFBITS,Shdr))))) ++ return 1; ++ + off_t shdr_offset = elf->start_offset + ehdr->e_shoff; + #if EV_NUM != 2 + xfct_t shdr_fctp = __elf_xfctstom[__libelf_version - 1][EV_CURRENT - 1][ELFW(ELFCLASS, LIBELFBITS) - 1][ELF_T_SHDR]; +--- elfutils-0.136/libelf/elf_begin.c.robustify ++++ elfutils-0.136/libelf/elf_begin.c +@@ -155,7 +155,8 @@ get_shnum (void *map_address, unsigned c + + if (unlikely (result == 0) && ehdr.e32->e_shoff != 0) + { +- if (ehdr.e32->e_shoff + sizeof (Elf32_Shdr) > maxsize) ++ if (unlikely (ehdr.e32->e_shoff >= maxsize) ++ || unlikely (ehdr.e32->e_shoff + sizeof (Elf32_Shdr) > maxsize)) + /* Cannot read the first section header. */ + return 0; + +@@ -203,7 +204,8 @@ get_shnum (void *map_address, unsigned c + + if (unlikely (result == 0) && ehdr.e64->e_shoff != 0) + { +- if (ehdr.e64->e_shoff + sizeof (Elf64_Shdr) > maxsize) ++ if (unlikely (ehdr.e64->e_shoff >= maxsize) ++ || unlikely (ehdr.e64->e_shoff + sizeof (Elf64_Shdr) > maxsize)) + /* Cannot read the first section header. */ + return 0; + +@@ -275,6 +277,15 @@ file_read_elf (int fildes, void *map_add + /* Could not determine the number of sections. */ + return NULL; + ++ /* Check for too many sections. */ ++ if (e_ident[EI_CLASS] == ELFCLASS32) ++ { ++ if (scncnt > SIZE_MAX / (sizeof (Elf_Scn) + sizeof (Elf32_Shdr))) ++ return NULL; ++ } ++ else if (scncnt > SIZE_MAX / (sizeof (Elf_Scn) + sizeof (Elf64_Shdr))) ++ return NULL; ++ + /* We can now allocate the memory. */ + Elf *elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent, + ELF_K_ELF, scncnt * sizeof (Elf_Scn)); +@@ -308,13 +319,31 @@ file_read_elf (int fildes, void *map_add + { + /* We can use the mmapped memory. */ + elf->state.elf32.ehdr = ehdr; ++ ++ if (unlikely (ehdr->e_shoff >= maxsize) ++ || unlikely (ehdr->e_shoff ++ + scncnt * sizeof (Elf32_Shdr) > maxsize)) ++ { ++ free_and_out: ++ free (elf); ++ __libelf_seterrno (ELF_E_INVALID_FILE); ++ return NULL; ++ } + elf->state.elf32.shdr + = (Elf32_Shdr *) ((char *) ehdr + ehdr->e_shoff); ++ + if (ehdr->e_phnum > 0) ++ { + /* Assign a value only if there really is a program + header. Otherwise the value remains NULL. */ ++ if (unlikely (ehdr->e_phoff >= maxsize) ++ || unlikely (ehdr->e_phoff ++ + ehdr->e_phnum ++ * sizeof (Elf32_Phdr) > maxsize)) ++ goto free_and_out; + elf->state.elf32.phdr + = (Elf32_Phdr *) ((char *) ehdr + ehdr->e_phoff); ++ } + + for (size_t cnt = 0; cnt < scncnt; ++cnt) + { +@@ -396,13 +425,26 @@ file_read_elf (int fildes, void *map_add + { + /* We can use the mmapped memory. */ + elf->state.elf64.ehdr = ehdr; ++ ++ if (unlikely (ehdr->e_shoff >= maxsize) ++ || unlikely (ehdr->e_shoff ++ + scncnt * sizeof (Elf32_Shdr) > maxsize)) ++ goto free_and_out; + elf->state.elf64.shdr + = (Elf64_Shdr *) ((char *) ehdr + ehdr->e_shoff); ++ + if (ehdr->e_phnum > 0) ++ { + /* Assign a value only if there really is a program + header. Otherwise the value remains NULL. */ ++ if (unlikely (ehdr->e_phoff >= maxsize) ++ || unlikely (ehdr->e_phoff ++ + ehdr->e_phnum ++ * sizeof (Elf32_Phdr) > maxsize)) ++ goto free_and_out; + elf->state.elf64.phdr + = (Elf64_Phdr *) ((char *) ehdr + ehdr->e_phoff); ++ } + + for (size_t cnt = 0; cnt < scncnt; ++cnt) + { +--- elfutils-0.136/libelf/elf_getarsym.c.robustify ++++ elfutils-0.136/libelf/elf_getarsym.c +@@ -179,6 +179,9 @@ elf_getarsym (elf, ptr) + size_t index_size = atol (tmpbuf); + + if (SARMAG + sizeof (struct ar_hdr) + index_size > elf->maximum_size ++#if SIZE_MAX <= 4294967295U ++ || n >= SIZE_MAX / sizeof (Elf_Arsym) ++#endif + || n * sizeof (uint32_t) > index_size) + { + /* This index table cannot be right since it does not fit into +--- elfutils-0.136/libelf/elf_getshstrndx.c.robustify ++++ elfutils-0.136/libelf/elf_getshstrndx.c +@@ -125,10 +125,25 @@ elf_getshstrndx (elf, dst) + if (elf->map_address != NULL + && elf->state.elf32.ehdr->e_ident[EI_DATA] == MY_ELFDATA + && (ALLOW_UNALIGNED +- || (((size_t) ((char *) elf->map_address + offset)) ++ || (((size_t) ((char *) elf->map_address ++ + elf->start_offset + offset)) + & (__alignof__ (Elf32_Shdr) - 1)) == 0)) ++ { ++ /* 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 + offset))->sh_link; ++ num = ((Elf32_Shdr *) (elf->map_address + elf->start_offset ++ + offset))->sh_link; ++ } + else + { + /* We avoid reading in all the section headers. Just read +@@ -163,10 +178,25 @@ 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)) ++ { ++ /* 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 + offset))->sh_link; ++ 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.136/libelf/elf_newscn.c.robustify ++++ elfutils-0.136/libelf/elf_newscn.c +@@ -104,10 +104,18 @@ elf_newscn (elf) + else + { + /* We must allocate a new element. */ +- Elf_ScnList *newp; ++ Elf_ScnList *newp = NULL; + + assert (elf->state.elf.scnincr > 0); + ++ if ( ++#if SIZE_MAX <= 4294967295U ++ likely (elf->state.elf.scnincr ++ < SIZE_MAX / 2 / sizeof (Elf_Scn) - sizeof (Elf_ScnList)) ++#else ++ 1 ++#endif ++ ) + newp = (Elf_ScnList *) calloc (sizeof (Elf_ScnList) + + ((elf->state.elf.scnincr *= 2) + * sizeof (Elf_Scn)), 1); +--- elfutils-0.136/libelf/gelf_getdyn.c.robustify ++++ elfutils-0.136/libelf/gelf_getdyn.c +@@ -93,7 +93,8 @@ gelf_getdyn (data, ndx, dst) + table entries has to be adopted. The user better has provided + a buffer where we can store the information. While copying the + data we are converting the format. */ +- if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Dyn) ++ || unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -114,7 +115,8 @@ gelf_getdyn (data, ndx, dst) + + /* The data is already in the correct form. Just make sure the + index is OK. */ +- if (unlikely ((ndx + 1) * sizeof (GElf_Dyn) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, GElf_Dyn) ++ || unlikely ((ndx + 1) * sizeof (GElf_Dyn) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils-0.136/libelf/gelf_getlib.c.robustify ++++ elfutils-0.136/libelf/gelf_getlib.c +@@ -86,7 +86,8 @@ gelf_getlib (data, ndx, dst) + /* The data is already in the correct form. Just make sure the + index is OK. */ + 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.136/libelf/gelf_getmove.c.robustify ++++ elfutils-0.136/libelf/gelf_getmove.c +@@ -83,7 +83,8 @@ gelf_getmove (data, ndx, dst) + + /* The data is already in the correct form. Just make sure the + index is OK. */ +- if (unlikely ((ndx + 1) * sizeof (GElf_Move) > data->d_size)) ++ if (INVALID_NDX (ndx, GElf_Move) ++ || unlikely ((ndx + 1) * sizeof (GElf_Move) > data->d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils-0.136/libelf/gelf_getrela.c.robustify ++++ elfutils-0.136/libelf/gelf_getrela.c +@@ -71,12 +71,6 @@ gelf_getrela (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_RELA)) + { + __libelf_seterrno (ELF_E_INVALID_HANDLE); +@@ -93,7 +87,8 @@ gelf_getrela (data, ndx, dst) + if (scn->elf->class == ELFCLASS32) + { + /* We have to convert the data. */ +- if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Rela) ++ || unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + result = NULL; +@@ -114,7 +109,8 @@ gelf_getrela (data, ndx, dst) + { + /* Simply copy the data after we made sure we are actually getting + correct data. */ +- if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Rela) ++ || unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + result = NULL; +--- elfutils-0.136/libelf/gelf_getrel.c.robustify ++++ elfutils-0.136/libelf/gelf_getrel.c +@@ -71,12 +71,6 @@ gelf_getrel (data, ndx, dst) + if (data_scn == NULL) + return NULL; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return NULL; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_REL)) + { + __libelf_seterrno (ELF_E_INVALID_HANDLE); +@@ -93,7 +87,8 @@ gelf_getrel (data, ndx, dst) + if (scn->elf->class == ELFCLASS32) + { + /* We have to convert the data. */ +- if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Rel) ++ || unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + result = NULL; +@@ -113,7 +108,8 @@ gelf_getrel (data, ndx, dst) + { + /* Simply copy the data after we made sure we are actually getting + correct data. */ +- if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Rel) ++ || unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + result = NULL; +--- elfutils-0.136/libelf/gelf_getsym.c.robustify ++++ elfutils-0.136/libelf/gelf_getsym.c +@@ -90,7 +90,8 @@ gelf_getsym (data, ndx, dst) + table entries has to be adopted. The user better has provided + a buffer where we can store the information. While copying the + data we are converting the format. */ +- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data->d_size)) ++ if (INVALID_NDX (ndx, Elf32_Sym) ++ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data->d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -119,7 +120,8 @@ gelf_getsym (data, ndx, dst) + + /* The data is already in the correct form. Just make sure the + index is OK. */ +- if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > data->d_size)) ++ if (INVALID_NDX (ndx, GElf_Sym) ++ || unlikely ((ndx + 1) * sizeof (GElf_Sym) > data->d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils-0.136/libelf/gelf_getsyminfo.c.robustify ++++ elfutils-0.136/libelf/gelf_getsyminfo.c +@@ -84,7 +84,8 @@ gelf_getsyminfo (data, ndx, dst) + + /* The data is already in the correct form. Just make sure the + index is OK. */ +- if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data->d_size)) ++ if (INVALID_NDX (ndx, GElf_Syminfo) ++ || unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data->d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils-0.136/libelf/gelf_getsymshndx.c.robustify ++++ elfutils-0.136/libelf/gelf_getsymshndx.c +@@ -90,7 +90,9 @@ gelf_getsymshndx (symdata, shndxdata, nd + section index table. */ + if (likely (shndxdata_scn != NULL)) + { +- if (unlikely ((ndx + 1) * sizeof (Elf32_Word) > shndxdata_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Word) ++ || unlikely ((ndx + 1) * sizeof (Elf32_Word) ++ > shndxdata_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -110,7 +112,8 @@ gelf_getsymshndx (symdata, shndxdata, nd + table entries has to be adopted. The user better has provided + a buffer where we can store the information. While copying the + data we are converting the format. */ +- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata->d_size)) ++ if (INVALID_NDX (ndx, Elf32_Sym) ++ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata->d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -139,7 +142,8 @@ gelf_getsymshndx (symdata, shndxdata, nd + + /* The data is already in the correct form. Just make sure the + index is OK. */ +- if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > symdata->d_size)) ++ if (INVALID_NDX (ndx, GElf_Sym) ++ || unlikely ((ndx + 1) * sizeof (GElf_Sym) > symdata->d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils-0.136/libelf/gelf_getversym.c.robustify ++++ elfutils-0.136/libelf/gelf_getversym.c +@@ -92,7 +92,8 @@ gelf_getversym (data, ndx, dst) + + /* The data is already in the correct form. Just make sure the + index is OK. */ +- if (unlikely ((ndx + 1) * sizeof (GElf_Versym) > data->d_size)) ++ if (INVALID_NDX (ndx, GElf_Versym) ++ || unlikely ((ndx + 1) * sizeof (GElf_Versym) > data->d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + result = NULL; +--- elfutils-0.136/libelf/gelf_update_dyn.c.robustify ++++ elfutils-0.136/libelf/gelf_update_dyn.c +@@ -71,12 +71,6 @@ gelf_update_dyn (data, ndx, src) + if (data == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_DYN)) + { + /* The type of the data better should match. */ +@@ -102,7 +96,8 @@ gelf_update_dyn (data, ndx, src) + } + + /* Check whether we have to resize the data buffer. */ +- if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Dyn) ++ || unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -116,7 +111,8 @@ gelf_update_dyn (data, ndx, src) + else + { + /* Check whether we have to resize the data buffer. */ +- if (unlikely ((ndx + 1) * sizeof (Elf64_Dyn) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Dyn) ++ || unlikely ((ndx + 1) * sizeof (Elf64_Dyn) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils-0.136/libelf/gelf_update_lib.c.robustify ++++ elfutils-0.136/libelf/gelf_update_lib.c +@@ -68,12 +68,6 @@ gelf_update_lib (data, ndx, src) + if (data == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data; + if (unlikely (data_scn->d.d_type != ELF_T_LIB)) + { +@@ -87,7 +81,8 @@ gelf_update_lib (data, ndx, src) + + /* Check whether we have to resize the data buffer. */ + int result = 0; +- if (unlikely ((ndx + 1) * sizeof (Elf64_Lib) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Lib) ++ || unlikely ((ndx + 1) * sizeof (Elf64_Lib) > data_scn->d.d_size)) + __libelf_seterrno (ELF_E_INVALID_INDEX); + else + { +--- elfutils-0.136/libelf/gelf_update_move.c.robustify ++++ elfutils-0.136/libelf/gelf_update_move.c +@@ -75,7 +75,7 @@ gelf_update_move (data, ndx, src) + assert (sizeof (GElf_Move) == sizeof (Elf64_Move)); + + /* Check whether we have to resize the data buffer. */ +- if (unlikely (ndx < 0) ++ if (INVALID_NDX (ndx, GElf_Move) + || unlikely ((ndx + 1) * sizeof (GElf_Move) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); +--- elfutils-0.136/libelf/gelf_update_rela.c.robustify ++++ elfutils-0.136/libelf/gelf_update_rela.c +@@ -68,12 +68,6 @@ gelf_update_rela (Elf_Data *dst, int ndx + if (dst == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_RELA)) + { + /* The type of the data better should match. */ +@@ -101,7 +95,8 @@ gelf_update_rela (Elf_Data *dst, int ndx + } + + /* Check whether we have to resize the data buffer. */ +- if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Rela) ++ || unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -117,7 +112,8 @@ gelf_update_rela (Elf_Data *dst, int ndx + else + { + /* Check whether we have to resize the data buffer. */ +- if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Rela) ++ || unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils-0.136/libelf/gelf_update_rel.c.robustify ++++ elfutils-0.136/libelf/gelf_update_rel.c +@@ -68,12 +68,6 @@ gelf_update_rel (Elf_Data *dst, int ndx, + if (dst == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_REL)) + { + /* The type of the data better should match. */ +@@ -99,7 +93,8 @@ gelf_update_rel (Elf_Data *dst, int ndx, + } + + /* Check whether we have to resize the data buffer. */ +- if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Rel) ++ || unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -114,7 +109,8 @@ gelf_update_rel (Elf_Data *dst, int ndx, + else + { + /* Check whether we have to resize the data buffer. */ +- if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Rel) ++ || unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils-0.136/libelf/gelf_update_sym.c.robustify ++++ elfutils-0.136/libelf/gelf_update_sym.c +@@ -72,12 +72,6 @@ gelf_update_sym (data, ndx, src) + if (data == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_SYM)) + { + /* The type of the data better should match. */ +@@ -102,7 +96,8 @@ gelf_update_sym (data, ndx, src) + } + + /* Check whether we have to resize the data buffer. */ +- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Sym) ++ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -125,7 +120,8 @@ gelf_update_sym (data, ndx, src) + else + { + /* Check whether we have to resize the data buffer. */ +- if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Sym) ++ || unlikely ((ndx + 1) * sizeof (Elf64_Sym) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils-0.136/libelf/gelf_update_syminfo.c.robustify ++++ elfutils-0.136/libelf/gelf_update_syminfo.c +@@ -72,12 +72,6 @@ gelf_update_syminfo (data, ndx, src) + if (data == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (data_scn->d.d_type != ELF_T_SYMINFO)) + { + /* The type of the data better should match. */ +@@ -93,7 +87,8 @@ gelf_update_syminfo (data, ndx, src) + rwlock_wrlock (scn->elf->lock); + + /* Check whether we have to resize the data buffer. */ +- if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data_scn->d.d_size)) ++ if (INVALID_NDX (ndx, GElf_Syminfo) ++ || unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils-0.136/libelf/gelf_update_symshndx.c.robustify ++++ elfutils-0.136/libelf/gelf_update_symshndx.c +@@ -77,12 +77,6 @@ gelf_update_symshndx (symdata, shndxdata + if (symdata == NULL) + return 0; + +- if (unlikely (ndx < 0)) +- { +- __libelf_seterrno (ELF_E_INVALID_INDEX); +- return 0; +- } +- + if (unlikely (symdata_scn->d.d_type != ELF_T_SYM)) + { + /* The type of the data better should match. */ +@@ -128,7 +122,8 @@ gelf_update_symshndx (symdata, shndxdata + } + + /* Check whether we have to resize the data buffer. */ +- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf32_Sym) ++ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +@@ -151,7 +146,8 @@ gelf_update_symshndx (symdata, shndxdata + else + { + /* Check whether we have to resize the data buffer. */ +- if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size)) ++ if (INVALID_NDX (ndx, Elf64_Sym) ++ || unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); + goto out; +--- elfutils-0.136/libelf/gelf_update_versym.c.robustify ++++ elfutils-0.136/libelf/gelf_update_versym.c +@@ -75,7 +75,7 @@ gelf_update_versym (data, ndx, src) + assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym)); + + /* Check whether we have to resize the data buffer. */ +- if (unlikely (ndx < 0) ++ if (INVALID_NDX (ndx, GElf_Versym) + || unlikely ((ndx + 1) * sizeof (GElf_Versym) > data_scn->d.d_size)) + { + __libelf_seterrno (ELF_E_INVALID_INDEX); +--- elfutils-0.136/libelf/libelfP.h.robustify ++++ elfutils-0.136/libelf/libelfP.h +@@ -611,4 +611,13 @@ extern uint32_t __libelf_crc32 (uint32_t + /* Align offset to 4 bytes as needed for note name and descriptor data. */ + #define NOTE_ALIGN(n) (((n) + 3) & -4U) + ++/* Convenience macro. Assumes int NDX and TYPE with size at least ++ 2 bytes. */ ++#if SIZE_MAX > 4294967295U ++# define INVALID_NDX(ndx, type) unlikely (ndx < 0) ++#else ++# define INVALID_NDX(ndx, type) \ ++ unlikely ((unsigned int) (ndx) >= SIZE_MAX / sizeof (type)) ++#endif ++ + #endif /* libelfP.h */ +--- elfutils-0.136/src/elflint.c.robustify ++++ elfutils-0.136/src/elflint.c +@@ -131,6 +131,9 @@ static uint32_t shstrndx; + /* Array to count references in section groups. */ + static int *scnref; + ++/* Number of sections. */ ++static unsigned int shnum; ++ + + int + main (int argc, char *argv[]) +@@ -320,10 +323,19 @@ section_name (Ebl *ebl, int idx) + { + GElf_Shdr shdr_mem; + GElf_Shdr *shdr; ++ const char *ret; ++ ++ if ((unsigned int) idx > shnum) ++ return ""; + + shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem); ++ if (shdr == NULL) ++ return ""; + +- return elf_strptr (ebl->elf, shstrndx, shdr->sh_name); ++ ret = elf_strptr (ebl->elf, shstrndx, shdr->sh_name); ++ if (ret == NULL) ++ return ""; ++ return ret; + } + + +@@ -345,10 +357,6 @@ static const int valid_e_machine[] = + (sizeof (valid_e_machine) / sizeof (valid_e_machine[0])) + + +-/* Number of sections. */ +-static unsigned int shnum; +- +- + static void + check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size) + { +@@ -613,7 +621,8 @@ section [%2d] '%s': symbol table cannot + } + } + +- if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT)) ++ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT); ++ if (shdr->sh_entsize != sh_entsize) + ERROR (gettext ("\ + section [%2u] '%s': entry size is does not match ElfXX_Sym\n"), + idx, section_name (ebl, idx)); +@@ -651,7 +660,7 @@ section [%2d] '%s': XINDEX for zeroth en + xndxscnidx, section_name (ebl, xndxscnidx)); + } + +- for (size_t cnt = 1; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) ++ for (size_t cnt = 1; cnt < shdr->sh_size / sh_entsize; ++cnt) + { + sym = gelf_getsymshndx (data, xndxdata, cnt, &sym_mem, &xndx); + if (sym == NULL) +@@ -671,7 +680,8 @@ section [%2d] '%s': symbol %zu: invalid + else + { + name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name); +- assert (name != NULL); ++ assert (name != NULL ++ || strshdr->sh_type != SHT_STRTAB); + } + + if (sym->st_shndx == SHN_XINDEX) +@@ -1001,9 +1011,11 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e + { + GElf_Shdr rcshdr_mem; + const GElf_Shdr *rcshdr = gelf_getshdr (scn, &rcshdr_mem); +- assert (rcshdr != NULL); + +- if (rcshdr->sh_type == SHT_DYNAMIC) ++ if (rcshdr == NULL) ++ break; ++ ++ if (rcshdr->sh_type == SHT_DYNAMIC && rcshdr->sh_entsize) + { + /* Found the dynamic section. Look through it. */ + Elf_Data *d = elf_getdata (scn, NULL); +@@ -1013,7 +1025,9 @@ is_rel_dyn (Ebl *ebl, const GElf_Ehdr *e + { + GElf_Dyn dyn_mem; + GElf_Dyn *dyn = gelf_getdyn (d, cnt, &dyn_mem); +- assert (dyn != NULL); ++ ++ if (dyn == NULL) ++ break; + + if (dyn->d_tag == DT_RELCOUNT) + { +@@ -1027,7 +1041,9 @@ section [%2d] '%s': DT_RELCOUNT used for + /* Does the number specified number of relative + relocations exceed the total number of + relocations? */ +- if (dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize) ++ if (shdr->sh_entsize != 0 ++ && dyn->d_un.d_val > (shdr->sh_size ++ / shdr->sh_entsize)) + ERROR (gettext ("\ + section [%2d] '%s': DT_RELCOUNT value %d too high for this section\n"), + idx, section_name (ebl, idx), +@@ -1187,7 +1203,8 @@ section [%2d] '%s': no relocations for m + } + } + +- if (shdr->sh_entsize != gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT)) ++ size_t sh_entsize = gelf_fsize (ebl->elf, reltype, 1, EV_CURRENT); ++ if (shdr->sh_entsize != sh_entsize) + ERROR (gettext (reltype == ELF_T_RELA ? "\ + section [%2d] '%s': section entry size does not match ElfXX_Rela\n" : "\ + section [%2d] '%s': section entry size does not match ElfXX_Rel\n"), +@@ -1410,7 +1427,8 @@ check_rela (Ebl *ebl, GElf_Ehdr *ehdr, G + Elf_Data *symdata = elf_getdata (symscn, NULL); + enum load_state state = state_undecided; + +- for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) ++ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT); ++ for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) + { + GElf_Rela rela_mem; + GElf_Rela *rela = gelf_getrela (data, cnt, &rela_mem); +@@ -1460,7 +1478,8 @@ check_rel (Ebl *ebl, GElf_Ehdr *ehdr, GE + Elf_Data *symdata = elf_getdata (symscn, NULL); + enum load_state state = state_undecided; + +- for (size_t cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) ++ size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT); ++ for (size_t cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) + { + GElf_Rel rel_mem; + GElf_Rel *rel = gelf_getrel (data, cnt, &rel_mem); +@@ -1563,7 +1582,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)); +@@ -1573,7 +1593,7 @@ section [%2d] '%s': section entry size d + idx, section_name (ebl, idx)); + + bool non_null_warned = false; +- for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) ++ for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) + { + GElf_Dyn dyn_mem; + GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dyn_mem); +@@ -1854,6 +1874,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 ("\ +@@ -1880,6 +1902,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")); +@@ -1922,7 +1950,7 @@ section [%2d] '%s': hash table section i + + size_t maxidx = nchain; + +- if (symshdr != NULL) ++ if (symshdr != NULL && symshdr->sh_entsize != 0) + { + size_t symsize = symshdr->sh_size / symshdr->sh_entsize; + +@@ -1933,18 +1961,28 @@ section [%2d] '%s': hash table section i + maxidx = symsize; + } + ++ Elf32_Word *buf = (Elf32_Word *) data->d_buf; ++ Elf32_Word *end = (Elf32_Word *) ((char *) data->d_buf + shdr->sh_size); + size_t cnt; + for (cnt = 2; cnt < 2 + nbucket; ++cnt) +- if (((Elf32_Word *) data->d_buf)[cnt] >= maxidx) ++ { ++ if (buf + cnt >= end) ++ break; ++ else if (buf[cnt] >= maxidx) + ERROR (gettext ("\ + section [%2d] '%s': hash bucket reference %zu out of bounds\n"), + idx, section_name (ebl, idx), cnt - 2); ++ } + + for (; cnt < 2 + nbucket + nchain; ++cnt) +- if (((Elf32_Word *) data->d_buf)[cnt] >= maxidx) ++ { ++ if (buf + cnt >= end) ++ break; ++ else if (buf[cnt] >= maxidx) + ERROR (gettext ("\ + section [%2d] '%s': hash chain reference %zu out of bounds\n"), + idx, section_name (ebl, idx), cnt - 2 - nbucket); ++ } + } + + +@@ -1974,18 +2012,28 @@ section [%2d] '%s': hash table section i + maxidx = symsize; + } + ++ Elf64_Xword *buf = (Elf64_Xword *) data->d_buf; ++ Elf64_Xword *end = (Elf64_Xword *) ((char *) data->d_buf + shdr->sh_size); + size_t cnt; + for (cnt = 2; cnt < 2 + nbucket; ++cnt) +- if (((Elf64_Xword *) data->d_buf)[cnt] >= maxidx) ++ { ++ if (buf + cnt >= end) ++ break; ++ else if (buf[cnt] >= maxidx) + ERROR (gettext ("\ + section [%2d] '%s': hash bucket reference %zu out of bounds\n"), + idx, section_name (ebl, idx), cnt - 2); ++ } + + for (; cnt < 2 + nbucket + nchain; ++cnt) +- if (((Elf64_Xword *) data->d_buf)[cnt] >= maxidx) ++ { ++ if (buf + cnt >= end) ++ break; ++ else if (buf[cnt] >= maxidx) + ERROR (gettext ("\ + section [%2d] '%s': hash chain reference %" PRIu64 " out of bounds\n"), +- idx, section_name (ebl, idx), (uint64_t) (cnt - 2 - nbucket)); ++ idx, section_name (ebl, idx), (uint64_t) cnt - 2 - nbucket); ++ } + } + + +@@ -2010,7 +2058,7 @@ section [%2d] '%s': bitmask size not pow + if (shdr->sh_size < (4 + bitmask_words + nbuckets) * sizeof (Elf32_Word)) + { + ERROR (gettext ("\ +-section [%2d] '%s': hash table section is too small (is %ld, expected at least%ld)\n"), ++section [%2d] '%s': hash table section is too small (is %ld, expected at least %ld)\n"), + idx, section_name (ebl, idx), (long int) shdr->sh_size, + (long int) ((4 + bitmask_words + nbuckets) * sizeof (Elf32_Word))); + return; +@@ -2682,8 +2730,9 @@ section [%2d] '%s' refers in sh_link to + + /* The number of elements in the version symbol table must be the + same as the number of symbols. */ +- if (shdr->sh_size / shdr->sh_entsize +- != symshdr->sh_size / symshdr->sh_entsize) ++ if (shdr->sh_entsize && symshdr->sh_entsize ++ && (shdr->sh_size / shdr->sh_entsize ++ != symshdr->sh_size / symshdr->sh_entsize)) + ERROR (gettext ("\ + section [%2d] '%s' has different number of entries than symbol table [%2d] '%s'\n"), + idx, section_name (ebl, idx), +--- elfutils-0.136/src/readelf.c.robustify ++++ elfutils-0.136/src/readelf.c +@@ -1111,6 +1111,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G + Elf32_Word *grpref = (Elf32_Word *) data->d_buf; + + GElf_Sym sym_mem; ++ GElf_Sym *sym = gelf_getsym (symdata, shdr->sh_info, &sym_mem); ++ + printf ((grpref[0] & GRP_COMDAT) + ? ngettext ("\ + \nCOMDAT section group [%2zu] '%s' with signature '%s' contains %zu entry:\n", +@@ -1123,8 +1125,8 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, G + data->d_size / sizeof (Elf32_Word) - 1), + elf_ndxscn (scn), + elf_strptr (ebl->elf, shstrndx, shdr->sh_name), +- elf_strptr (ebl->elf, symshdr->sh_link, +- gelf_getsym (symdata, shdr->sh_info, &sym_mem)->st_name) ++ (sym == NULL ? NULL ++ : elf_strptr (ebl->elf, symshdr->sh_link, sym->st_name)) + ?: gettext (""), + data->d_size / sizeof (Elf32_Word) - 1); + +@@ -1275,7 +1277,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; +@@ -1290,6 +1293,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", + "\ +@@ -1299,9 +1307,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) +@@ -1801,6 +1807,13 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G + error (EXIT_FAILURE, 0, + gettext ("cannot get section header string table index")); + ++ GElf_Shdr glink_mem; ++ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), ++ &glink_mem); ++ if (glink == NULL) ++ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), ++ elf_ndxscn (scn)); ++ + /* Now we can compute the number of entries in the section. */ + unsigned int nsyms = data->d_size / (class == ELFCLASS32 + ? sizeof (Elf32_Sym) +@@ -1811,15 +1824,12 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, G + nsyms), + (unsigned int) elf_ndxscn (scn), + elf_strptr (ebl->elf, shstrndx, shdr->sh_name), nsyms); +- GElf_Shdr glink; + printf (ngettext (" %lu local symbol String table: [%2u] '%s'\n", + " %lu local symbols String table: [%2u] '%s'\n", + shdr->sh_info), + (unsigned long int) shdr->sh_info, + (unsigned int) shdr->sh_link, +- elf_strptr (ebl->elf, shstrndx, +- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), +- &glink)->sh_name)); ++ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); + + fputs_unlocked (class == ELFCLASS32 + ? gettext ("\ +@@ -2055,7 +2065,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", + "\ +@@ -2066,9 +2082,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; ) +@@ -2121,8 +2135,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", + "\ +@@ -2134,9 +2154,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; ) +@@ -2398,8 +2416,14 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, G + filename = NULL; + } + ++ GElf_Shdr glink_mem; ++ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), ++ &glink_mem); ++ if (glink == NULL) ++ error (EXIT_FAILURE, 0, gettext ("invalid sh_link value in section %Zu"), ++ elf_ndxscn (scn)); ++ + /* Print the header. */ +- GElf_Shdr glink; + printf (ngettext ("\ + \nVersion symbols section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'", + "\ +@@ -2411,9 +2435,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) +@@ -2465,7 +2487,17 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn, + for (Elf32_Word cnt = 0; cnt < nbucket; ++cnt) + ++counts[lengths[cnt]]; + +- GElf_Shdr glink; ++ GElf_Shdr glink_mem; ++ GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, ++ shdr->sh_link), ++ &glink_mem); ++ if (glink == NULL) ++ { ++ error (0, 0, gettext ("invalid sh_link value in section %Zu"), ++ elf_ndxscn (scn)); ++ return; ++ } ++ + printf (ngettext ("\ + \nHistogram for bucket list length in section [%2u] '%s' (total of %d bucket):\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", + "\ +@@ -2478,9 +2510,7 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn, + shdr->sh_addr, + shdr->sh_offset, + (unsigned int) shdr->sh_link, +- elf_strptr (ebl->elf, shstrndx, +- gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), +- &glink)->sh_name)); ++ elf_strptr (ebl->elf, shstrndx, glink->sh_name)); + + if (extrastr != NULL) + fputs (extrastr, stdout); +@@ -4039,6 +4069,16 @@ print_debug_aranges_section (Dwfl_Module + return; + } + ++ GElf_Shdr glink_mem; ++ GElf_Shdr *glink; ++ glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem); ++ if (glink == NULL) ++ { ++ error (0, 0, gettext ("invalid sh_link value in section %Zu"), ++ elf_ndxscn (scn)); ++ return; ++ } ++ + printf (ngettext ("\ + \nDWARF section '%s' at offset %#" PRIx64 " contains %zu entry:\n", + "\ +--- elfutils-0.136/src/strip.c.robustify ++++ elfutils-0.136/src/strip.c +@@ -544,6 +544,11 @@ handle_elf (int fd, Elf *elf, const char + goto fail_close; + } + ++ if (shstrndx >= shnum) ++ goto illformed; ++ ++#define elf_assert(test) do { if (!(test)) goto illformed; } while (0) ++ + /* Storage for section information. We leave room for two more + entries since we unconditionally create a section header string + table. Maybe some weird tool created an ELF file without one. +@@ -565,7 +570,7 @@ handle_elf (int fd, Elf *elf, const char + { + /* This should always be true (i.e., there should not be any + holes in the numbering). */ +- assert (elf_ndxscn (scn) == cnt); ++ elf_assert (elf_ndxscn (scn) == cnt); + + shdr_info[cnt].scn = scn; + +@@ -578,6 +583,7 @@ handle_elf (int fd, Elf *elf, const char + shdr_info[cnt].shdr.sh_name); + if (shdr_info[cnt].name == NULL) + { ++ illformed: + error (0, 0, gettext ("illformed file '%s'"), fname); + goto fail_close; + } +@@ -587,6 +593,8 @@ handle_elf (int fd, Elf *elf, const char + + /* Remember the shdr.sh_link value. */ + shdr_info[cnt].old_sh_link = shdr_info[cnt].shdr.sh_link; ++ if (shdr_info[cnt].old_sh_link >= shnum) ++ goto illformed; + + /* Sections in files other than relocatable object files which + are not loaded can be freely moved by us. In relocatable +@@ -599,7 +607,7 @@ handle_elf (int fd, Elf *elf, const char + appropriate reference. */ + if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX)) + { +- assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0); ++ elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0); + shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx = cnt; + } + else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GROUP)) +@@ -616,7 +624,12 @@ handle_elf (int fd, Elf *elf, const char + for (inner = 1; + inner < shdr_info[cnt].data->d_size / sizeof (Elf32_Word); + ++inner) ++ { ++ if (grpref[inner] < shnum) + shdr_info[grpref[inner]].group_idx = cnt; ++ else ++ goto illformed; ++ } + + if (inner == 1 || (inner == 2 && (grpref[0] & GRP_COMDAT) == 0)) + /* If the section group contains only one element and this +@@ -627,7 +640,7 @@ handle_elf (int fd, Elf *elf, const char + } + else if (unlikely (shdr_info[cnt].shdr.sh_type == SHT_GNU_versym)) + { +- assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0); ++ elf_assert (shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0); + shdr_info[shdr_info[cnt].shdr.sh_link].version_idx = cnt; + } + +@@ -635,7 +648,7 @@ handle_elf (int fd, Elf *elf, const char + discarded right away. */ + if ((shdr_info[cnt].shdr.sh_flags & SHF_GROUP) != 0) + { +- assert (shdr_info[cnt].group_idx != 0); ++ elf_assert (shdr_info[cnt].group_idx != 0); + + if (shdr_info[shdr_info[cnt].group_idx].idx == 0) + { +@@ -710,11 +723,15 @@ handle_elf (int fd, Elf *elf, const char + { + /* If a relocation section is marked as being removed make + sure the section it is relocating is removed, too. */ +- if ((shdr_info[cnt].shdr.sh_type == SHT_REL ++ if (shdr_info[cnt].shdr.sh_type == SHT_REL + || shdr_info[cnt].shdr.sh_type == SHT_RELA) +- && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) ++ { ++ if (shdr_info[cnt].shdr.sh_info >= shnum) ++ goto illformed; ++ else if (shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) + shdr_info[cnt].idx = 1; + } ++ } + + if (shdr_info[cnt].idx == 1) + { +@@ -741,7 +758,7 @@ handle_elf (int fd, Elf *elf, const char + if (shdr_info[cnt].symtab_idx != 0 + && shdr_info[shdr_info[cnt].symtab_idx].data == NULL) + { +- assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB); ++ elf_assert (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB); + + shdr_info[shdr_info[cnt].symtab_idx].data + = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, +@@ -781,6 +798,9 @@ handle_elf (int fd, Elf *elf, const char + else if (scnidx == SHN_XINDEX) + scnidx = xndx; + ++ if (scnidx >= shnum) ++ goto illformed; ++ + if (shdr_info[scnidx].idx == 0) + /* This symbol table has a real symbol in + a discarded section. So preserve the +@@ -811,12 +831,16 @@ handle_elf (int fd, Elf *elf, const char + } + + /* Handle references through sh_info. */ +- if (SH_INFO_LINK_P (&shdr_info[cnt].shdr) +- && shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0) ++ if (SH_INFO_LINK_P (&shdr_info[cnt].shdr)) ++ { ++ if (shdr_info[cnt].shdr.sh_info >= shnum) ++ goto illformed; ++ else if ( shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0) + { + shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1; + changes |= shdr_info[cnt].shdr.sh_info < cnt; + } ++ } + + /* Mark the section as investigated. */ + shdr_info[cnt].idx = 2; +@@ -954,7 +978,7 @@ handle_elf (int fd, Elf *elf, const char + error (EXIT_FAILURE, 0, gettext ("while generating output file: %s"), + elf_errmsg (-1)); + +- assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); ++ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); + + /* Add this name to the section header string table. */ + shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0); +@@ -991,7 +1015,7 @@ handle_elf (int fd, Elf *elf, const char + error (EXIT_FAILURE, 0, + gettext ("while create section header section: %s"), + elf_errmsg (-1)); +- assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); ++ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx); + + shdr_info[cnt].data = elf_newdata (shdr_info[cnt].newscn); + if (shdr_info[cnt].data == NULL) +@@ -1047,7 +1071,7 @@ handle_elf (int fd, Elf *elf, const char + error (EXIT_FAILURE, 0, + gettext ("while create section header section: %s"), + elf_errmsg (-1)); +- assert (elf_ndxscn (shdr_info[cnt].newscn) == idx); ++ elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == idx); + + /* Finalize the string table and fill in the correct indices in the + section headers. */ +@@ -1137,20 +1161,20 @@ handle_elf (int fd, Elf *elf, const char + shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn, + NULL); + +- assert ((versiondata->d_size / sizeof (Elf32_Word)) ++ elf_assert ((versiondata->d_size / sizeof (Elf32_Word)) + >= shdr_info[cnt].data->d_size / elsize); + } + + if (shdr_info[cnt].version_idx != 0) + { +- assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM); ++ elf_assert (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM); + /* This section has associated version + information. We have to modify that + information, too. */ + versiondata = elf_getdata (shdr_info[shdr_info[cnt].version_idx].scn, + NULL); + +- assert ((versiondata->d_size / sizeof (GElf_Versym)) ++ elf_assert ((versiondata->d_size / sizeof (GElf_Versym)) + >= shdr_info[cnt].data->d_size / elsize); + } + +@@ -1205,7 +1229,7 @@ handle_elf (int fd, Elf *elf, const char + sec = shdr_info[sym->st_shndx].idx; + else + { +- assert (shndxdata != NULL); ++ elf_assert (shndxdata != NULL); + + sec = shdr_info[xshndx].idx; + } +@@ -1226,7 +1250,7 @@ handle_elf (int fd, Elf *elf, const char + nxshndx = sec; + } + +- assert (sec < SHN_LORESERVE || shndxdata != NULL); ++ elf_assert (sec < SHN_LORESERVE || shndxdata != NULL); + + if ((inner != destidx || nshndx != sym->st_shndx + || (shndxdata != NULL && nxshndx != xshndx)) +@@ -1250,7 +1274,7 @@ handle_elf (int fd, Elf *elf, const char + || shdr_info[cnt].debug_data == NULL) + /* This is a section symbol for a section which has + been removed. */ +- assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION); ++ elf_assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION); + } + + if (destidx != inner) +@@ -1437,11 +1461,11 @@ handle_elf (int fd, Elf *elf, const char + { + GElf_Sym sym_mem; + GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem); +- assert (sym != NULL); ++ elf_assert (sym != NULL); + + const char *name = elf_strptr (elf, strshndx, + sym->st_name); +- assert (name != NULL); ++ elf_assert (name != NULL); + size_t hidx = elf_hash (name) % nbucket; + + if (bucket[hidx] == 0) +@@ -1460,7 +1484,7 @@ handle_elf (int fd, Elf *elf, const char + else + { + /* Alpha and S390 64-bit use 64-bit SHT_HASH entries. */ +- assert (shdr_info[cnt].shdr.sh_entsize ++ elf_assert (shdr_info[cnt].shdr.sh_entsize + == sizeof (Elf64_Xword)); + + Elf64_Xword *bucket = (Elf64_Xword *) hashd->d_buf; +@@ -1491,11 +1515,11 @@ handle_elf (int fd, Elf *elf, const char + { + GElf_Sym sym_mem; + GElf_Sym *sym = gelf_getsym (symd, inner, &sym_mem); +- assert (sym != NULL); ++ elf_assert (sym != NULL); + + const char *name = elf_strptr (elf, strshndx, + sym->st_name); +- assert (name != NULL); ++ elf_assert (name != NULL); + size_t hidx = elf_hash (name) % nbucket; + + if (bucket[hidx] == 0) diff --git a/elfutils.spec b/elfutils.spec index 1f655f5..d2d3430 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,43 +1,45 @@ -%define version 0.106 -%define release 3 +%define eu_version 0.137 +%define eu_release 3 -%define gpl 0 %if %{?_with_compat:1}%{!?_with_compat:0} %define compat 1 %else %define compat 0 %endif -Summary: A collection of utilities and DSOs to handle compiled objects. +%if 0%{?fedora} >= 8 +%define scanf_has_m 1 +%endif +%if 0%{?rhel} >= 6 +%define scanf_has_m 1 +%endif + +%if 0%{?fedora} >= 7 +%define separate_devel_static 1 +%endif +%if 0%{?rhel} >= 6 +%define separate_devel_static 1 +%endif + +Summary: A collection of utilities and DSOs to handle compiled objects Name: elfutils -Version: %{version} +Version: %{eu_version} %if !%{compat} -Release: %{release} +Release: %{eu_release}%{?dist} %else -Release: 0.%{release} -%endif -%if %{gpl} -License: GPL -%else -License: OSL +Release: 0.%{eu_release} %endif +License: GPLv2 with exceptions Group: Development/Tools -#URL: file://home/devel/drepper/ -Source: elfutils-%{version}.tar.gz -Patch1: elfutils-0.106-libdw-compile.patch -%if %{compat} -Patch100: elfutils-portability.patch -Patch101: elfutils-bswap.patch -%endif -Obsoletes: libelf libelf-devel -Requires: elfutils-libelf = %{version}-%{release} -%if %{gpl} -Requires: binutils >= 2.14.90.0.4-26.2 -%endif +URL: https://fedorahosted.org/elfutils/ +Source: http://fedorahosted.org/releases/e/l/elfutils/%{name}-%{version}.tar.gz +Patch1: elfutils-portability.patch +Patch2: elfutils-robustify.patch +Patch3: elfutils-0.137-fixes.patch +Requires: elfutils-libelf-%{_arch} = %{version}-%{release} +Requires: elfutils-libs-%{_arch} = %{version}-%{release} -# ExcludeArch: xxx - -BuildRoot: %{_tmppath}/%{name}-root +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: bison >= 1.875 BuildRequires: flex >= 2.5.4a BuildRequires: bzip2 @@ -57,20 +59,30 @@ Elfutils is a collection of utilities, including ld (a linker), nm (for listing symbols from object files), size (for listing the section sizes of an object or archive file), strip (for discarding symbols), readelf (to see the raw ELF file structures), and elflint -(to check for well-formed ELF files). Also included are numerous -helper libraries which implement DWARF, ELF, and machine-specific ELF -handling. +(to check for well-formed ELF files). + + +%package libs +Summary: Libraries to handle compiled objects +Group: Development/Tools +Provides: elfutils-libs-%{_arch} = %{version}-%{release} +Requires: elfutils-libelf-%{_arch} = %{version}-%{release} + +%description libs +The elfutils-libs package contains libraries which implement DWARF, ELF, +and machine-specific ELF handling. These libraries are used by the programs +in the elfutils package. The elfutils-devel package enables building +other programs using these libraries. %package devel -Summary: Development libraries to handle compiled objects. +Summary: Development libraries to handle compiled objects Group: Development/Tools -%if %{gpl} -License: GPL -%else -License: OSL +Provides: elfutils-devel-%{_arch} = %{version}-%{release} +Requires: elfutils-libs-%{_arch} = %{version}-%{release} +Requires: elfutils-libelf-devel-%{_arch} = %{version}-%{release} +%if !0%{?separate_devel_static} +Requires: elfutils-devel-static-%{_arch} = %{version}-%{release} %endif -Requires: elfutils = %{version}-%{release} -Requires: elfutils-libelf-devel = %{version}-%{release} %description devel The elfutils-devel package contains the libraries to create @@ -79,12 +91,22 @@ higher-level ELF access functionality. libdw provides access to the DWARF debugging information. libasm provides a programmable assembler interface. -%package libelf -Summary: Library to read and write ELF files. +%package devel-static +Summary: Static archives to handle compiled objects Group: Development/Tools -%if %{gpl} -License: GPL -%endif +Provides: elfutils-devel-static-%{_arch} = %{version}-%{release} +Requires: elfutils-devel-%{_arch} = %{version}-%{release} +Requires: elfutils-libelf-devel-static-%{_arch} = %{version}-%{release} + +%description devel-static +The elfutils-devel-static package contains the static archives +with the code to handle compiled objects. + +%package libelf +Summary: Library to read and write ELF files +Group: Development/Tools +Provides: elfutils-libelf-%{_arch} = %{version}-%{release} +Obsoletes: libelf <= 0.8.2-2 %description libelf The elfutils-libelf package provides a DSO which allows reading and @@ -95,11 +117,12 @@ elfutils package use it also to generate new ELF files. %package libelf-devel Summary: Development support for libelf Group: Development/Tools -Requires: elfutils-libelf = %{version}-%{release} -Conflicts: libelf-devel -%if %{gpl} -License: GPL +Provides: elfutils-libelf-devel-%{_arch} = %{version}-%{release} +Requires: elfutils-libelf-%{_arch} = %{version}-%{release} +%if !0%{?separate_devel_static} +Requires: elfutils-libelf-devel-static-%{_arch} = %{version}-%{release} %endif +Obsoletes: libelf-devel <= 0.8.2-2 %description libelf-devel The elfutils-libelf-devel package contains the libraries to create @@ -107,66 +130,73 @@ applications for handling compiled objects. libelf allows you to access the internals of the ELF object file format, so you can see the different sections of an ELF file. +%package libelf-devel-static +Summary: Static archive of libelf +Group: Development/Tools +Provides: elfutils-libelf-devel-static-%{_arch} = %{version}-%{release} +Requires: elfutils-libelf-devel-%{_arch} = %{version}-%{release} + +%description libelf-devel-static +The elfutils-libelf-static package contains the static archive +for libelf. + %prep %setup -q -%patch1 -p1 +%if !0%{?scanf_has_m} +sed -i.scanf-m -e 's/%m/%a/' tests/line2addr.c +%endif %if %{compat} -%patch100 -p1 -%patch101 -p1 +%patch1 -p1 -b .portability sleep 1 find . \( -name Makefile.in -o -name aclocal.m4 \) -print | xargs touch sleep 1 find . \( -name configure -o -name config.h.in \) -print | xargs touch %endif +%patch2 -p1 -b .robustify + +%patch3 -p1 -b .fixes + +find . -name \*.sh ! -perm -0100 -print | xargs chmod +x + %build -mkdir build-%{_target_platform} -cd build-%{_target_platform} -cat > configure <<\EOF -#!/bin/sh -exec ../configure "$@" -EOF -chmod +x configure -%configure --enable-shared -make -cd .. +# Remove -Wall from default flags. The makefiles enable enough warnings +# themselves, and they use -Werror. Appending -Wall defeats the cases where +# the makefiles disable some specific warnings for specific code. +RPM_OPT_FLAGS=${RPM_OPT_FLAGS/-Wall/} + +%if %{compat} +# Some older glibc headers can run afoul of -Werror all by themselves. +# Disabling the fancy inlines avoids those problems. +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -D__NO_INLINE__" +%endif + +%configure CFLAGS="$RPM_OPT_FLAGS -fexceptions" +make -s %{?_smp_mflags} %install rm -rf ${RPM_BUILD_ROOT} -mkdir -p ${RPM_BUILD_ROOT}%{_prefix} - -cd build-%{_target_platform} -%makeinstall +make -s install DESTDIR=${RPM_BUILD_ROOT} chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/lib*.so* -%if !%{gpl} chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/elfutils/lib*.so* -%endif -cd .. - -%if !%{gpl} # XXX Nuke unpackaged files { cd ${RPM_BUILD_ROOT} rm -f .%{_bindir}/eu-ld - rm -f .%{_includedir}/elfutils/libasm.h - rm -f .%{_libdir}/libasm-%{version}.so - rm -f .%{_libdir}/libasm.a } -%endif %check -cd build-%{_target_platform} -make check +make -s check %clean rm -rf ${RPM_BUILD_ROOT} -%post -p /sbin/ldconfig +%post libs -p /sbin/ldconfig -%postun -p /sbin/ldconfig +%postun libs -p /sbin/ldconfig %post libelf -p /sbin/ldconfig @@ -175,55 +205,329 @@ rm -rf ${RPM_BUILD_ROOT} %files %defattr(-,root,root) %doc README TODO -%if %{gpl} -%doc fake-src/FULL -%endif %{_bindir}/eu-addr2line +%{_bindir}/eu-ar +%{_bindir}/eu-elfcmp %{_bindir}/eu-elflint %{_bindir}/eu-findtextrel %{_bindir}/eu-nm +%{_bindir}/eu-objdump +%{_bindir}/eu-ranlib %{_bindir}/eu-readelf %{_bindir}/eu-size +%{_bindir}/eu-strings %{_bindir}/eu-strip -%if !%{gpl} #%{_bindir}/eu-ld -#%{_libdir}/libasm-%{version}.so +%{_bindir}/eu-unstrip +%{_bindir}/eu-make-debug-archive + +%files libs +%defattr(-,root,root) +%{_libdir}/libasm-%{version}.so +%{_libdir}/libasm.so.* %{_libdir}/libdw-%{version}.so -#%{_libdir}/libasm*.so.* -%{_libdir}/libdw*.so.* +%{_libdir}/libdw.so.* %dir %{_libdir}/elfutils %{_libdir}/elfutils/lib*.so -%endif %files devel %defattr(-,root,root) %{_includedir}/dwarf.h %dir %{_includedir}/elfutils %{_includedir}/elfutils/elf-knowledge.h -%if !%{gpl} +%{_includedir}/elfutils/libasm.h %{_includedir}/elfutils/libebl.h %{_includedir}/elfutils/libdw.h -#%{_libdir}/libasm.a +%{_includedir}/elfutils/libdwfl.h %{_libdir}/libebl.a -%{_libdir}/libdw.a -#%{_libdir}/libasm.so +%{_libdir}/libasm.so %{_libdir}/libdw.so -%endif + +%files devel-static +%defattr(-,root,root) +%{_libdir}/libasm.a +%{_libdir}/libdw.a %files libelf %defattr(-,root,root) %{_libdir}/libelf-%{version}.so -%{_libdir}/libelf*.so.* +%{_libdir}/libelf.so.* %files libelf-devel %defattr(-,root,root) %{_includedir}/libelf.h %{_includedir}/gelf.h %{_includedir}/nlist.h -%{_libdir}/libelf.a %{_libdir}/libelf.so +%files libelf-devel-static +%defattr(-,root,root) +%{_libdir}/libelf.a + %changelog +* Wed Oct 1 2008 Roland McGrath - 0.137-3 +- fix libdwfl regression (#462689) + +* Thu Aug 28 2008 Roland McGrath - 0.137-2 +- Update to 0.137 + - libdwfl: bug fixes; new segment interfaces; + all the libdwfl-based tools now support --core=COREFILE option +- Resolves: RHBZ #325021, RHBZ #447416 + +* Mon Jul 7 2008 Tom "spot" Callaway - 0.135-2 +- fix conditional comparison + +* Mon May 12 2008 Roland McGrath - 0.135-1 +- Update to 0.135 + - libdwfl: bug fixes + - eu-strip: changed handling of ET_REL files wrt symbol tables and relocs + +* Wed Apr 9 2008 Roland McGrath - 0.134-1 +- Update to 0.134 + - elflint: backend improvements for sparc, alpha (#204170) + - libdwfl, libelf: bug fixes (#439344, #438867, #438263, #438190) +- Remove Conflicts: libelf-devel from elfutils-libelf-devel. (#435742) + +* Sun Mar 2 2008 Roland McGrath - 0.133-2 +- Update to 0.133 + - readelf, elflint, libebl: SHT_GNU_ATTRIBUTE section handling (readelf -A) + - readelf: core note handling for NT_386_TLS, NT_PPC_SPE, Alpha NT_AUXV + - libdwfl: bug fixes and optimization in relocation handling + - elfcmp: bug fix for non-allocated section handling + - ld: implement newer features of binutils linker. +- Install eu-objdump and libasm, now has limited disassembler support. + +* Mon Jan 21 2008 Roland McGrath - 0.132-3 +- Update to 0.132 + - libelf: Use loff_t instead of off64_t in libelf.h header. (#377241) + - eu-readelf: Fix handling of ET_REL files in archives. + - libcpu: Implement x86 and x86-64 disassembler. + - libasm: Add interface for disassembler. + - all programs: add debugging of branch prediction. + - libelf: new function elf_scnshndx. + +* Sun Nov 11 2007 Roland McGrath - 0.131-1 +- Update to 0.131 + - libdw: DW_FORM_ref_addr support; dwarf_formref entry point now deprecated; + bug fixes for oddly-formatted DWARF + - libdwfl: bug fixes in offline archive support, symbol table handling; + apply partial relocations for dwfl_module_address_section on ET_REL + - libebl: powerpc backend support for Altivec registers + +* Wed Oct 17 2007 Roland McGrath - 0.130-3 +- Fix ET_REL support. +- Fix odd indentation in eu-readelf -x output. + +* Tue Oct 16 2007 Roland McGrath - 0.130-1 +- Update to 0.130 + - eu-readelf -p option can take an argument like -x for one section + - eu-readelf --archive-index (or -c) + - eu-readelf -n improved output for core dumps + - eu-readelf: handle SHT_NOTE sections without requiring phdrs (#249467) + - eu-elflint: ditto + - eu-elflint: stricter checks on debug sections + - eu-unstrip: new options, --list (or -n), --relocate (or -R) + - libelf: new function elf_getdata_rawchunk, replaces gelf_rawchunk; + new functions gelf_getnote, gelf_getauxv, gelf_update_auxv + - libebl: backend improvements (#324031) + - libdwfl: build_id support, new functions for it + - libdwfl: dwfl_module_addrsym fixes (#268761, #268981) + - libdwfl offline archive support, new script eu-make-debug-archive + +* Mon Aug 20 2007 Roland McGrath - 0.129-2 +- Fix false-positive eu-elflint failure on ppc -mbss-plt binaries. + +* Tue Aug 14 2007 Roland McGrath - 0.129-1 +- Update to 0.129 + - readelf: new options --hex-dump (or -x), --strings (or -p) (#250973) + - addr2line: new option --symbols (or -S) + - libdw: dwarf_getscopes fixes (#230235) + - libdwfl: dwfl_module_addrsym fixes (#249490) + +* Fri Jun 8 2007 Roland McGrath - 0.128-2 +- Update to 0.128 + - new program: unstrip + - elfcmp: new option --hash-inexact +- Replace Conflicts: with Provides/Requires using -arch + +* Wed Apr 18 2007 Roland McGrath - 0.127-1 +- Update to 0.127 + - libdw: new function dwarf_getsrcdirs + - libdwfl: new functions dwfl_module_addrsym, dwfl_report_begin_add, + dwfl_module_address_section + +* Mon Feb 5 2007 Roland McGrath - 0.126-1 +- Update to 0.126 + - New program eu-ar. + - libdw: fix missing dwarf_getelf (#227206) + - libdwfl: dwfl_module_addrname for st_size=0 symbols (#227167, #227231) + +* Wed Jan 10 2007 Roland McGrath - 0.125-3 +- Fix overeager warn_unused_result build failures. + +* Wed Jan 10 2007 Roland McGrath - 0.125-1 +- Update to 0.125 + - elflint: Compare DT_GNU_HASH tests. + - move archives into -static RPMs + - libelf, elflint: better support for core file handling + - Really fix libdwfl sorting of modules with 64-bit addresses (#220817). +- Resolves: RHBZ #220817, RHBZ #213792 + +* Tue Oct 10 2006 Roland McGrath - 0.124-1 +- eu-strip -f: copy symtab into debuginfo file when relocs use it (#203000) +- Update to 0.124 + - libebl: fix ia64 reloc support (#206981) + - libebl: sparc backend support for return value location + - libebl, libdwfl: backend register name support extended with more info + - libelf, libdw: bug fixes for unaligned accesses on machines that care + - readelf, elflint: trivial bugs fixed + +* Mon Aug 14 2006 Roland McGrath 0.123-1 +- Update to 0.123 + - libebl: Backend build fixes, thanks to Stepan Kasal. + - libebl: ia64 backend support for register names, return value location + - libdwfl: Handle truncated linux kernel module section names. + - libdwfl: Look for linux kernel vmlinux files with .debug suffix. + - elflint: Fix checks to permit --hash-style=gnu format. + +* Mon Jul 17 2006 Roland McGrath - 0.122-4 +- Fix warnings in elflint compilation. + +* Wed Jul 12 2006 Roland McGrath - 0.122-3 +- Update to 0.122 + - Fix libdwfl sorting of modules with 64-bit addresses (#198225). + - libebl: add function to test for relative relocation + - elflint: fix and extend DT_RELCOUNT/DT_RELACOUNT checks + - elflint, readelf: add support for DT_GNU_HASH + - libelf: add elf_gnu_hash + - elflint, readelf: add support for 64-bit SysV-style hash tables + - libdwfl: new functions dwfl_module_getsymtab, dwfl_module_getsym. + +* Thu Jun 15 2006 Roland McGrath - 0.121-1 +- Update to 0.121 + - libelf: bug fixes for rewriting existing files when using mmap (#187618). + - make all installed headers usable in C++ code (#193153). + - eu-readelf: better output format. + - eu-elflint: fix tests of dynamic section content. + - libdw, libdwfl: handle files without aranges info. + +* Thu May 25 2006 Jeremy Katz - 0.120-3 +- rebuild to pick up -devel deps + +* Tue Apr 4 2006 Roland McGrath - 0.120-2 +- Update to 0.120 + - License changed to GPL, with some exceptions for using + the libelf, libebl, libdw, and libdwfl library interfaces. + Red Hat elfutils is an included package of the Open Invention Network. + - dwarf.h updated for DWARF 3.0 final specification. + - libelf: Fix corruption in ELF_C_RDWR uses (#187618). + - libdwfl: New function dwfl_version; fixes for offline. + +* Fri Feb 10 2006 Jesse Keating - 0.119-1.2.1 +- bump again for double-long bug on ppc(64) + +* Tue Feb 07 2006 Jesse Keating - 0.119-1.2 +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Fri Jan 13 2006 Roland McGrath - 0.119-1 +- update to 0.119 + +* Fri Dec 09 2005 Jesse Keating +- rebuilt + +* Sun Nov 27 2005 Roland McGrath - 0.118-1 +- update to 0.118 + - elflint: more tests. + - libdwfl: New function dwfl_module_register_names. + - libebl: New backend hook for register names. +- Make sure -fexceptions is always in CFLAGS. + +* Tue Nov 22 2005 Roland McGrath - 0.117-2 +- update to 0.117 + - libdwfl: New function dwfl_module_return_value_location (#166118) + - libebl: Backend improvements for several CPUs + +* Mon Oct 31 2005 Roland McGrath - 0.116-1 +- update to 0.116 + - libdw fixes, API changes and additions + - libdwfl fixes (#169672) + - eu-strip/libelf fix to preserve setuid/setgid permission bits (#167745) + +* Fri Sep 9 2005 Roland McGrath - 0.115-3 +- Update requires/conflicts for better biarch update behavior. + +* Mon Sep 5 2005 Roland McGrath - 0.115-2 +- update to 0.115 + - New program eu-strings. + - libdw: New function dwarf_getscopes_die. + - libelf: speed-ups of non-mmap reading. + - Implement --enable-gcov option for configure. + +* Wed Aug 24 2005 Roland McGrath - 0.114-1 +- update to 0.114 + - new program eu-ranlib + - libdw: new calls for inlines + - libdwfl: new calls for offline modules + +* Sat Aug 13 2005 Roland McGrath - 0.113-2 +- update to 0.113 + - elflint: relax a bit. Allow version definitions for defined symbols + against DSO versions also for symbols in nobits sections. + Allow .rodata section to have STRINGS and MERGE flag set. + - strip: add some more compatibility with binutils. + - libdwfl: bug fixes. +- Separate libdw et al into elfutils-libs subpackage. + +* Sat Aug 6 2005 Roland McGrath - 0.112-1 +- update to 0.112 + - elfcmp: some more relaxation. + - elflint: many more tests, especially regarding to symbol versioning. + - libelf: Add elfXX_offscn and gelf_offscn. + - libasm: asm_begin interface changes. + - libebl: Add three new interfaces to directly access machine, class, + and data encoding information. + +* Fri Jul 29 2005 Roland McGrath - 0.111-2 +- update portability patch + +* Thu Jul 28 2005 Roland McGrath - 0.111-1 +- update to 0.111 + - libdwfl library now merged into libdw + +* Sun Jul 24 2005 Roland McGrath - 0.110-1 +- update to 0.110 + +* Fri Jul 22 2005 Roland McGrath - 0.109-2 +- update to 0.109 + - verify that libebl modules are from the same build + - new eu-elflint checks on copy relocations + - new program eu-elfcmp + - new experimental libdwfl library + +* Thu Jun 9 2005 Roland McGrath - 0.108-5 +- robustification of eu-strip and eu-readelf + +* Wed May 25 2005 Roland McGrath - 0.108-3 +- more robustification + +* Mon May 16 2005 Roland McGrath - 0.108-2 +- robustification + +* Mon May 9 2005 Roland McGrath - 0.108-1 +- update to 0.108 + - merge strip fixes + - sort records in dwarf_getsrclines, fix dwarf_getsrc_die searching + - update elf.h from glibc + +* Sun May 8 2005 Roland McGrath - 0.107-2 +- fix strip -f byte-swapping bug + +* Sun May 8 2005 Roland McGrath - 0.107-1 +- update to 0.107 + - readelf: improve DWARF output format + - elflint: -d option to support checking separate debuginfo files + - strip: fix ET_REL debuginfo files (#156341) + * Mon Apr 4 2005 Roland McGrath - 0.106-3 - fix some bugs in new code, reenable make check diff --git a/sources b/sources index 46622f8..81ce69c 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -6b4a7b0e3a3f274f91095a9d95cfa635 elfutils-0.106.tar.gz +a24690a64268516bd413c4c3fe6c6dd4 elfutils-0.137.tar.gz