Update to 0.143

This commit is contained in:
roland 2009-09-21 17:44:00 +00:00
parent d36848b525
commit e4d1f5cf47
8 changed files with 448 additions and 163 deletions

View File

@ -1 +1 @@
elfutils-0.142.tar.bz2
elfutils-0.143.tar.bz2

View File

@ -34,15 +34,18 @@ patches := $(patsubst %,elfutils-%.patch,robustify portability)
all: $(patches)
branch-portability = portable
branch-master = elfutils-$(VERSION)
elfutils-%/configure: .git/refs/heads/* Makefile
git-%/configure: .git/refs/heads/* Makefile
@rm -rf $(@D)
git archive --prefix=$(@D)/ $(firstword $(branch-$*) $*) | tar xf -
cd $(@D) && autoreconf -i && rm -rf autom4te.cache
elfutils-%.patch: elfutils-master/configure elfutils-%/configure
diff --exclude='.gitignore' -Nrpu $(^D) | \
elfutils-%.patch: git-%/configure
branch=$(firstword $(branch-$*) $*); \
master=`git merge-base origin/master $$branch` && \
master=`git describe --tags --always $$master` && \
(set -x; $(MAKE) git-$$master/configure) && \
(set -x; diff --exclude='.gitignore' -Nrpu git-$$master $(<D)) | \
filterdiff --remove-timestamps --strip=1 --addprefix=elfutils/ > $@.new
mv $@.new $@

Binary file not shown.

BIN
elfutils-0.143.tar.bz2.sig Normal file

Binary file not shown.

View File

@ -1,6 +1,6 @@
--- elfutils/backends/ChangeLog
+++ elfutils/backends/ChangeLog
@@ -48,6 +48,10 @@
@@ -57,6 +57,10 @@
* ppc_attrs.c (ppc_check_object_attribute): Handle tag
GNU_Power_ABI_Struct_Return.
@ -11,7 +11,7 @@
2008-10-04 Ulrich Drepper <drepper@redhat.com>
* i386_reloc.def: Fix entries for TLS_GOTDESC, TLS_DESC_CALL, and
@@ -375,6 +379,11 @@
@@ -384,6 +388,11 @@
* sparc_init.c: Likewise.
* x86_64_init.c: Likewise.
@ -23,7 +23,7 @@
2005-11-19 Roland McGrath <roland@redhat.com>
* ppc64_reloc.def: REL30 -> ADDR30.
@@ -397,6 +406,9 @@
@@ -406,6 +415,9 @@
* Makefile.am (uninstall): Don't try to remove $(pkgincludedir).
(CLEANFILES): Add libebl_$(m).so.
@ -101,7 +101,18 @@
# XXX Should not be needed...
--- elfutils/ChangeLog
+++ elfutils/ChangeLog
@@ -9,6 +9,8 @@
@@ -6,6 +6,10 @@
* configure.ac (zip_LIBS): Check for liblzma too.
+2009-08-17 Roland McGrath <roland@redhat.com>
+
+ * configure.ac: Check for -fgnu89-inline; add it to WEXTRA if it works.
+
2009-04-19 Roland McGrath <roland@redhat.com>
* configure.ac (eu_version): Round down here, not in version.h macros.
@@ -17,6 +21,8 @@
2009-01-23 Roland McGrath <roland@redhat.com>
@ -110,7 +121,7 @@
* configure.ac (zlib check): Check for gzdirect, need zlib >= 1.2.2.3.
* configure.ac (__thread check): Use AC_LINK_IFELSE, in case of
@@ -89,6 +91,10 @@
@@ -97,6 +103,10 @@
* configure.ac: Add dummy automake conditional to get dependencies
for non-generic linker right. See src/Makefile.am.
@ -121,7 +132,7 @@
2005-11-18 Roland McGrath <roland@redhat.com>
* Makefile.am (DISTCHECK_CONFIGURE_FLAGS): New variable.
@@ -136,6 +142,17 @@
@@ -144,6 +154,17 @@
* Makefile.am (all_SUBDIRS): Add libdwfl.
* configure.ac: Write libdwfl/Makefile.
@ -168,7 +179,7 @@
/* $libdir subdirectory containing libebl modules. */
#undef LIBEBL_SUBDIR
@@ -52,4 +55,7 @@
@@ -55,4 +58,7 @@
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
@ -178,7 +189,7 @@
#include <eu-config.h>
--- elfutils/configure
+++ elfutils/configure
@@ -644,6 +644,8 @@ NATIVE_LD_FALSE
@@ -646,6 +646,8 @@ NATIVE_LD_FALSE
NATIVE_LD_TRUE
DATADIRNAME
LOCALEDIR
@ -187,7 +198,7 @@
LEXLIB
LEX_OUTPUT_ROOT
LEX
@@ -4094,6 +4096,152 @@ $as_echo "$as_me: error: gcc with C99 su
@@ -4098,6 +4100,205 @@ $as_echo "$as_me: error: gcc with C99 su
fi
@ -240,6 +251,59 @@
+fi
+
+
+{ $as_echo "$as_me:$LINENO: checking for -fgnu89-inline option to $CC" >&5
+$as_echo_n "checking for -fgnu89-inline option to $CC... " >&6; }
+if test "${ac_cv_cc_gnu89_inline+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -fgnu89-inline -Werror"
+cat >conftest.$ac_ext <<_ACEOF
+
+void foo (void)
+{
+ inline void bar (void) {}
+ bar ();
+}
+extern inline void baz (void) {}
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_cc_gnu89_inline=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_cc_gnu89_inline=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+CFLAGS="$old_CFLAGS"
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_cc_gnu89_inline" >&5
+$as_echo "$ac_cv_cc_gnu89_inline" >&6; }
+if test "x$ac_cv_cc_gnu89_inline" = xyes; then
+ WEXTRA="${WEXTRA:+$WEXTRA }-fgnu89-inline"
+fi
+
+
+{ $as_echo "$as_me:$LINENO: checking for --as-needed linker option" >&5
+$as_echo_n "checking for --as-needed linker option... " >&6; }
+if test "${ac_cv_as_needed+set}" = set; then
@ -340,7 +404,7 @@
{ $as_echo "$as_me:$LINENO: checking for __thread support" >&5
$as_echo_n "checking for __thread support... " >&6; }
if test "${ac_cv_tls+set}" = set; then
@@ -4159,9 +4307,18 @@ fi
@@ -4163,9 +4364,18 @@ fi
{ $as_echo "$as_me:$LINENO: result: $ac_cv_tls" >&5
$as_echo "$ac_cv_tls" >&6; }
if test "x$ac_cv_tls" != xyes; then
@ -363,7 +427,7 @@
--- elfutils/configure.ac
+++ elfutils/configure.ac
@@ -74,6 +74,39 @@ CFLAGS="$old_CFLAGS"])
@@ -73,6 +73,54 @@ CFLAGS="$old_CFLAGS"])
AS_IF([test "x$ac_cv_c99" != xyes],
AC_MSG_ERROR([gcc with C99 support required]))
@ -376,6 +440,21 @@
+AC_SUBST(WEXTRA)
+AS_IF([test "x$ac_cv_cc_wextra" = xyes], [WEXTRA=-Wextra], [WEXTRA=-W])
+
+AC_CACHE_CHECK([for -fgnu89-inline option to $CC], ac_cv_cc_gnu89_inline, [dnl
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -fgnu89-inline -Werror"
+AC_COMPILE_IFELSE([
+void foo (void)
+{
+ inline void bar (void) {}
+ bar ();
+}
+extern inline void baz (void) {}
+], ac_cv_cc_gnu89_inline=yes, ac_cv_cc_gnu89_inline=no)
+CFLAGS="$old_CFLAGS"])
+AS_IF([test "x$ac_cv_cc_gnu89_inline" = xyes],
+ [WEXTRA="${WEXTRA:+$WEXTRA }-fgnu89-inline"])
+
+AC_CACHE_CHECK([for --as-needed linker option],
+ ac_cv_as_needed, [dnl
+cat > conftest.c <<EOF
@ -403,7 +482,7 @@
AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl
# Use the same flags that we use for our DSOs, so the test is representative.
# Some old compiler/linker/libc combinations fail some ways and not others.
@@ -89,7 +122,10 @@ static __thread int a; int foo (int b) {
@@ -88,7 +136,10 @@ static __thread int a; int foo (int b) {
CFLAGS="$save_CFLAGS"
LDFLAGS="$save_LDFLAGS"])
AS_IF([test "x$ac_cv_tls" != xyes],
@ -417,7 +496,8 @@
AC_SUBST(LOCALEDIR)
--- elfutils/lib/ChangeLog
+++ elfutils/lib/ChangeLog
@@ -1,5 +1,8 @@
@@ -4,6 +4,9 @@
2009-01-23 Roland McGrath <roland@redhat.com>
+ * eu-config.h [! HAVE_BUILTIN_POPCOUNT]
@ -426,7 +506,7 @@
* eu-config.h: Add multiple inclusion protection.
2009-01-17 Ulrich Drepper <drepper@redhat.com>
@@ -56,6 +59,11 @@
@@ -60,6 +63,11 @@
* Makefile.am (libeu_a_SOURCES): Add it.
* system.h: Declare crc32_file.
@ -440,7 +520,7 @@
* Makefile.am: Use -ffunction-sections for xmalloc.c.
--- elfutils/lib/eu-config.h
+++ elfutils/lib/eu-config.h
@@ -182,5 +182,16 @@ asm (".section predict_data, \"aw\"; .pr
@@ -182,6 +182,17 @@ asm (".section predict_data, \"aw\"; .pr
/* This macro is used by the tests conditionalize for standalone building. */
#define ELFUTILS_HEADER(name) <lib##name.h>
@ -456,7 +536,8 @@
+#endif /* HAVE_BUILTIN_POPCOUNT */
+
#endif /* eu-config.h */
#ifdef SHARED
# define OLD_VERSION(name, version) \
--- elfutils/lib/Makefile.am
+++ elfutils/lib/Makefile.am
@@ -25,12 +25,13 @@
@ -647,7 +728,18 @@
@MUDFLAP_TRUE@ $($(*F)_no_Werror),,-Werror)
--- elfutils/libdw/ChangeLog
+++ elfutils/libdw/ChangeLog
@@ -738,6 +738,11 @@
@@ -20,6 +20,10 @@
* dwarf_hasattr_integrate.c: Integrate DW_AT_specification too.
+2009-08-17 Roland McGrath <roland@redhat.com>
+
+ * libdw.h: Disable extern inlines for GCC 4.2.
+
2009-08-10 Roland McGrath <roland@redhat.com>
* dwarf_getscopevar.c: Use dwarf_diename.
@@ -788,6 +792,11 @@
2005-05-31 Roland McGrath <roland@redhat.com>
@ -659,6 +751,17 @@
* dwarf_formref_die.c (dwarf_formref_die): Add CU header offset to
formref offset.
--- elfutils/libdw/libdw.h
+++ elfutils/libdw/libdw.h
@@ -809,7 +809,7 @@ extern Dwarf_OOM dwarf_new_oom_handler (
/* Inline optimizations. */
-#ifdef __OPTIMIZE__
+#if defined __OPTIMIZE__ && !(__GNUC__ == 4 && __GNUC_MINOR__ == 2)
/* Return attribute code of given attribute. */
__libdw_extern_inline unsigned int
dwarf_whatattr (Dwarf_Attribute *attr)
--- elfutils/libdw/Makefile.am
+++ elfutils/libdw/Makefile.am
@@ -25,6 +25,7 @@
@ -711,7 +814,7 @@
$(COMPILE)))
--- elfutils/libdwfl/ChangeLog
+++ elfutils/libdwfl/ChangeLog
@@ -1098,6 +1098,11 @@
@@ -1139,6 +1139,11 @@
2005-07-21 Roland McGrath <roland@redhat.com>
@ -742,7 +845,7 @@
VERSION = 1
--- elfutils/libdwfl/Makefile.in
+++ elfutils/libdwfl/Makefile.in
@@ -176,6 +176,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -179,6 +179,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
@ -750,7 +853,7 @@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
@@ -205,6 +206,7 @@ SHELL = @SHELL@
@@ -208,6 +209,7 @@ SHELL = @SHELL@
STRIP = @STRIP@
USE_NLS = @USE_NLS@
VERSION = 1
@ -758,7 +861,7 @@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
YACC = @YACC@
@@ -263,9 +265,9 @@ top_builddir = @top_builddir@
@@ -266,9 +268,9 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
zip_LIBS = @zip_LIBS@
@MUDFLAP_FALSE@AM_CFLAGS = -Wall -Werror -Wshadow -Wunused -Wformat=2 \
@ -772,7 +875,7 @@
--- elfutils/libebl/ChangeLog
+++ elfutils/libebl/ChangeLog
@@ -593,6 +593,11 @@
@@ -603,6 +603,11 @@
* Makefile.am (libebl_*_so_SOURCES): Set to $(*_SRCS) so dependency
tracking works right.
@ -833,7 +936,7 @@
--- elfutils/libelf/ChangeLog
+++ elfutils/libelf/ChangeLog
@@ -576,6 +576,11 @@
@@ -580,6 +580,11 @@
* elf.h: Update from glibc.
@ -968,7 +1071,24 @@
/* It was symbol+offset. */
--- elfutils/src/ChangeLog
+++ elfutils/src/ChangeLog
@@ -155,6 +155,8 @@
@@ -7,8 +7,16 @@
* readelf.c (attr_callback): Use print_block only when we don't use
print_ops.
+2009-08-17 Roland McGrath <roland@redhat.com>
+
+ * ld.h: Disable extern inlines for GCC 4.2.
+
2009-08-14 Roland McGrath <roland@redhat.com>
+ * strings.c (read_block): Conditionalize posix_fadvise use
+ on [POSIX_FADV_SEQUENTIAL].
+ From Petr Salinger <Petr.Salinger@seznam.cz>.
+
* ar.c (do_oper_extract): Use pathconf instead of statfs.
2009-08-01 Ulrich Drepper <drepper@redhat.com>
@@ -172,6 +180,8 @@
* readelf.c (print_debug_frame_section): Use t instead of j formats
for ptrdiff_t OFFSET.
@ -977,7 +1097,7 @@
2009-01-21 Ulrich Drepper <drepper@redhat.com>
* elflint.c (check_program_header): Fix typo in .eh_frame_hdr section
@@ -338,6 +340,11 @@
@@ -355,6 +365,11 @@
that matches its PT_LOAD's p_flags &~ PF_W. On sparc, PF_X really
is valid in RELRO.
@ -989,7 +1109,7 @@
2008-02-29 Roland McGrath <roland@redhat.com>
* readelf.c (print_attributes): Add a cast.
@@ -589,6 +596,8 @@
@@ -606,6 +621,8 @@
* readelf.c (hex_dump): Fix rounding error in whitespace calculation.
@ -998,7 +1118,7 @@
2007-10-15 Roland McGrath <roland@redhat.com>
* make-debug-archive.in: New file.
@@ -1028,6 +1037,10 @@
@@ -1045,6 +1062,10 @@
* elflint.c (valid_e_machine): Add EM_ALPHA.
Reported by Christian Aichinger <Greek0@gmx.net>.
@ -1009,7 +1129,7 @@
2006-08-08 Ulrich Drepper <drepper@redhat.com>
* elflint.c (check_dynamic): Don't require DT_HASH for DT_SYMTAB.
@@ -1104,6 +1117,10 @@
@@ -1121,6 +1142,10 @@
* Makefile.am: Add hacks to create dependency files for non-generic
linker.
@ -1020,7 +1140,7 @@
2006-06-12 Ulrich Drepper <drepper@redhat.com>
* ldgeneric.c (ld_generic_generate_sections): Don't create .interp
@@ -1452,6 +1469,11 @@
@@ -1469,6 +1494,11 @@
* readelf.c (print_debug_loc_section): Fix indentation for larger
address size.
@ -1047,6 +1167,23 @@
GElf_Addr addr, Elf *elf, Elf_Scn *symscn, Dwarf *dw,
const char *fname, bool more_than_one, void **knownsrcs)
{
--- elfutils/src/ld.h
+++ elfutils/src/ld.h
@@ -1122,6 +1122,7 @@ extern bool dynamically_linked_p (void);
/* Checked whether the symbol is undefined and referenced from a DSO. */
extern bool linked_from_dso_p (struct scninfo *scninfo, size_t symidx);
+#if defined __OPTIMIZE__ && !(__GNUC__ == 4 && __GNUC_MINOR__ == 2)
#ifdef __GNUC_STDC_INLINE__
__attribute__ ((__gnu_inline__))
#endif
@@ -1139,5 +1140,6 @@ linked_from_dso_p (struct scninfo *scnin
return sym->defined && sym->in_dso;
}
+#endif /* Optimizing and not GCC 4.2. */
#endif /* ld.h */
--- elfutils/src/Makefile.am
+++ elfutils/src/Makefile.am
@@ -26,6 +26,7 @@
@ -1122,7 +1259,7 @@
size_LDADD = $(libelf) $(libeu) $(libmudflap)
--- elfutils/src/readelf.c
+++ elfutils/src/readelf.c
@@ -7591,7 +7591,7 @@ dump_archive_index (Elf *elf, const char
@@ -7594,7 +7594,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))
@ -1158,6 +1295,18 @@
break;
}
if (errno != EINVAL && errno != ENOMEM)
@@ -586,9 +595,11 @@ read_block (int fd, const char *fname, o
elfmap_off = from & ~(ps - 1);
elfmap_base = elfmap = map_file (fd, elfmap_off, fdlen, &elfmap_size);
+#ifdef POSIX_FADV_SEQUENTIAL
if (unlikely (elfmap == MAP_FAILED))
/* Let the kernel know we are going to read everything in sequence. */
(void) posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+#endif
}
if (unlikely (elfmap == MAP_FAILED))
--- elfutils/src/strip.c
+++ elfutils/src/strip.c
@@ -52,6 +52,12 @@

View File

@ -1,6 +1,6 @@
--- elfutils/libelf/ChangeLog
+++ elfutils/libelf/ChangeLog
@@ -568,6 +568,49 @@
@@ -572,6 +572,49 @@
If section content hasn't been read yet, do it before looking for the
block size. If no section data present, infer size of section header.
@ -52,6 +52,13 @@
* elf.h: Update again.
--- elfutils/libelf/elf32_getphdr.c
+++ elfutils/libelf/elf32_getphdr.c
@@ -1,5 +1,5 @@
/* Get ELF program header table.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 Red Hat, Inc.
+ Copyright (C) 1998-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 1998.
@@ -105,6 +105,16 @@ __elfw2(LIBELFBITS,getphdr_wrlock) (elf)
if (elf->map_address != NULL)
@ -59,7 +66,7 @@
+ /* First see whether the information in the ELF header is
+ valid and it does not ask for too much. */
+ if (unlikely (ehdr->e_phoff >= elf->maximum_size)
+ || unlikely (ehdr->e_phoff + size > elf->maximum_size))
+ || unlikely (elf->maximum_size - ehdr->e_phoff < size))
+ {
+ /* Something is wrong. */
+ __libelf_seterrno (ELF_E_INVALID_PHDR);
@ -95,7 +102,7 @@
+ /* First see whether the information in the ELF header is
+ valid and it does not ask for too much. */
+ if (unlikely (ehdr->e_shoff >= elf->maximum_size)
+ || unlikely (ehdr->e_shoff + size > elf->maximum_size))
+ || unlikely (elf->maximum_size - ehdr->e_shoff < size))
+ {
+ /* Something is wrong. */
+ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
@ -145,13 +152,20 @@
xfct_t shdr_fctp = __elf_xfctstom[__libelf_version - 1][EV_CURRENT - 1][ELFW(ELFCLASS, LIBELFBITS) - 1][ELF_T_SHDR];
--- elfutils/libelf/elf_begin.c
+++ elfutils/libelf/elf_begin.c
@@ -1,5 +1,5 @@
/* Create descriptor for processing file.
- Copyright (C) 1998-2005, 2006, 2007, 2008 Red Hat, Inc.
+ Copyright (C) 1998-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 1998.
@@ -165,7 +165,8 @@ get_shnum (void *map_address, unsigned c
if (unlikely (result == 0) && ehdr.e32->e_shoff != 0)
{
- if (ehdr.e32->e_shoff + sizeof (Elf32_Shdr) > maxsize)
+ if (unlikely (ehdr.e32->e_shoff >= maxsize)
+ || unlikely (ehdr.e32->e_shoff + sizeof (Elf32_Shdr) > maxsize))
+ || unlikely (maxsize - ehdr.e32->e_shoff < sizeof (Elf32_Shdr)))
/* Cannot read the first section header. */
return 0;
@ -181,14 +195,14 @@
/* We can now allocate the memory. */
Elf *elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent,
ELF_K_ELF, scncnt * sizeof (Elf_Scn));
@@ -318,13 +329,31 @@ file_read_elf (int fildes, void *map_add
@@ -318,13 +329,30 @@ file_read_elf (int fildes, void *map_add
{
/* We can use the mmapped memory. */
elf->state.elf32.ehdr = ehdr;
+
+ if (unlikely (ehdr->e_shoff >= maxsize)
+ || unlikely (ehdr->e_shoff
+ + scncnt * sizeof (Elf32_Shdr) > maxsize))
+ || unlikely (maxsize - ehdr->e_shoff
+ < scncnt * sizeof (Elf32_Shdr)))
+ {
+ free_and_out:
+ free (elf);
@ -203,9 +217,8 @@
/* 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))
+ || unlikely (maxsize - ehdr->e_phoff
+ < ehdr->e_phnum * sizeof (Elf32_Phdr)))
+ goto free_and_out;
elf->state.elf32.phdr
= (Elf32_Phdr *) ((char *) ehdr + ehdr->e_phoff);
@ -213,7 +226,7 @@
for (size_t cnt = 0; cnt < scncnt; ++cnt)
{
@@ -406,13 +435,26 @@ file_read_elf (int fildes, void *map_add
@@ -406,13 +434,26 @@ file_read_elf (int fildes, void *map_add
{
/* We can use the mmapped memory. */
elf->state.elf64.ehdr = ehdr;
@ -262,11 +275,13 @@
+ || (((size_t) ((char *) elf->map_address
+ + elf->start_offset + offset))
& (__alignof__ (Elf32_Shdr) - 1)) == 0))
- /* We can directly access the memory. */
- num = ((Elf32_Shdr *) (elf->map_address + offset))->sh_link;
+ {
+ /* First see whether the information in the ELF header is
+ valid and it does not ask for too much. */
+ if (unlikely (offset + sizeof (Elf32_Shdr)
+ > elf->maximum_size))
+ if (unlikely (elf->maximum_size - offset
+ < sizeof (Elf32_Shdr)))
+ {
+ /* Something is wrong. */
+ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
@ -274,8 +289,7 @@
+ goto out;
+ }
+
/* We can directly access the memory. */
- num = ((Elf32_Shdr *) (elf->map_address + offset))->sh_link;
+ /* We can directly access the memory. */
+ num = ((Elf32_Shdr *) (elf->map_address + elf->start_offset
+ + offset))->sh_link;
+ }
@ -290,11 +304,13 @@
+ || (((size_t) ((char *) elf->map_address
+ + elf->start_offset + offset))
& (__alignof__ (Elf64_Shdr) - 1)) == 0))
- /* We can directly access the memory. */
- num = ((Elf64_Shdr *) (elf->map_address + offset))->sh_link;
+ {
+ /* First see whether the information in the ELF header is
+ valid and it does not ask for too much. */
+ if (unlikely (offset + sizeof (Elf64_Shdr)
+ > elf->maximum_size))
+ if (unlikely (elf->maximum_size - offset
+ < sizeof (Elf64_Shdr)))
+ {
+ /* Something is wrong. */
+ __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
@ -302,10 +318,9 @@
+ goto out;
+ }
+
/* We can directly access the memory. */
- num = ((Elf64_Shdr *) (elf->map_address + offset))->sh_link;
+ num = ((Elf64_Shdr *) (elf->map_address
+ + elf->start_offset + offset))->sh_link;
+ /* We can directly access the memory. */
+ num = ((Elf64_Shdr *) (elf->map_address + elf->start_offset
+ + offset))->sh_link;
+ }
else
{
@ -334,52 +349,76 @@
* sizeof (Elf_Scn)), 1);
--- elfutils/libelf/gelf_getdyn.c
+++ elfutils/libelf/gelf_getdyn.c
@@ -93,7 +93,8 @@ gelf_getdyn (data, ndx, dst)
@@ -1,5 +1,5 @@
/* Get information from dynamic table at the given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -93,7 +93,7 @@ gelf_getdyn (data, ndx, dst)
table entries has to be adopted. The user better has provided
a buffer where we can store the information. While copying the
data we are converting the format. */
- if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Dyn)
+ || unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Dyn, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
@@ -114,7 +115,8 @@ gelf_getdyn (data, ndx, dst)
@@ -114,7 +114,7 @@ gelf_getdyn (data, ndx, dst)
/* The data is already in the correct form. Just make sure the
index is OK. */
- if (unlikely ((ndx + 1) * sizeof (GElf_Dyn) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, GElf_Dyn)
+ || unlikely ((ndx + 1) * sizeof (GElf_Dyn) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, GElf_Dyn, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
--- elfutils/libelf/gelf_getlib.c
+++ elfutils/libelf/gelf_getlib.c
@@ -86,7 +86,8 @@ gelf_getlib (data, ndx, dst)
@@ -1,5 +1,5 @@
/* Get library from table at the given index.
- Copyright (C) 2004 Red Hat, Inc.
+ Copyright (C) 2004-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -86,7 +86,7 @@ gelf_getlib (data, ndx, dst)
/* The data is already in the correct form. Just make sure the
index is OK. */
GElf_Lib *result = NULL;
- if (unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size))
+ if (INVALID_NDX (ndx, GElf_Lib)
+ || unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size))
+ if (INVALID_NDX (ndx, GElf_Lib, data))
__libelf_seterrno (ELF_E_INVALID_INDEX);
else
{
--- elfutils/libelf/gelf_getmove.c
+++ elfutils/libelf/gelf_getmove.c
@@ -83,7 +83,8 @@ gelf_getmove (data, ndx, dst)
@@ -1,5 +1,5 @@
/* Get move structure at the given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -83,7 +83,7 @@ gelf_getmove (data, ndx, dst)
/* The data is already in the correct form. Just make sure the
index is OK. */
- if (unlikely ((ndx + 1) * sizeof (GElf_Move) > data->d_size))
+ if (INVALID_NDX (ndx, GElf_Move)
+ || unlikely ((ndx + 1) * sizeof (GElf_Move) > data->d_size))
+ if (INVALID_NDX (ndx, GElf_Move, data))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
--- elfutils/libelf/gelf_getrela.c
+++ elfutils/libelf/gelf_getrela.c
@@ -1,5 +1,5 @@
/* Get RELA relocation information at given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -71,12 +71,6 @@ gelf_getrela (data, ndx, dst)
if (data_scn == NULL)
return NULL;
@ -393,28 +432,33 @@
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)
@@ -93,7 +87,7 @@ gelf_getrela (data, ndx, dst)
if (scn->elf->class == ELFCLASS32)
{
/* We have to convert the data. */
- if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Rela)
+ || unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Rela, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
result = NULL;
@@ -114,7 +109,8 @@ gelf_getrela (data, ndx, dst)
@@ -114,7 +108,7 @@ gelf_getrela (data, ndx, dst)
{
/* Simply copy the data after we made sure we are actually getting
correct data. */
- if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Rela)
+ || unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Rela, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
result = NULL;
--- elfutils/libelf/gelf_getrel.c
+++ elfutils/libelf/gelf_getrel.c
@@ -1,5 +1,5 @@
/* Get REL relocation information at given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -71,12 +71,6 @@ gelf_getrel (data, ndx, dst)
if (data_scn == NULL)
return NULL;
@ -428,107 +472,133 @@
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)
@@ -93,7 +87,7 @@ gelf_getrel (data, ndx, dst)
if (scn->elf->class == ELFCLASS32)
{
/* We have to convert the data. */
- if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Rel)
+ || unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Rel, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
result = NULL;
@@ -113,7 +108,8 @@ gelf_getrel (data, ndx, dst)
@@ -113,7 +107,7 @@ gelf_getrel (data, ndx, dst)
{
/* Simply copy the data after we made sure we are actually getting
correct data. */
- if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Rel)
+ || unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Rel, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
result = NULL;
--- elfutils/libelf/gelf_getsym.c
+++ elfutils/libelf/gelf_getsym.c
@@ -90,7 +90,8 @@ gelf_getsym (data, ndx, dst)
@@ -1,5 +1,5 @@
/* Get symbol information from symbol table at the given index.
- Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 1999-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 1999.
@@ -90,7 +90,7 @@ gelf_getsym (data, ndx, dst)
table entries has to be adopted. The user better has provided
a buffer where we can store the information. While copying the
data we are converting the format. */
- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data->d_size))
+ if (INVALID_NDX (ndx, Elf32_Sym)
+ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data->d_size))
+ if (INVALID_NDX (ndx, Elf32_Sym, data))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
@@ -119,7 +120,8 @@ gelf_getsym (data, ndx, dst)
@@ -119,7 +119,7 @@ gelf_getsym (data, ndx, dst)
/* The data is already in the correct form. Just make sure the
index is OK. */
- if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > data->d_size))
+ if (INVALID_NDX (ndx, GElf_Sym)
+ || unlikely ((ndx + 1) * sizeof (GElf_Sym) > data->d_size))
+ if (INVALID_NDX (ndx, GElf_Sym, data))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
--- elfutils/libelf/gelf_getsyminfo.c
+++ elfutils/libelf/gelf_getsyminfo.c
@@ -84,7 +84,8 @@ gelf_getsyminfo (data, ndx, dst)
@@ -1,5 +1,5 @@
/* Get additional symbol information from symbol table at the given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -84,7 +84,7 @@ gelf_getsyminfo (data, ndx, dst)
/* The data is already in the correct form. Just make sure the
index is OK. */
- if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data->d_size))
+ if (INVALID_NDX (ndx, GElf_Syminfo)
+ || unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data->d_size))
+ if (INVALID_NDX (ndx, GElf_Syminfo, data))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
--- elfutils/libelf/gelf_getsymshndx.c
+++ elfutils/libelf/gelf_getsymshndx.c
@@ -90,7 +90,9 @@ gelf_getsymshndx (symdata, shndxdata, nd
@@ -1,6 +1,6 @@
/* Get symbol information and separate section index from symbol table
at the given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -90,7 +90,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
section index table. */
if (likely (shndxdata_scn != NULL))
{
- if (unlikely ((ndx + 1) * sizeof (Elf32_Word) > shndxdata_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Word)
+ || unlikely ((ndx + 1) * sizeof (Elf32_Word)
+ > shndxdata_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Word, &shndxdata_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
@@ -110,7 +112,8 @@ gelf_getsymshndx (symdata, shndxdata, nd
@@ -110,7 +110,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
table entries has to be adopted. The user better has provided
a buffer where we can store the information. While copying the
data we are converting the format. */
- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata->d_size))
+ if (INVALID_NDX (ndx, Elf32_Sym)
+ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata->d_size))
+ if (INVALID_NDX (ndx, Elf32_Sym, symdata))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
@@ -139,7 +142,8 @@ gelf_getsymshndx (symdata, shndxdata, nd
@@ -139,7 +139,7 @@ gelf_getsymshndx (symdata, shndxdata, nd
/* The data is already in the correct form. Just make sure the
index is OK. */
- if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > symdata->d_size))
+ if (INVALID_NDX (ndx, GElf_Sym)
+ || unlikely ((ndx + 1) * sizeof (GElf_Sym) > symdata->d_size))
+ if (INVALID_NDX (ndx, GElf_Sym, symdata))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
--- elfutils/libelf/gelf_getversym.c
+++ elfutils/libelf/gelf_getversym.c
@@ -92,7 +92,8 @@ gelf_getversym (data, ndx, dst)
@@ -1,5 +1,5 @@
/* Get symbol version information at the given index.
- Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 1999-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 1999.
@@ -92,7 +92,7 @@ gelf_getversym (data, ndx, dst)
/* The data is already in the correct form. Just make sure the
index is OK. */
- if (unlikely ((ndx + 1) * sizeof (GElf_Versym) > data->d_size))
+ if (INVALID_NDX (ndx, GElf_Versym)
+ || unlikely ((ndx + 1) * sizeof (GElf_Versym) > data->d_size))
+ if (INVALID_NDX (ndx, GElf_Versym, data))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
result = NULL;
--- elfutils/libelf/gelf_update_dyn.c
+++ elfutils/libelf/gelf_update_dyn.c
@@ -1,5 +1,5 @@
/* Update information in dynamic table at the given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -71,12 +71,6 @@ gelf_update_dyn (data, ndx, src)
if (data == NULL)
return 0;
@ -542,28 +612,33 @@
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)
@@ -102,7 +96,7 @@ gelf_update_dyn (data, ndx, src)
}
/* Check whether we have to resize the data buffer. */
- if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Dyn)
+ || unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Dyn, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
@@ -116,7 +111,8 @@ gelf_update_dyn (data, ndx, src)
@@ -116,7 +110,7 @@ gelf_update_dyn (data, ndx, src)
else
{
/* Check whether we have to resize the data buffer. */
- if (unlikely ((ndx + 1) * sizeof (Elf64_Dyn) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Dyn)
+ || unlikely ((ndx + 1) * sizeof (Elf64_Dyn) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Dyn, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
--- elfutils/libelf/gelf_update_lib.c
+++ elfutils/libelf/gelf_update_lib.c
@@ -1,5 +1,5 @@
/* Update library in table at the given index.
- Copyright (C) 2004 Red Hat, Inc.
+ Copyright (C) 2004-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -68,12 +68,6 @@ gelf_update_lib (data, ndx, src)
if (data == NULL)
return 0;
@ -577,29 +652,43 @@
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)
@@ -87,7 +81,7 @@ gelf_update_lib (data, ndx, src)
/* Check whether we have to resize the data buffer. */
int result = 0;
- if (unlikely ((ndx + 1) * sizeof (Elf64_Lib) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Lib)
+ || unlikely ((ndx + 1) * sizeof (Elf64_Lib) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Lib, &data_scn->d))
__libelf_seterrno (ELF_E_INVALID_INDEX);
else
{
--- elfutils/libelf/gelf_update_move.c
+++ elfutils/libelf/gelf_update_move.c
@@ -75,7 +75,7 @@ gelf_update_move (data, ndx, src)
@@ -1,5 +1,5 @@
/* Update move structure at the given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -75,8 +75,7 @@ gelf_update_move (data, ndx, src)
assert (sizeof (GElf_Move) == sizeof (Elf64_Move));
/* Check whether we have to resize the data buffer. */
- if (unlikely (ndx < 0)
+ if (INVALID_NDX (ndx, GElf_Move)
|| unlikely ((ndx + 1) * sizeof (GElf_Move) > data_scn->d.d_size))
- || unlikely ((ndx + 1) * sizeof (GElf_Move) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, GElf_Move, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
return 0;
--- elfutils/libelf/gelf_update_rela.c
+++ elfutils/libelf/gelf_update_rela.c
@@ -1,5 +1,5 @@
/* Update RELA relocation information at given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -68,12 +68,6 @@ gelf_update_rela (Elf_Data *dst, int ndx
if (dst == NULL)
return 0;
@ -613,28 +702,33 @@
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
@@ -101,7 +95,7 @@ gelf_update_rela (Elf_Data *dst, int ndx
}
/* Check whether we have to resize the data buffer. */
- if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Rela)
+ || unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Rela, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
@@ -117,7 +112,8 @@ gelf_update_rela (Elf_Data *dst, int ndx
@@ -117,7 +111,7 @@ gelf_update_rela (Elf_Data *dst, int ndx
else
{
/* Check whether we have to resize the data buffer. */
- if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Rela)
+ || unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Rela, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
--- elfutils/libelf/gelf_update_rel.c
+++ elfutils/libelf/gelf_update_rel.c
@@ -1,5 +1,5 @@
/* Update REL relocation information at given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -68,12 +68,6 @@ gelf_update_rel (Elf_Data *dst, int ndx,
if (dst == NULL)
return 0;
@ -648,28 +742,33 @@
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,
@@ -99,7 +93,7 @@ gelf_update_rel (Elf_Data *dst, int ndx,
}
/* Check whether we have to resize the data buffer. */
- if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Rel)
+ || unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Rel, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
@@ -114,7 +109,8 @@ gelf_update_rel (Elf_Data *dst, int ndx,
@@ -114,7 +108,7 @@ gelf_update_rel (Elf_Data *dst, int ndx,
else
{
/* Check whether we have to resize the data buffer. */
- if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Rel)
+ || unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Rel, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
--- elfutils/libelf/gelf_update_sym.c
+++ elfutils/libelf/gelf_update_sym.c
@@ -1,5 +1,5 @@
/* Update symbol information in symbol table at the given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -72,12 +72,6 @@ gelf_update_sym (data, ndx, src)
if (data == NULL)
return 0;
@ -683,28 +782,33 @@
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)
@@ -102,7 +96,7 @@ gelf_update_sym (data, ndx, src)
}
/* Check whether we have to resize the data buffer. */
- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Sym)
+ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Sym, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
@@ -125,7 +120,8 @@ gelf_update_sym (data, ndx, src)
@@ -125,7 +119,7 @@ gelf_update_sym (data, ndx, src)
else
{
/* Check whether we have to resize the data buffer. */
- if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Sym)
+ || unlikely ((ndx + 1) * sizeof (Elf64_Sym) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Sym, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
--- elfutils/libelf/gelf_update_syminfo.c
+++ elfutils/libelf/gelf_update_syminfo.c
@@ -1,5 +1,5 @@
/* Update additional symbol information in symbol table at the given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -72,12 +72,6 @@ gelf_update_syminfo (data, ndx, src)
if (data == NULL)
return 0;
@ -718,18 +822,25 @@
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)
@@ -93,7 +87,7 @@ gelf_update_syminfo (data, ndx, src)
rwlock_wrlock (scn->elf->lock);
/* Check whether we have to resize the data buffer. */
- if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, GElf_Syminfo)
+ || unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, GElf_Syminfo, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
--- elfutils/libelf/gelf_update_symshndx.c
+++ elfutils/libelf/gelf_update_symshndx.c
@@ -1,6 +1,6 @@
/* Update symbol information and section index in symbol table at the
given index.
- Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2000-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -77,12 +77,6 @@ gelf_update_symshndx (symdata, shndxdata
if (symdata == NULL)
return 0;
@ -743,56 +854,57 @@
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
@@ -128,7 +122,7 @@ gelf_update_symshndx (symdata, shndxdata
}
/* Check whether we have to resize the data buffer. */
- if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Sym)
+ || unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf32_Sym, &symdata_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
@@ -151,7 +146,8 @@ gelf_update_symshndx (symdata, shndxdata
@@ -151,7 +145,7 @@ gelf_update_symshndx (symdata, shndxdata
else
{
/* Check whether we have to resize the data buffer. */
- if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Sym)
+ || unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size))
+ if (INVALID_NDX (ndx, Elf64_Sym, &symdata_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
goto out;
--- elfutils/libelf/gelf_update_versym.c
+++ elfutils/libelf/gelf_update_versym.c
@@ -75,7 +75,7 @@ gelf_update_versym (data, ndx, src)
@@ -1,5 +1,5 @@
/* Update symbol version information.
- Copyright (C) 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2001-2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2001.
@@ -75,8 +75,7 @@ gelf_update_versym (data, ndx, src)
assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym));
/* Check whether we have to resize the data buffer. */
- if (unlikely (ndx < 0)
+ if (INVALID_NDX (ndx, GElf_Versym)
|| unlikely ((ndx + 1) * sizeof (GElf_Versym) > data_scn->d.d_size))
- || unlikely ((ndx + 1) * sizeof (GElf_Versym) > data_scn->d.d_size))
+ if (INVALID_NDX (ndx, GElf_Versym, &data_scn->d))
{
__libelf_seterrno (ELF_E_INVALID_INDEX);
return 0;
--- elfutils/libelf/libelfP.h
+++ elfutils/libelf/libelfP.h
@@ -606,4 +606,13 @@ extern uint32_t __libelf_crc32 (uint32_t
@@ -606,4 +606,8 @@ extern uint32_t __libelf_crc32 (uint32_t
/* Align offset to 4 bytes as needed for note name and descriptor data. */
#define NOTE_ALIGN(n) (((n) + 3) & -4U)
+/* Convenience macro. Assumes int NDX and TYPE with size at least
+ 2 bytes. */
+#if SIZE_MAX > 4294967295U
+# define INVALID_NDX(ndx, type) unlikely (ndx < 0)
+#else
+# define INVALID_NDX(ndx, type) \
+ unlikely ((unsigned int) (ndx) >= SIZE_MAX / sizeof (type))
+#endif
+/* Convenience macro. */
+#define INVALID_NDX(ndx, type, data) \
+ unlikely ((data)->d_size / sizeof (type) <= (unsigned int) (ndx))
+
#endif /* libelfP.h */
--- elfutils/src/ChangeLog
+++ elfutils/src/ChangeLog
@@ -1440,6 +1440,16 @@
@@ -1457,6 +1457,16 @@
object symbols or symbols with unknown type.
(check_rel): Likewise.
@ -809,7 +921,7 @@
2005-06-08 Roland McGrath <roland@redhat.com>
* readelf.c (print_ops): Add consts.
@@ -1485,6 +1495,19 @@
@@ -1502,6 +1512,19 @@
* readelf.c (dwarf_tag_string): Add new tags.

View File

@ -1,4 +1,4 @@
%define eu_version 0.142
%define eu_version 0.143
%define eu_release 1
%if %{?_with_compat:1}%{!?_with_compat:0}
@ -50,12 +50,20 @@ BuildRequires: glibc-headers >= 2.3.4-11
BuildRequires: gcc >= 3.2
%endif
%define use_zlib 0
%define use_zlib 0
%if 0%{?fedora} >= 5
%define use_zlib 1
%define use_zlib 1
%endif
%if 0%{?rhel} >= 5
%define use_zlib 1
%define use_zlib 1
%endif
%define use_xz 0
%if 0%{?fedora} >= 10
%define use_xz 1
%endif
%if 0%{?rhel} >= 6
%define use_xz 1
%endif
%if %{use_zlib}
@ -63,6 +71,10 @@ BuildRequires: zlib-devel >= 1.2.2.3
BuildRequires: bzip2-devel
%endif
%if %{use_xz}
BuildRequires: xz-devel
%endif
%define _gnu %{nil}
%define _program_prefix eu-
@ -276,16 +288,25 @@ rm -rf ${RPM_BUILD_ROOT}
%{_libdir}/libelf.a
%changelog
* Mon Sep 21 2009 Roland McGrath <roland@redhat.com> - 0.143-1
- Update to 0.143
- libdw: Various convenience functions for individual attributes now use
dwarf_attr_integrate to look up indirect inherited attributes.
Location expression handling now supports DW_OP_implicit_value.
- libdwfl: Support automatic decompression of files in XZ format,
and of Linux kernel images made with bzip2 or LZMA
(as well as gzip).
* Tue Jul 28 2009 Roland McGrath <roland@redhat.com> - 0.142-1
- Update to 0.142
- libelf: Bug fix in filling gaps between sections. (#512840)
- libelf: Add elf_getshdrnum alias for elf_getshnum and elf_getshdrstrndx
alias for elf_getshstrndx and deprecate original names.
alias for elf_getshstrndx and deprecate original names.
- libebl, elflint: Add support for STB_GNU_UNIQUE. (#511436)
- readelf: Add -N option, speeds up DWARF printing
without address->name lookups. (#505347)
without address->name lookups. (#505347)
- libdw: Add support for decoding DWARF CFI into location description form.
Handle some new DWARF 3 expression operations previously omitted.
Handle some new DWARF 3 expression operations previously omitted.
Basic handling of some new encodings slated for DWARF 4.
* Thu Apr 23 2009 Roland McGrath <roland@redhat.com> - 0.141-1

View File

@ -1 +1 @@
03ce3616fa6a347c3156ee5f74985ea7 elfutils-0.142.tar.bz2
06e35c348e78dec58f6aeb51bd397760 elfutils-0.143.tar.bz2