debian/0000775000000000000000000000000013107160060007162 5ustar debian/docs0000664000000000000000000000002111155535207010040 0ustar NEWS README TODO debian/control0000664000000000000000000000705312300464761010603 0ustar Source: elfutils Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Kurt Roeckx Build-Depends: debhelper (>= 8.1.3), autotools-dev, autoconf, automake, bzip2, zlib1g-dev, libbz2-dev, liblzma-dev, m4, gettext, autoconf, automake, gawk, dpkg-dev (>= 1.16.1~), gcc-multilib [any-amd64] Build-Conflicts: autoconf2.13, automake1.4 Standards-Version: 3.8.4 Section: libs Homepage: https://fedorahosted.org/elfutils/ Package: elfutils Section: utils Architecture: any Multi-Arch: foreign Depends: ${shlibs:Depends}, libelf1 (= ${binary:Version}), libdw1 (= ${binary:Version}), ${misc:Depends} Description: collection of utilities to handle ELF objects Elfutils is a collection of utilities, including eu-ld (a linker), eu-nm (for listing symbols from object files), eu-size (for listing the section sizes of an object or archive file), eu-strip (for discarding symbols), eu-readelf (to see the raw ELF file structures), and eu-elflint (to check for well-formed ELF files). Package: libelf1 Architecture: any Multi-Arch: same Depends: ${shlibs:Depends}, ${misc:Depends} Pre-Depends: ${misc:Pre-Depends} Description: library to read and write ELF files The libelf1 package provides a shared library which allows reading and writing ELF files on a high level. Third party programs depend on this package to read internals of ELF files. The programs of the elfutils package use it also to generate new ELF files. . This library is part of elfutils. Package: libelf-dev Section: libdevel Architecture: any Multi-Arch: same Depends: libelf1 (= ${binary:Version}), ${misc:Depends} Conflicts: libelfg0-dev Description: libelf1 development libraries and header files libelf1 provides a shared library which allows reading and writing of ELF files on a high level. . This package contains development libraries and header files for libelf1. Package: libdw-dev Section: libdevel Architecture: any Multi-Arch: same Depends: libelf-dev, libdw1 (= ${binary:Version}), ${misc:Depends} Description: libdw1 development libraries and header files libdw1 provides a library that provides access to DWARF debug information stored inside ELF files. . This package contains development libraries and header files for libdw1. . It also contains a static version of libdw. Only link to the static version for special cases and when you don't need anything from the ebl backends. Package: libdw1 Architecture: any Multi-Arch: same Depends: ${shlibs:Depends}, libelf1 (= ${binary:Version}), ${misc:Depends} Pre-Depends: ${misc:Pre-Depends} Description: library that provides access to the DWARF debug information libdw1 provides a library that provides access to DWARF debug information stored inside ELF files. . This library is part of elfutils. Package: libasm1 Architecture: any Multi-Arch: same Depends: ${shlibs:Depends}, libelf1 (= ${binary:Version}), libdw1 (= ${binary:Version}), ${misc:Depends} Pre-Depends: ${misc:Pre-Depends} Description: library with a programmable assembler interface The libasm1 package provides a library with a programmable assembler interface. It allows you to create ELF files on a low level. . This library is part of elfutils. Package: libasm-dev Section: libdevel Architecture: any Multi-Arch: same Depends: libasm1 (= ${binary:Version}), libelf-dev, ${misc:Depends} Conflicts: libelfsh0-dev, libasm0-dev Description: libasm development libraries and header files libasm1 allows you to create ELF files on a low level. . This package contains development libraries and header files for libasm1. debian/patches/0000775000000000000000000000000013107140016010610 5ustar debian/patches/redhat-portability.diff0000664000000000000000000017071212262471327015276 0ustar --- elfutils/backends/ChangeLog +++ elfutils/backends/ChangeLog @@ -292,6 +292,10 @@ * ppc_attrs.c (ppc_check_object_attribute): Handle tag GNU_Power_ABI_Struct_Return. +2009-01-23 Roland McGrath + + * Makefile.am (libebl_%.so): Use $(LD_AS_NEEDED). + 2008-10-04 Ulrich Drepper * i386_reloc.def: Fix entries for TLS_GOTDESC, TLS_DESC_CALL, and @@ -619,6 +623,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. @@ -641,6 +650,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 @@ -124,7 +124,7 @@ libebl_%.so libebl_%.map: libebl_%_pic.a $(LINK) -shared -o $(@:.map=.so) \ -Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \ -Wl,--version-script,$(@:.so=.map) \ - -Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw) $(libmudflap) + -Wl,-z,defs $(LD_AS_NEEDED) $(libelf) $(libdw) $(libmudflap) $(textrel_check) libebl_i386.so: $(cpu_i386) --- elfutils/backends/Makefile.in +++ elfutils/backends/Makefile.in @@ -83,7 +83,8 @@ host_triplet = @host@ DIST_COMMON = $(top_srcdir)/config/eu.am $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(top_srcdir)/config/depcomp \ $(noinst_HEADERS) ChangeLog -@MUDFLAP_TRUE@am__append_1 = -fmudflap +@BUILD_WERROR_TRUE@am__append_1 = $(if $($(*F)_no_Werror),,-Werror) +@MUDFLAP_TRUE@am__append_2 = -fmudflap subdir = backends ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/biarch.m4 \ @@ -284,6 +285,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@ @@ -315,6 +317,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ @@ -378,10 +381,9 @@ AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_sr -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \ -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ - $($(*F)_no_Werror),,-Werror) $(if \ - $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ + $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ - $(am__append_1) + $(am__append_1) $(am__append_2) @MUDFLAP_FALSE@libmudflap = @MUDFLAP_TRUE@libmudflap = -lmudflap COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage $(no_mudflap.os),\ @@ -888,7 +890,7 @@ libebl_%.so libebl_%.map: libebl_%_pic.a $(LINK) -shared -o $(@:.map=.so) \ -Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \ -Wl,--version-script,$(@:.so=.map) \ - -Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw) $(libmudflap) + -Wl,-z,defs $(LD_AS_NEEDED) $(libelf) $(libdw) $(libmudflap) $(textrel_check) libebl_i386.so: $(cpu_i386) --- elfutils/ChangeLog +++ elfutils/ChangeLog @@ -118,6 +118,8 @@ 2012-01-24 Mark Wielaard + * configure.ac: Wrap AC_COMPILE_IFELSE sources in AC_LANG_SOURCE. + * COPYING: Fix address. Updated version from gnulib. 2012-01-23 Mark Wielaard @@ -136,6 +138,9 @@ 2011-10-08 Mike Frysinger + * configure.ac (--disable-werror): Handle it, controlling BUILD_WERROR + automake option. + * configure.ac: Fix use of AC_ARG_ENABLE to handle $enableval correctly. 2011-10-02 Ulrich Drepper @@ -157,6 +162,10 @@ * configure.ac (LOCALEDIR, DATADIRNAME): Removed. +2009-11-22 Roland McGrath + + * configure.ac: Use sed and expr instead of modern bash extensions. + 2009-09-21 Ulrich Drepper * configure.ac: Update for more modern autoconf. @@ -165,6 +174,10 @@ * configure.ac (zip_LIBS): Check for liblzma too. +2009-08-17 Roland McGrath + + * configure.ac: Check for -fgnu89-inline; add it to WEXTRA if it works. + 2009-04-19 Roland McGrath * configure.ac (eu_version): Round down here, not in version.h macros. @@ -176,6 +189,8 @@ 2009-01-23 Roland McGrath + * configure.ac: Check for __builtin_popcount. + * configure.ac (zlib check): Check for gzdirect, need zlib >= 1.2.2.3. * configure.ac (__thread check): Use AC_LINK_IFELSE, in case of @@ -256,6 +271,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. @@ -303,6 +322,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. + + * 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. + 2005-05-19 Roland McGrath * configure.ac [AH_BOTTOM] (INTDECL, _INTDECL): New macros. --- elfutils/config/ChangeLog +++ elfutils/config/ChangeLog @@ -44,6 +44,10 @@ * known-dwarf.awk: Use gawk. +2011-10-08 Mike Frysinger + + * eu.am [BUILD_WERROR]: Conditionalize -Werror use on this. + 2010-07-02 Ulrich Drepper * elfutils.spec.in: Add more BuildRequires. --- elfutils/config/eu.am +++ elfutils/config/eu.am @@ -1,6 +1,6 @@ ## Common automake fragments for elfutils subdirectory makefiles. ## -## Copyright (C) 2010 Red Hat, Inc. +## Copyright (C) 2010-2011 Red Hat, Inc. ## ## This file is part of elfutils. ## @@ -29,14 +29,20 @@ ## not, see . ## +WEXTRA = @WEXTRA@ +LD_AS_NEEDED = @LD_AS_NEEDED@ + DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"' AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. AM_CFLAGS = -std=gnu99 -Wall -Wshadow \ - $(if $($(*F)_no_Werror),,-Werror) \ - $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ + $(if $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) \ $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \ $($(*F)_CFLAGS) +if BUILD_WERROR +AM_CFLAGS += $(if $($(*F)_no_Werror),,-Werror) +endif + if MUDFLAP AM_CFLAGS += -fmudflap libmudflap = -lmudflap --- elfutils/config/Makefile.in +++ elfutils/config/Makefile.in @@ -146,6 +146,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@ @@ -177,6 +178,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ --- elfutils/config.h.in +++ elfutils/config.h.in @@ -6,6 +6,9 @@ /* Defined if libdw should support GNU ref_alt FORM, dwz multi files. */ #undef ENABLE_DWZ +/* Have __builtin_popcount. */ +#undef HAVE_BUILTIN_POPCOUNT + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -102,4 +105,7 @@ /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES +/* Stubbed out if missing compiler support. */ +#undef __thread + #include --- elfutils/configure +++ elfutils/configure @@ -661,6 +661,8 @@ ZLIB_TRUE LIBEBL_SUBDIR TESTS_RPATH_FALSE TESTS_RPATH_TRUE +BUILD_WERROR_FALSE +BUILD_WERROR_TRUE BUILD_STATIC_FALSE BUILD_STATIC_TRUE USE_VALGRIND_FALSE @@ -678,6 +680,8 @@ NEVER_TRUE base_cpu NATIVE_LD_FALSE NATIVE_LD_TRUE +LD_AS_NEEDED +WEXTRA NM READELF ac_ct_AR @@ -802,6 +806,7 @@ enable_debugpred enable_gprof enable_gcov enable_valgrind +enable_werror enable_tests_rpath enable_libebl_subdir with_zlib @@ -1461,6 +1466,7 @@ Optional Features: --enable-gprof build binaries with gprof support --enable-gcov build binaries with gcov support --enable-valgrind run all tests under valgrind + --disable-werror do not build with -Werror --enable-tests-rpath build $ORIGIN-using rpath into tests --enable-libebl-subdir=DIR install libebl_CPU modules in $(libdir)/DIR @@ -4709,6 +4715,130 @@ if test "x$ac_cv_c99" != xyes; then : as_fn_error $? "gcc with C99 support required" "$LINENO" 5 fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wextra option to $CC" >&5 +$as_echo_n "checking for -Wextra option to $CC... " >&6; } +if ${ac_cv_cc_wextra+:} false; then : + $as_echo_n "(cached) " >&6 +else + old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wextra" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +void foo (void) { } +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_cc_wextra=yes +else + ac_cv_cc_wextra=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$old_CFLAGS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cc_wextra" >&5 +$as_echo "$ac_cv_cc_wextra" >&6; } + +if test "x$ac_cv_cc_wextra" = xyes; then : + WEXTRA=-Wextra +else + WEXTRA=-W +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fgnu89-inline option to $CC" >&5 +$as_echo_n "checking for -fgnu89-inline option to $CC... " >&6; } +if ${ac_cv_cc_gnu89_inline+:} false; then : + $as_echo_n "(cached) " >&6 +else + old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fgnu89-inline -Werror" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +void foo (void) +{ + inline void bar (void) {} + bar (); +} +extern inline void baz (void) {} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_cc_gnu89_inline=yes +else + 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:${as_lineno-$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:${as_lineno-$LINENO}: checking for --as-needed linker option" >&5 +$as_echo_n "checking for --as-needed linker option... " >&6; } +if ${ac_cv_as_needed+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then + ac_cv_as_needed=yes +else + ac_cv_as_needed=no +fi +rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_as_needed" >&5 +$as_echo "$ac_cv_as_needed" >&6; } +if test "x$ac_cv_as_needed" = xyes; then : + LD_AS_NEEDED=-Wl,--as-needed +else + LD_AS_NEEDED= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_popcount" >&5 +$as_echo_n "checking for __builtin_popcount... " >&6; } +if ${ac_cv_popcount+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +exit (__builtin_popcount (127)); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_popcount=yes +else + ac_cv_popcount=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_popcount" >&5 +$as_echo "$ac_cv_popcount" >&6; } +if test "x$ac_cv_popcount" = xyes; then : + +$as_echo "#define HAVE_BUILTIN_POPCOUNT 1" >>confdefs.h + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __thread support" >&5 $as_echo_n "checking for __thread support... " >&6; } if ${ac_cv_tls+:} false; then : @@ -4745,7 +4875,13 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_tls" >&5 $as_echo "$ac_cv_tls" >&6; } if test "x$ac_cv_tls" != xyes; then : - as_fn_error $? "__thread support required" "$LINENO" 5 + if test "$use_locks" = yes; then : + as_fn_error $? "--enable-thread-safety requires __thread support" "$LINENO" 5 +else + +$as_echo "#define __thread /* empty: no multi-thread support */" >>confdefs.h + +fi fi # Check whether --enable-largefile was given. @@ -5155,6 +5291,22 @@ else fi +# Check whether --enable-werror was given. +if test "${enable_werror+set}" = set; then : + enableval=$enable_werror; enable_werror=$enableval +else + enable_werror=yes +fi + + if test "$enable_werror" = yes; then + BUILD_WERROR_TRUE= + BUILD_WERROR_FALSE='#' +else + BUILD_WERROR_TRUE='#' + BUILD_WERROR_FALSE= +fi + + # Check whether --enable-tests-rpath was given. if test "${enable_tests_rpath+set}" = set; then : enableval=$enable_tests_rpath; tests_use_rpath=$enableval @@ -5875,7 +6027,7 @@ case "$eu_version" in esac # Round up to the next release API (x.y) version. -eu_version=$(( (eu_version + 999) / 1000 )) +eu_version=`expr \( $eu_version + 999 \) / 1000` ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -6613,6 +6765,10 @@ if test -z "${BUILD_STATIC_TRUE}" && tes as_fn_error $? "conditional \"BUILD_STATIC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${BUILD_WERROR_TRUE}" && test -z "${BUILD_WERROR_FALSE}"; then + as_fn_error $? "conditional \"BUILD_WERROR\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${TESTS_RPATH_TRUE}" && test -z "${TESTS_RPATH_FALSE}"; then as_fn_error $? "conditional \"TESTS_RPATH\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 --- elfutils/configure.ac +++ elfutils/configure.ac @@ -99,6 +99,54 @@ CFLAGS="$old_CFLAGS"]) AS_IF([test "x$ac_cv_c99" != xyes], AC_MSG_ERROR([gcc with C99 support required])) +AC_CACHE_CHECK([for -Wextra option to $CC], ac_cv_cc_wextra, [dnl +old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wextra" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([void foo (void) { }])], + ac_cv_cc_wextra=yes, ac_cv_cc_wextra=no) +CFLAGS="$old_CFLAGS"]) +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([AC_LANG_SOURCE([ +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 <&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) + +AC_CACHE_CHECK([for __builtin_popcount], ac_cv_popcount, [dnl +AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[exit (__builtin_popcount (127));]])], + ac_cv_popcount=yes, ac_cv_popcount=no)]) +AS_IF([test "x$ac_cv_popcount" = xyes], + [AC_DEFINE([HAVE_BUILTIN_POPCOUNT], [1], [Have __builtin_popcount.])]) + AC_CACHE_CHECK([for __thread support], ac_cv_tls, [dnl # Use the same flags that we use for our DSOs, so the test is representative. # Some old compiler/linker/libc combinations fail some ways and not others. @@ -114,7 +162,10 @@ static __thread int a; int foo (int b) { CFLAGS="$save_CFLAGS" LDFLAGS="$save_LDFLAGS"]) AS_IF([test "x$ac_cv_tls" != xyes], - AC_MSG_ERROR([__thread support required])) + [AS_IF([test "$use_locks" = yes], + [AC_MSG_ERROR([--enable-thread-safety requires __thread support])], + [AC_DEFINE([__thread], [/* empty: no multi-thread support */], + [Stubbed out if missing compiler support.])])]) dnl This test must come as early as possible after the compiler configuration dnl tests, because the choice of the file model can (in principle) affect @@ -213,6 +264,11 @@ AM_CONDITIONAL(USE_VALGRIND, test "$use_ AM_CONDITIONAL(BUILD_STATIC, [dnl test "$use_mudflap" = yes -o "$use_gprof" = yes -o "$use_gcov" = yes]) +AC_ARG_ENABLE([werror], +AS_HELP_STRING([--disable-werror],[do not build with -Werror]), + [enable_werror=$enableval], [enable_werror=yes]) +AM_CONDITIONAL(BUILD_WERROR, test "$enable_werror" = yes) + AC_ARG_ENABLE([tests-rpath], AS_HELP_STRING([--enable-tests-rpath],[build $ORIGIN-using rpath into tests]), [tests_use_rpath=$enableval], [tests_use_rpath=no]) @@ -324,7 +380,7 @@ case "$eu_version" in esac # Round up to the next release API (x.y) version. -eu_version=$(( (eu_version + 999) / 1000 )) +eu_version=`expr \( $eu_version + 999 \) / 1000` AC_CHECK_SIZEOF(long) --- elfutils/lib/ChangeLog +++ elfutils/lib/ChangeLog @@ -61,6 +61,9 @@ 2009-01-23 Roland McGrath + * eu-config.h [! HAVE_BUILTIN_POPCOUNT] + (__builtin_popcount): New inline function. + * eu-config.h: Add multiple inclusion protection. 2009-01-17 Ulrich Drepper @@ -117,6 +120,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-04-30 Ulrich Drepper * Makefile.am: Use -ffunction-sections for xmalloc.c. --- elfutils/lib/eu-config.h +++ elfutils/lib/eu-config.h @@ -162,6 +162,17 @@ asm (".section predict_data, \"aw\"; .pr /* This macro is used by the tests conditionalize for standalone building. */ #define ELFUTILS_HEADER(name) +#ifndef HAVE_BUILTIN_POPCOUNT +# define __builtin_popcount hakmem_popcount +static inline unsigned int __attribute__ ((unused)) +hakmem_popcount (unsigned int x) +{ + /* HAKMEM 169 */ + unsigned int n = x - ((x >> 1) & 033333333333) - ((x >> 2) & 011111111111); + return ((n + (n >> 3)) & 030707070707) % 63; +} +#endif /* HAVE_BUILTIN_POPCOUNT */ + #ifdef SHARED # define OLD_VERSION(name, version) \ --- elfutils/lib/Makefile.in +++ elfutils/lib/Makefile.in @@ -82,7 +82,8 @@ host_triplet = @host@ DIST_COMMON = $(top_srcdir)/config/eu.am $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(top_srcdir)/config/depcomp \ $(noinst_HEADERS) ChangeLog -@MUDFLAP_TRUE@am__append_1 = -fmudflap +@BUILD_WERROR_TRUE@am__append_1 = $(if $($(*F)_no_Werror),,-Werror) +@MUDFLAP_TRUE@am__append_2 = -fmudflap subdir = lib ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/biarch.m4 \ @@ -198,6 +199,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@ @@ -229,6 +231,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ @@ -291,10 +294,9 @@ zip_LIBS = @zip_LIBS@ AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. \ -I$(srcdir)/../libelf AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ - $($(*F)_no_Werror),,-Werror) $(if \ - $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ + $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ - $(am__append_1) -fpic + $(am__append_1) $(am__append_2) -fpic @MUDFLAP_FALSE@libmudflap = @MUDFLAP_TRUE@libmudflap = -lmudflap COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage $(no_mudflap.os),\ --- elfutils/libasm/ChangeLog +++ elfutils/libasm/ChangeLog @@ -75,6 +75,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.in +++ elfutils/libasm/Makefile.in @@ -83,10 +83,11 @@ host_triplet = @host@ DIST_COMMON = $(top_srcdir)/config/eu.am $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(top_srcdir)/config/depcomp \ $(noinst_HEADERS) $(pkginclude_HEADERS) ChangeLog -@MUDFLAP_TRUE@am__append_1 = -fmudflap +@BUILD_WERROR_TRUE@am__append_1 = $(if $($(*F)_no_Werror),,-Werror) +@MUDFLAP_TRUE@am__append_2 = -fmudflap @MUDFLAP_FALSE@noinst_PROGRAMS = $(am__EXEEXT_1) @MUDFLAP_TRUE@am_libasm_pic_a_OBJECTS = -@MUDFLAP_FALSE@@USE_LOCKS_TRUE@am__append_2 = -lpthread +@MUDFLAP_FALSE@@USE_LOCKS_TRUE@am__append_3 = -lpthread subdir = libasm ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/biarch.m4 \ @@ -250,6 +251,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@ @@ -281,6 +283,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ @@ -344,10 +347,9 @@ AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_sr -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl \ -I$(top_srcdir)/libdw AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ - $($(*F)_no_Werror),,-Werror) $(if \ - $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ + $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ - $(am__append_1) + $(am__append_1) $(am__append_2) @MUDFLAP_FALSE@libmudflap = @MUDFLAP_TRUE@libmudflap = -lmudflap COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage $(no_mudflap.os),\ @@ -376,7 +378,7 @@ libasm_a_SOURCES = asm_begin.c asm_abort @MUDFLAP_FALSE@libasm_pic_a_SOURCES = @MUDFLAP_FALSE@am_libasm_pic_a_OBJECTS = $(libasm_a_SOURCES:.c=.os) -@MUDFLAP_FALSE@libasm_so_LDLIBS = $(am__append_2) +@MUDFLAP_FALSE@libasm_so_LDLIBS = $(am__append_3) @MUDFLAP_FALSE@libasm_so_SOURCES = noinst_HEADERS = libasmP.h symbolhash.h EXTRA_DIST = libasm.map --- elfutils/libcpu/ChangeLog +++ elfutils/libcpu/ChangeLog @@ -47,6 +47,9 @@ 2009-01-23 Roland McGrath + * i386_disasm.c (i386_disasm): Add abort after assert-constant for old + compilers that don't realize it's noreturn. + * Makefile.am (i386_parse_CFLAGS): Use quotes around command substitution that can produce leading whitespace. @@ -376,6 +379,11 @@ * defs/i386.doc: New file. * defs/x86_64: New file. +2005-04-04 Roland McGrath + + * Makefile.am (WEXTRA): New variable, substituted by configure. + (AM_CFLAGS): Use it instead of -Wextra. + 2005-02-15 Ulrich Drepper * Makefile (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2. --- elfutils/libcpu/i386_disasm.c +++ elfutils/libcpu/i386_disasm.c @@ -822,6 +822,7 @@ i386_disasm (const uint8_t **startp, con default: assert (! "INVALID not handled"); + abort (); } } else --- elfutils/libcpu/Makefile.in +++ elfutils/libcpu/Makefile.in @@ -84,7 +84,8 @@ DIST_COMMON = $(top_srcdir)/config/eu.am $(srcdir)/Makefile.am i386_lex.c i386_parse.c \ $(top_srcdir)/config/depcomp $(top_srcdir)/config/ylwrap \ $(am__noinst_HEADERS_DIST) ChangeLog -@MUDFLAP_TRUE@am__append_1 = -fmudflap +@BUILD_WERROR_TRUE@am__append_1 = $(if $($(*F)_no_Werror),,-Werror) +@MUDFLAP_TRUE@am__append_2 = -fmudflap @MAINTAINER_MODE_TRUE@noinst_PROGRAMS = i386_gendis$(EXEEXT) subdir = libcpu ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -225,6 +226,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.$( + + * dwarf_begin_elf.c: Add fallback for be64toh if not defined. + 2011-07-14 Mark Wielaard * libdw.h (dwarf_offdie): Fix documentation to mention .debug_info. @@ -705,6 +709,10 @@ * dwarf_hasattr_integrate.c: Integrate DW_AT_specification too. +2009-08-17 Roland McGrath + + * libdw.h: Disable extern inlines for GCC 4.2. + 2009-08-10 Roland McGrath * dwarf_getscopevar.c: Use dwarf_diename. @@ -1473,6 +1481,11 @@ 2005-05-31 Roland McGrath + * 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/dwarf_begin_elf.c +++ elfutils/libdw/dwarf_begin_elf.c @@ -48,6 +48,14 @@ #if USE_ZLIB # include # define crc32 loser_crc32 +# ifndef be64toh +# include +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define be64toh(x) bswap_64 (x) +# else +# define be64toh(x) (x) +# endif +# endif # include # undef crc32 #endif --- elfutils/libdw/libdw.h +++ elfutils/libdw/libdw.h @@ -879,7 +879,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.in +++ elfutils/libdw/Makefile.in @@ -84,8 +84,9 @@ DIST_COMMON = $(top_srcdir)/config/eu.am $(srcdir)/Makefile.am $(top_srcdir)/config/depcomp \ $(include_HEADERS) $(noinst_HEADERS) $(pkginclude_HEADERS) \ ChangeLog -@MUDFLAP_TRUE@am__append_1 = -fmudflap -@BUILD_STATIC_TRUE@am__append_2 = -fpic +@BUILD_WERROR_TRUE@am__append_1 = $(if $($(*F)_no_Werror),,-Werror) +@MUDFLAP_TRUE@am__append_2 = -fmudflap +@BUILD_STATIC_TRUE@am__append_3 = -fpic @MUDFLAP_FALSE@noinst_PROGRAMS = $(am__EXEEXT_1) @MUDFLAP_TRUE@am_libdw_pic_a_OBJECTS = subdir = libdw @@ -295,6 +296,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@ @@ -326,6 +328,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ @@ -388,10 +391,9 @@ zip_LIBS = @zip_LIBS@ AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. \ -I$(srcdir)/../libelf AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ - $($(*F)_no_Werror),,-Werror) $(if \ - $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ + $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ - $(am__append_1) $(am__append_2) + $(am__append_1) $(am__append_2) $(am__append_3) @MUDFLAP_FALSE@libmudflap = @MUDFLAP_TRUE@libmudflap = -lmudflap COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage $(no_mudflap.os),\ --- elfutils/libdwfl/ChangeLog +++ elfutils/libdwfl/ChangeLog @@ -283,6 +283,21 @@ (dwfl_module_addrsym) (i_to_symfile): New function. (dwfl_module_addrsym) (search_table): Use it. +2013-11-09 Jan Kratochvil + + Older OS compatibility bits. + * linux-core-attach.c (be64toh, le64toh, be32toh, le32toh): Provide + fallbacks if not defined by system. + +2013-11-09 Jan Kratochvil + + Handle T-stopped detach for old kernels. + * linux-pid-attach.c (struct pid_arg): New field stopped. + (ptrace_attach): New parameter stoppedp. Set it appropriately. + (pid_set_initial_registers): Pass the new field. + (pid_thread_detach): Handle the case of STOPPED for old kernels. + (__libdwfl_attach_state_for_pid): Initialize STOPPED. + 2013-11-07 Jan Kratochvil Mark Wielaard @@ -2048,6 +2063,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/linux-core-attach.c +++ elfutils/libdwfl/linux-core-attach.c @@ -29,6 +29,35 @@ #include "libdwflP.h" #include #include "system.h" +#include +#include +#if __BYTE_ORDER == __LITTLE_ENDIAN +# ifndef be64toh +# define be64toh(x) bswap_64 (x) +# endif +# ifndef le64toh +# define le64toh(x) (x) +# endif +# ifndef be32toh +# define be32toh(x) bswap_32 (x) +# endif +# ifndef le32toh +# define le32toh(x) (x) +# endif +#else +# ifndef be64toh +# define be64toh(x) (x) +# endif +# ifndef le64toh +# define le64toh(x) bswap_64 (x) +# endif +# ifndef be32toh +# define be32toh(x) (x) +# endif +# ifndef le32toh +# define le32toh(x) bswap_32 (x) +# endif +#endif #ifndef MIN # define MIN(a, b) ((a) < (b) ? (a) : (b)) --- elfutils/libdwfl/linux-pid-attach.c +++ elfutils/libdwfl/linux-pid-attach.c @@ -268,13 +268,24 @@ pid_thread_detach (Dwfl_Thread *thread, pid_arg->tid_attached = 0; if (! pid_arg->assume_ptrace_stopped) { + // Older kernels (tested kernel-2.6.18-348.12.1.el5.x86_64) need special + // handling of the detachment to keep the process State: T (stopped). + if (pid_arg->tid_was_stopped) + syscall (__NR_tkill, tid, SIGSTOP); /* This handling is needed only on older Linux kernels such as - 2.6.32-358.23.2.el6.ppc64. Later kernels such as - 3.11.7-200.fc19.x86_64 remember the T (stopped) state - themselves and no longer need to pass SIGSTOP during - PTRACE_DETACH. */ + 2.6.32-358.23.2.el6.ppc64. Later kernels such as 3.11.7-200.fc19.x86_64 + remember the T (stopped) state themselves and no longer need to pass + SIGSTOP during PTRACE_DETACH. */ ptrace (PTRACE_DETACH, tid, NULL, (void *) (intptr_t) (pid_arg->tid_was_stopped ? SIGSTOP : 0)); + if (pid_arg->tid_was_stopped) + { + // Wait till the SIGSTOP settles down. + int i; + for (i = 0; i < 100000; i++) + if (linux_proc_pid_is_stopped (tid)) + break; + } } } --- elfutils/libdwfl/Makefile.in +++ elfutils/libdwfl/Makefile.in @@ -82,11 +82,12 @@ host_triplet = @host@ DIST_COMMON = $(top_srcdir)/config/eu.am $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(top_srcdir)/config/depcomp \ $(noinst_HEADERS) $(pkginclude_HEADERS) ChangeLog -@MUDFLAP_TRUE@am__append_1 = -fmudflap -@MUDFLAP_FALSE@am__append_2 = libdwfl_pic.a -@ZLIB_TRUE@am__append_3 = gzip.c -@BZLIB_TRUE@am__append_4 = bzip2.c -@LZMA_TRUE@am__append_5 = lzma.c +@BUILD_WERROR_TRUE@am__append_1 = $(if $($(*F)_no_Werror),,-Werror) +@MUDFLAP_TRUE@am__append_2 = -fmudflap +@MUDFLAP_FALSE@am__append_3 = libdwfl_pic.a +@ZLIB_TRUE@am__append_4 = gzip.c +@BZLIB_TRUE@am__append_5 = bzip2.c +@LZMA_TRUE@am__append_6 = lzma.c @MUDFLAP_TRUE@am_libdwfl_pic_a_OBJECTS = subdir = libdwfl ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -289,6 +290,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@ @@ -320,6 +322,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ @@ -383,10 +386,9 @@ AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_sr -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ -I$(srcdir)/../libdw AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ - $($(*F)_no_Werror),,-Werror) $(if \ - $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ + $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ - $(am__append_1) + $(am__append_1) $(am__append_2) @MUDFLAP_FALSE@libmudflap = @MUDFLAP_TRUE@libmudflap = -lmudflap COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage $(no_mudflap.os),\ @@ -394,7 +396,7 @@ COMPILE.os = $(filter-out -fprofile-arcs CLEANFILES = *.gcno *.gcda $(am_libdwfl_pic_a_OBJECTS) textrel_check = if $(READELF) -d $@ | fgrep -q TEXTREL; then exit 1; fi -noinst_LIBRARIES = libdwfl.a $(am__append_2) +noinst_LIBRARIES = libdwfl.a $(am__append_3) pkginclude_HEADERS = libdwfl.h libdwfl_a_SOURCES = dwfl_begin.c dwfl_end.c dwfl_error.c \ dwfl_version.c dwfl_module.c dwfl_report_elf.c relocate.c \ @@ -417,8 +419,8 @@ libdwfl_a_SOURCES = dwfl_begin.c dwfl_en dwfl_module_register_names.c dwfl_segment_report_module.c \ link_map.c core-file.c open.c image-header.c dwfl_frame.c \ frame_unwind.c dwfl_frame_pc.c linux-pid-attach.c \ - linux-core-attach.c dwfl_frame_regs.c $(am__append_3) \ - $(am__append_4) $(am__append_5) + linux-core-attach.c dwfl_frame_regs.c $(am__append_4) \ + $(am__append_5) $(am__append_6) @MUDFLAP_FALSE@libdwfl = $(libdw) @MUDFLAP_TRUE@libdwfl = libdwfl.a $(libdw) $(libebl) $(libelf) $(libeu) @MUDFLAP_FALSE@libdw = ../libdw/libdw.so --- elfutils/libebl/ChangeLog +++ elfutils/libebl/ChangeLog @@ -738,6 +738,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.in +++ elfutils/libebl/Makefile.in @@ -82,7 +82,8 @@ host_triplet = @host@ DIST_COMMON = $(top_srcdir)/config/eu.am $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(top_srcdir)/config/depcomp \ $(noinst_HEADERS) $(pkginclude_HEADERS) ChangeLog -@MUDFLAP_TRUE@am__append_1 = -fmudflap +@BUILD_WERROR_TRUE@am__append_1 = $(if $($(*F)_no_Werror),,-Werror) +@MUDFLAP_TRUE@am__append_2 = -fmudflap subdir = libebl ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/biarch.m4 \ @@ -249,6 +250,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@ @@ -280,6 +282,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ @@ -343,10 +346,9 @@ AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_sr -I$(srcdir)/../libelf -I$(srcdir)/../libdw \ -I$(srcdir)/../libasm AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ - $($(*F)_no_Werror),,-Werror) $(if \ - $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ + $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ - $(am__append_1) -fpic + $(am__append_1) $(am__append_2) -fpic @MUDFLAP_FALSE@libmudflap = @MUDFLAP_TRUE@libmudflap = -lmudflap COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage $(no_mudflap.os),\ --- elfutils/libelf/ChangeLog +++ elfutils/libelf/ChangeLog @@ -85,6 +85,11 @@ * elf-knowledge.h (SECTION_STRIP_P): Remove < SHT_NUM check. +2011-03-10 Roland McGrath + + * gnuhash_xlate.h (elf_cvt_gnuhash): Avoid post-increment in bswap_32 + argument, since some implementations are buggy macros. + 2011-02-26 Mark Wielaard * elf_end.c (elf_end): Call rwlock_unlock before rwlock_fini. @@ -762,6 +767,11 @@ * elf.h: Update from glibc. +2005-05-31 Roland McGrath + + * Makefile.am (WEXTRA): New variable, substituted by configure. + (AM_CFLAGS): Use it in place of -Wextra. + 2005-05-08 Roland McGrath * elf_begin.c (read_file) [_MUDFLAP]: Don't use mmap for now. --- elfutils/libelf/common.h +++ elfutils/libelf/common.h @@ -139,7 +139,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)))) @@ -148,7 +148,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/gnuhash_xlate.h +++ elfutils/libelf/gnuhash_xlate.h @@ -1,5 +1,5 @@ /* Conversion functions for versioning information. - Copyright (C) 2006, 2007 Red Hat, Inc. + Copyright (C) 2006-2011 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2006. @@ -68,7 +68,9 @@ elf_cvt_gnuhash (void *dest, const void dest32 = (Elf32_Word *) &dest64[bitmask_words]; while (len >= 4) { - *dest32++ = bswap_32 (*src32++); + *dest32 = bswap_32 (*src32); + ++dest32; + ++src32; len -= 4; } } --- elfutils/libelf/Makefile.in +++ elfutils/libelf/Makefile.in @@ -84,11 +84,12 @@ DIST_COMMON = $(top_srcdir)/config/eu.am $(srcdir)/Makefile.am $(top_srcdir)/config/depcomp \ $(include_HEADERS) $(noinst_HEADERS) $(pkginclude_HEADERS) \ ChangeLog -@MUDFLAP_TRUE@am__append_1 = -fmudflap -@BUILD_STATIC_TRUE@am__append_2 = -fpic +@BUILD_WERROR_TRUE@am__append_1 = $(if $($(*F)_no_Werror),,-Werror) +@MUDFLAP_TRUE@am__append_2 = -fmudflap +@BUILD_STATIC_TRUE@am__append_3 = -fpic @MUDFLAP_FALSE@noinst_PROGRAMS = $(am__EXEEXT_1) @MUDFLAP_TRUE@am_libelf_pic_a_OBJECTS = -@MUDFLAP_FALSE@@USE_LOCKS_TRUE@am__append_3 = -lpthread +@MUDFLAP_FALSE@@USE_LOCKS_TRUE@am__append_4 = -lpthread subdir = libelf ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/biarch.m4 \ @@ -293,6 +294,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@ @@ -324,6 +326,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = 1 +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ @@ -385,10 +388,9 @@ top_srcdir = @top_srcdir@ zip_LIBS = @zip_LIBS@ AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ - $($(*F)_no_Werror),,-Werror) $(if \ - $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ + $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ - $(am__append_1) $(am__append_2) + $(am__append_1) $(am__append_2) $(am__append_3) @MUDFLAP_FALSE@libmudflap = @MUDFLAP_TRUE@libmudflap = -lmudflap COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage $(no_mudflap.os),\ @@ -453,7 +455,7 @@ libelf_a_SOURCES = elf_version.c elf_has @MUDFLAP_FALSE@libelf_pic_a_SOURCES = @MUDFLAP_FALSE@am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=.os) -@MUDFLAP_FALSE@libelf_so_LDLIBS = $(am__append_3) +@MUDFLAP_FALSE@libelf_so_LDLIBS = $(am__append_4) @MUDFLAP_FALSE@libelf_so_SOURCES = noinst_HEADERS = elf.h abstract.h common.h exttypes.h gelf_xlate.h libelfP.h \ version_xlate.h gnuhash_xlate.h note_xlate.h dl-hash.h --- elfutils/m4/Makefile.in +++ elfutils/m4/Makefile.in @@ -145,6 +145,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@ @@ -176,6 +177,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ --- elfutils/Makefile.in +++ elfutils/Makefile.in @@ -263,6 +263,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@ @@ -294,6 +295,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ --- elfutils/src/addr2line.c +++ elfutils/src/addr2line.c @@ -540,10 +540,10 @@ handle_address (const char *string, Dwfl bool parsed = false; int i, j; char *name = NULL; - if (sscanf (string, "(%m[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2 + if (sscanf (string, "(%a[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2 && string[i] == '\0') parsed = adjust_to_section (name, &addr, dwfl); - switch (sscanf (string, "%m[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j)) + switch (sscanf (string, "%a[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j)) { default: break; --- elfutils/src/ChangeLog +++ elfutils/src/ChangeLog @@ -964,8 +964,16 @@ * readelf.c (attr_callback): Use print_block only when we don't use print_ops. +2009-08-17 Roland McGrath + + * ld.h: Disable extern inlines for GCC 4.2. + 2009-08-14 Roland McGrath + * strings.c (read_block): Conditionalize posix_fadvise use + on [POSIX_FADV_SEQUENTIAL]. + From Petr Salinger . + * ar.c (do_oper_extract): Use pathconf instead of statfs. 2009-08-01 Ulrich Drepper @@ -1129,6 +1137,8 @@ * readelf.c (print_debug_frame_section): Use t instead of j formats for ptrdiff_t OFFSET. + * addr2line.c (handle_address): Use %a instead of %m for compatibility. + 2009-01-21 Ulrich Drepper * elflint.c (check_program_header): Fix typo in .eh_frame_hdr section @@ -1312,6 +1322,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. @@ -1563,6 +1578,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. @@ -2002,6 +2019,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. @@ -2078,6 +2099,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 @@ -2426,6 +2451,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 @@ -496,7 +496,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/ld.h +++ elfutils/src/ld.h @@ -1114,6 +1114,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 @@ -1131,5 +1132,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 @@ -95,6 +95,9 @@ addr2line_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 \ $(demanglelib) --- elfutils/src/Makefile.in +++ elfutils/src/Makefile.in @@ -85,7 +85,8 @@ DIST_COMMON = $(top_srcdir)/config/eu.am $(srcdir)/Makefile.am ldlex.c ldscript.c \ $(top_srcdir)/config/depcomp $(top_srcdir)/config/ylwrap \ $(noinst_HEADERS) ChangeLog -@MUDFLAP_TRUE@am__append_1 = -fmudflap +@BUILD_WERROR_TRUE@am__append_1 = $(if $($(*F)_no_Werror),,-Werror) +@MUDFLAP_TRUE@am__append_2 = -fmudflap bin_PROGRAMS = readelf$(EXEEXT) nm$(EXEEXT) size$(EXEEXT) \ strip$(EXEEXT) ld$(EXEEXT) elflint$(EXEEXT) \ findtextrel$(EXEEXT) addr2line$(EXEEXT) elfcmp$(EXEEXT) \ @@ -94,9 +95,9 @@ bin_PROGRAMS = readelf$(EXEEXT) nm$(EXEE @NATIVE_LD_FALSE@noinst_PROGRAMS = $(am__EXEEXT_1) # We never build this library but we need to get the dependency files # of all the linker backends that might be used in a non-generic linker. -@NEVER_TRUE@am__append_2 = libdummy.a +@NEVER_TRUE@am__append_3 = libdummy.a # -ldl is always needed for libebl. -@NATIVE_LD_TRUE@am__append_3 = libld_elf.a +@NATIVE_LD_TRUE@am__append_4 = libld_elf.a @NATIVE_LD_TRUE@am_libld_elf_i386_pic_a_OBJECTS = subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -164,7 +165,7 @@ am_ld_OBJECTS = ld.$(OBJEXT) ldgeneric.$ versionhash.$(OBJEXT) ld_OBJECTS = $(am_ld_OBJECTS) ld_DEPENDENCIES = $(libebl) $(libelf) $(libeu) $(am__DEPENDENCIES_1) \ - $(am__append_3) + $(am__append_4) ld_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(ld_LDFLAGS) $(LDFLAGS) -o \ $@ am_libld_elf_i386_so_OBJECTS = @@ -347,6 +348,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@ @@ -378,6 +380,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ @@ -442,10 +445,9 @@ AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_sr -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \ -I$(srcdir)/../libasm AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ - $($(*F)_no_Werror),,-Werror) $(if \ - $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ + $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ - $(am__append_1) + $(am__append_1) $(am__append_2) @MUDFLAP_FALSE@libmudflap = @MUDFLAP_TRUE@libmudflap = -lmudflap COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage $(no_mudflap.os),\ @@ -461,8 +463,8 @@ AM_LFLAGS = -Pld -olex.yy.c native_ld = @native_ld@ ld_dsos = libld_elf_i386_pic.a @NATIVE_LD_FALSE@noinst_LIBRARIES = libld_elf.a libar.a $(ld_dsos) \ -@NATIVE_LD_FALSE@ $(am__append_2) -@NATIVE_LD_TRUE@noinst_LIBRARIES = libld_elf.a libar.a $(am__append_2) +@NATIVE_LD_FALSE@ $(am__append_3) +@NATIVE_LD_TRUE@noinst_LIBRARIES = libld_elf.a libar.a $(am__append_3) @NATIVE_LD_TRUE@native_ld_cflags = -DBASE_ELF_NAME=elf_$(base_cpu) @NEVER_TRUE@libdummy_a_SOURCES = i386_ld.c ld_SOURCES = ld.c ldgeneric.c ldlex.l ldscript.y symbolhash.c sectionhash.c \ @@ -491,6 +493,9 @@ strings_no_Wformat = yes addr2line_no_Wformat = yes # XXX While the file is not finished, don't warn about this ldgeneric_no_Wunused = yes + +# Buggy old compilers. +readelf_no_Werror = yes readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl \ $(demanglelib) @@ -498,7 +503,7 @@ nm_LDADD = $(libdw) $(libebl) $(libelf) size_LDADD = $(libelf) $(libeu) $(libmudflap) strip_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl ld_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl \ - $(am__append_3) + $(am__append_4) ld_LDFLAGS = -rdynamic elflint_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl findtextrel_LDADD = $(libdw) $(libelf) $(libmudflap) --- elfutils/src/readelf.c +++ elfutils/src/readelf.c @@ -4171,10 +4171,12 @@ listptr_base (struct listptr *p) return base; } +static const char *listptr_name; + static int -compare_listptr (const void *a, const void *b, void *arg) +compare_listptr (const void *a, const void *b) { - const char *name = arg; + const char *const name = listptr_name; struct listptr *p1 = (void *) a; struct listptr *p2 = (void *) b; @@ -4263,8 +4265,11 @@ static void sort_listptr (struct listptr_table *table, const char *name) { if (table->n > 0) - qsort_r (table->table, table->n, sizeof table->table[0], - &compare_listptr, (void *) name); + { + listptr_name = name; + qsort (table->table, table->n, sizeof table->table[0], + &compare_listptr); + } } static bool @@ -9151,7 +9156,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 @@ -43,6 +43,10 @@ #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); @@ -483,8 +487,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) @@ -576,9 +585,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 @@ -45,6 +45,12 @@ #include #include +#ifdef HAVE_FUTIMES +# define FUTIMES(fd, fname, tvp) futimes (fd, tvp) +#else +# define FUTIMES(fd, fname, tvp) utimes (fname, tvp) +#endif + typedef uint8_t GElf_Byte; /* Name and version of program. */ @@ -318,8 +324,18 @@ process_file (const char *fname) /* If we have to preserve the timestamp, we need it in the format utimes() understands. */ +#ifdef HAVE_STRUCT_STAT_ST_ATIM TIMESPEC_TO_TIMEVAL (&tv[0], &pre_st.st_atim); +#else + tv[0].tv_sec = pre_st.st_atime; + tv[0].tv_usec = 0; +#endif +#ifdef HAVE_STRUCT_STAT_ST_MTIM TIMESPEC_TO_TIMEVAL (&tv[1], &pre_st.st_mtim); +#else + tv[1].tv_sec = pre_st.st_atime; + tv[1].tv_usec = 0; +#endif } /* Open the file. */ @@ -2060,7 +2076,7 @@ while computing checksum for debug infor /* If requested, preserve the timestamp. */ if (tvp != NULL) { - if (futimes (fd, tvp) != 0) + if (FUTIMES (fd, output_fname, tvp) != 0) { error (0, errno, gettext ("\ cannot set access and modification date of '%s'"), @@ -2117,7 +2133,7 @@ handle_ar (int fd, Elf *elf, const char if (tvp != NULL) { - if (unlikely (futimes (fd, tvp) != 0)) + if (unlikely (FUTIMES (fd, fname, tvp) != 0)) { error (0, errno, gettext ("\ cannot set access and modification date of '%s'"), fname); --- elfutils/tests/backtrace.c +++ elfutils/tests/backtrace.c @@ -36,6 +36,7 @@ #include #include #include +#include #include ELFUTILS_HEADER(dwfl) static int --- elfutils/tests/ChangeLog +++ elfutils/tests/ChangeLog @@ -123,6 +123,13 @@ 2013-12-02 Jan Kratochvil + Handle T-stopped detach for old kernels. + * backtrace.c: Include sys/syscall.h. + (linux_proc_pid_is_stopped): New function. + (ptrace_detach_stopped): Handle old kernels. + +2013-12-02 Jan Kratochvil + * Makefile.am (check_PROGRAMS): Add backtrace, backtrace-child, backtrace-data and backtrace-dwarf. (BUILT_SOURCES, clean-local, backtrace-child-biarch): New. @@ -987,6 +994,8 @@ 2008-01-21 Roland McGrath + * line2addr.c (main): Revert last change. + * testfile45.S.bz2: Add tests for cltq, cqto. * testfile45.expect.bz2: Adjust. @@ -1695,6 +1704,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 @@ -124,7 +124,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.in +++ elfutils/tests/Makefile.in @@ -80,14 +80,15 @@ host_triplet = @host@ DIST_COMMON = $(top_srcdir)/config/eu.am $(srcdir)/Makefile.in \ $(srcdir)/Makefile.am $(top_srcdir)/config/depcomp \ $(top_srcdir)/config/test-driver ChangeLog -@MUDFLAP_TRUE@am__append_1 = -fmudflap -@STANDALONE_FALSE@am__append_2 = -I$(top_srcdir)/libasm -I$(top_srcdir)/libdw \ +@BUILD_WERROR_TRUE@am__append_1 = $(if $($(*F)_no_Werror),,-Werror) +@MUDFLAP_TRUE@am__append_2 = -fmudflap +@STANDALONE_FALSE@am__append_3 = -I$(top_srcdir)/libasm -I$(top_srcdir)/libdw \ @STANDALONE_FALSE@ -I$(top_srcdir)/libdwfl \ @STANDALONE_FALSE@ -I$(top_srcdir)/libebl -I$(top_srcdir)/libelf \ @STANDALONE_FALSE@ -I$(top_srcdir)/lib -I.. -@STANDALONE_FALSE@am__append_3 = -Wl,-rpath-link,../libasm:../libdw:../libelf -@TESTS_RPATH_TRUE@am__append_4 = -Wl,-rpath,$(BUILD_RPATH) +@STANDALONE_FALSE@am__append_4 = -Wl,-rpath-link,../libasm:../libdw:../libelf +@TESTS_RPATH_TRUE@am__append_5 = -Wl,-rpath,$(BUILD_RPATH) check_PROGRAMS = arextract$(EXEEXT) arsymtest$(EXEEXT) \ newfile$(EXEEXT) saridx$(EXEEXT) scnnames$(EXEEXT) \ sectiondump$(EXEEXT) showptable$(EXEEXT) update1$(EXEEXT) \ @@ -111,7 +112,7 @@ check_PROGRAMS = arextract$(EXEEXT) arsy varlocs$(EXEEXT) backtrace$(EXEEXT) backtrace-child$(EXEEXT) \ backtrace-data$(EXEEXT) backtrace-dwarf$(EXEEXT) \ $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_4) -@BIARCH_TRUE@am__append_5 = backtrace-child-biarch +@BIARCH_TRUE@am__append_6 = backtrace-child-biarch TESTS = run-arextract.sh run-arsymtest.sh newfile$(EXEEXT) \ test-nlist$(EXEEXT) update1$(EXEEXT) update2$(EXEEXT) \ update3$(EXEEXT) update4$(EXEEXT) run-show-die-info.sh \ @@ -151,14 +152,14 @@ TESTS = run-arextract.sh run-arsymtest.s run-backtrace-native-core-biarch.sh \ run-backtrace-core-x86_64.sh run-backtrace-core-i386.sh \ run-backtrace-core-ppc.sh run-backtrace-core-s390x.sh \ - run-backtrace-core-s390.sh $(am__EXEEXT_2) $(am__append_8) \ - $(am__EXEEXT_4) $(am__append_11) -@STANDALONE_FALSE@am__append_6 = msg_tst md5-sha1-test + run-backtrace-core-s390.sh $(am__EXEEXT_2) $(am__append_9) \ + $(am__EXEEXT_4) $(am__append_12) @STANDALONE_FALSE@am__append_7 = msg_tst md5-sha1-test -@LZMA_TRUE@am__append_8 = run-readelf-s.sh run-dwflsyms.sh -@HAVE_LIBASM_TRUE@am__append_9 = $(asm_TESTS) +@STANDALONE_FALSE@am__append_8 = msg_tst md5-sha1-test +@LZMA_TRUE@am__append_9 = run-readelf-s.sh run-dwflsyms.sh @HAVE_LIBASM_TRUE@am__append_10 = $(asm_TESTS) -@ENABLE_DWZ_TRUE@am__append_11 = run-readelf-dwz-multi.sh run-allfcts-multi.sh +@HAVE_LIBASM_TRUE@am__append_11 = $(asm_TESTS) +@ENABLE_DWZ_TRUE@am__append_12 = run-readelf-dwz-multi.sh run-allfcts-multi.sh subdir = tests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/biarch.m4 \ @@ -780,6 +781,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@ @@ -811,6 +813,7 @@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WEXTRA = @WEXTRA@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ @@ -870,12 +873,11 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ zip_LIBS = @zip_LIBS@ -AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. $(am__append_2) +AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. $(am__append_3) AM_CFLAGS = -std=gnu99 -Wall -Wshadow $(if \ - $($(*F)_no_Werror),,-Werror) $(if \ - $($(*F)_no_Wunused),,-Wunused -Wextra) $(if \ + $($(*F)_no_Wunused),,-Wunused $(WEXTRA)) $(if \ $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $($(*F)_CFLAGS) \ - $(am__append_1) + $(am__append_1) $(am__append_2) @MUDFLAP_FALSE@libmudflap = @MUDFLAP_TRUE@libmudflap = -lmudflap COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage $(no_mudflap.os),\ @@ -885,7 +887,7 @@ CLEANFILES = *.gcno *.gcda textrel_check = if $(READELF) -d $@ | fgrep -q TEXTREL; then exit 1; fi @MUDFLAP_FALSE@BUILD_RPATH = \$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../backends:\$$ORIGIN/../libelf @MUDFLAP_TRUE@BUILD_RPATH = \$$ORIGIN/../backends -AM_LDFLAGS = $(am__append_3) $(am__append_4) +AM_LDFLAGS = $(am__append_4) $(am__append_5) @TESTS_RPATH_FALSE@tests_rpath = no @TESTS_RPATH_TRUE@tests_rpath = yes asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \ debian/patches/CVE-2017-7613.patch0000664000000000000000000000330013107103200013221 0ustar From 4314716cd498bb51639db717bd7ce6182de33322 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 28 Mar 2017 01:25:34 +0200 Subject: [PATCH] elflint: Sanity check the number of phdrs and shdrs available. Make sure we can at least read the shnum sections or phnum segments. Limit the number we do check to those we can actually read. https://sourceware.org/bugzilla/show_bug.cgi?id=21312 Signed-off-by: Mark Wielaard Index: elfutils-0.158/src/elflint.c =================================================================== --- elfutils-0.158.orig/src/elflint.c +++ elfutils-0.158/src/elflint.c @@ -467,6 +467,19 @@ invalid number of section header table e ERROR (gettext ("invalid section header index\n")); } + /* Check the shdrs actually exist. */ + unsigned int scnt; + Elf_Scn *scn = NULL; + for (scnt = 1; scnt < shnum; ++scnt) + { + scn = elf_nextscn (ebl->elf, scn); + if (scn == NULL) + break; + } + if (scnt < shnum) + ERROR (gettext ("Can only check %u headers, shnum was %u\n"), scnt, shnum); + shnum = scnt; + phnum = ehdr->e_phnum; if (ehdr->e_phnum == PN_XNUM) { @@ -485,6 +498,19 @@ invalid number of program header table e } } + /* Check the phdrs actually exist. */ + unsigned int pcnt; + for (pcnt = 0; pcnt < phnum; ++pcnt) + { + GElf_Phdr phdr_mem; + GElf_Phdr *phdr = gelf_getphdr (ebl->elf, pcnt, &phdr_mem); + if (phdr == NULL) + break; + } + if (pcnt < phnum) + ERROR (gettext ("Can only check %u headers, phnum was %u\n"), pcnt, phnum); + phnum = pcnt; + /* Check the e_flags field. */ if (!ebl_machine_flag_check (ebl, ehdr->e_flags)) ERROR (gettext ("invalid machine flags: %s\n"), debian/patches/CVE-2014-0172.patch0000664000000000000000000000212212323276345013234 0ustar From 7f1eec317db79627b473c5b149a22a1b20d1f68f Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 9 Apr 2014 11:33:23 +0200 Subject: CVE-2014-0172 Check for overflow before calling malloc to uncompress data. https://bugzilla.redhat.com/show_bug.cgi?id=1085663 Reported-by: Florian Weimer Signed-off-by: Mark Wielaard Index: elfutils-0.157/libdw/dwarf_begin_elf.c =================================================================== --- elfutils-0.157.orig/libdw/dwarf_begin_elf.c 2014-04-15 13:55:24.218094637 -0400 +++ elfutils-0.157/libdw/dwarf_begin_elf.c 2014-04-15 13:55:24.210094637 -0400 @@ -289,6 +289,12 @@ memcpy (&size, data->d_buf + 4, sizeof size); size = be64toh (size); + /* Check for unsigned overflow so malloc always allocated + enough memory for both the Elf_Data header and the + uncompressed section data. */ + if (unlikely (sizeof (Elf_Data) + size < size)) + break; + Elf_Data *zdata = malloc (sizeof (Elf_Data) + size); if (unlikely (zdata == NULL)) break; debian/patches/scanf-format.patch0000664000000000000000000000321311722007577014227 0ustar From: Kurt Roeckx Subject: Use %m[ instead of %a[ in scanf() %a was a gnu extention, but C99 made this a float. So it got changed to %m (supported by glibc 2.7), but %a[ and %as are still supported by glibc. The portability branch changed this from %m to %a again since that's supported by more versions of glibc. However gcc gives a warning about this using -Wformat and we have a new enough libc to use %m. Index: elfutils-0.153/src/addr2line.c =================================================================== --- elfutils-0.153.orig/src/addr2line.c 2012-02-24 22:29:50.000000000 +0000 +++ elfutils-0.153/src/addr2line.c 2012-02-24 22:29:52.000000000 +0000 @@ -455,10 +455,10 @@ bool parsed = false; int i, j; char *name = NULL; - if (sscanf (string, "(%a[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2 + if (sscanf (string, "(%m[^)])%" PRIiMAX "%n", &name, &addr, &i) == 2 && string[i] == '\0') parsed = adjust_to_section (name, &addr, dwfl); - switch (sscanf (string, "%a[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j)) + switch (sscanf (string, "%m[^-+]%n%" PRIiMAX "%n", &name, &i, &addr, &j)) { default: break; Index: elfutils-0.153/tests/line2addr.c =================================================================== --- elfutils-0.153.orig/tests/line2addr.c 2012-02-24 22:29:50.000000000 +0000 +++ elfutils-0.153/tests/line2addr.c 2012-02-24 22:29:52.000000000 +0000 @@ -132,7 +132,7 @@ { struct args a = { .arg = argv[cnt] }; - switch (sscanf (a.arg, "%a[^:]:%d", &a.file, &a.line)) + switch (sscanf (a.arg, "%m[^:]:%d", &a.file, &a.line)) { default: case 0: debian/patches/arm_backend.diff0000664000000000000000000004415112262513277013713 0ustar Index: b/backends/arm_init.c =================================================================== --- a/backends/arm_init.c +++ b/backends/arm_init.c @@ -35,21 +35,32 @@ #define RELOC_PREFIX R_ARM_ #include "libebl_CPU.h" +#include "libebl_arm.h" + /* This defines the common reloc hooks based on arm_reloc.def. */ #include "common-reloc.c" const char * arm_init (elf, machine, eh, ehlen) - Elf *elf __attribute__ ((unused)); + Elf *elf; GElf_Half machine __attribute__ ((unused)); Ebl *eh; size_t ehlen; { + int soft_float = 0; + /* Check whether the Elf_BH object has a sufficent size. */ if (ehlen < sizeof (Ebl)) return NULL; + if (elf) { + GElf_Ehdr ehdr_mem; + GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem); + if (ehdr && (ehdr->e_flags & EF_ARM_SOFT_FLOAT)) + soft_float = 1; + } + /* We handle it. */ eh->name = "ARM"; arm_init_reloc (eh); @@ -61,7 +72,10 @@ HOOK (eh, core_note); HOOK (eh, auxv_info); HOOK (eh, check_object_attribute); - HOOK (eh, return_value_location); + if (soft_float) + eh->return_value_location = arm_return_value_location_soft; + else + eh->return_value_location = arm_return_value_location_hard; HOOK (eh, abi_cfi); return MODVERSION; Index: b/backends/arm_regs.c =================================================================== --- a/backends/arm_regs.c +++ b/backends/arm_regs.c @@ -31,6 +31,7 @@ #endif #include +#include #include #define BACKEND arm_ @@ -76,6 +77,9 @@ break; case 16 + 0 ... 16 + 7: + /* AADWARF says that there are no registers in that range, + * but gcc maps FPA registers here + */ regno += 96 - 16; /* Fall through. */ case 96 + 0 ... 96 + 7: @@ -87,11 +91,139 @@ namelen = 2; break; + case 64 + 0 ... 64 + 9: + *setname = "VFP"; + *bits = 32; + *type = DW_ATE_float; + name[0] = 's'; + name[1] = regno - 64 + '0'; + namelen = 2; + break; + + case 64 + 10 ... 64 + 31: + *setname = "VFP"; + *bits = 32; + *type = DW_ATE_float; + name[0] = 's'; + name[1] = (regno - 64) / 10 + '0'; + name[2] = (regno - 64) % 10 + '0'; + namelen = 3; + break; + + case 104 + 0 ... 104 + 7: + /* XXX TODO: + * This can be either intel wireless MMX general purpose/control + * registers or xscale accumulator, which have different usage. + * We only have the intel wireless MMX here now. + * The name needs to be changed for the xscale accumulator too. */ + *setname = "MMX"; + *type = DW_ATE_unsigned; + *bits = 32; + memcpy(name, "wcgr", 4); + name[4] = regno - 104 + '0'; + namelen = 5; + break; + + case 112 + 0 ... 112 + 9: + *setname = "MMX"; + *type = DW_ATE_unsigned; + *bits = 64; + name[0] = 'w'; + name[1] = 'r'; + name[2] = regno - 112 + '0'; + namelen = 3; + break; + + case 112 + 10 ... 112 + 15: + *setname = "MMX"; + *type = DW_ATE_unsigned; + *bits = 64; + name[0] = 'w'; + name[1] = 'r'; + name[2] = '1'; + name[3] = regno - 112 - 10 + '0'; + namelen = 4; + break; + case 128: + *setname = "state"; *type = DW_ATE_unsigned; return stpcpy (name, "spsr") + 1 - name; + case 129: + *setname = "state"; + *type = DW_ATE_unsigned; + return stpcpy(name, "spsr_fiq") + 1 - name; + + case 130: + *setname = "state"; + *type = DW_ATE_unsigned; + return stpcpy(name, "spsr_irq") + 1 - name; + + case 131: + *setname = "state"; + *type = DW_ATE_unsigned; + return stpcpy(name, "spsr_abt") + 1 - name; + + case 132: + *setname = "state"; + *type = DW_ATE_unsigned; + return stpcpy(name, "spsr_und") + 1 - name; + + case 133: + *setname = "state"; + *type = DW_ATE_unsigned; + return stpcpy(name, "spsr_svc") + 1 - name; + + case 144 ... 150: + *setname = "integer"; + *type = DW_ATE_signed; + *bits = 32; + return sprintf(name, "r%d_usr", regno - 144 + 8) + 1; + + case 151 ... 157: + *setname = "integer"; + *type = DW_ATE_signed; + *bits = 32; + return sprintf(name, "r%d_fiq", regno - 151 + 8) + 1; + + case 158 ... 159: + *setname = "integer"; + *type = DW_ATE_signed; + *bits = 32; + return sprintf(name, "r%d_irq", regno - 158 + 13) + 1; + + case 160 ... 161: + *setname = "integer"; + *type = DW_ATE_signed; + *bits = 32; + return sprintf(name, "r%d_abt", regno - 160 + 13) + 1; + + case 162 ... 163: + *setname = "integer"; + *type = DW_ATE_signed; + *bits = 32; + return sprintf(name, "r%d_und", regno - 162 + 13) + 1; + + case 164 ... 165: + *setname = "integer"; + *type = DW_ATE_signed; + *bits = 32; + return sprintf(name, "r%d_svc", regno - 164 + 13) + 1; + + case 192 ... 199: + *setname = "MMX"; + *bits = 32; + *type = DW_ATE_unsigned; + name[0] = 'w'; + name[1] = 'c'; + name[2] = regno - 192 + '0'; + namelen = 3; + break; + case 256 + 0 ... 256 + 9: + /* XXX TODO: Neon also uses those registers and can contain + * both float and integers */ *setname = "VFP"; *type = DW_ATE_float; *bits = 64; Index: b/backends/arm_retval.c =================================================================== --- a/backends/arm_retval.c +++ b/backends/arm_retval.c @@ -48,6 +48,13 @@ #define nloc_intreg 1 #define nloc_intregs(n) (2 * (n)) +/* f1 */ /* XXX TODO: f0 can also have number 96 if program was compiled with -mabi=aapcs */ +static const Dwarf_Op loc_fpreg[] = + { + { .atom = DW_OP_reg16 }, + }; +#define nloc_fpreg 1 + /* The return value is a structure and is actually stored in stack space passed in a hidden argument by the caller. But, the compiler helpfully returns the address of that space in r0. */ @@ -58,8 +65,9 @@ #define nloc_aggregate 1 -int -arm_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) +static int +arm_return_value_location_ (Dwarf_Die *functypedie, const Dwarf_Op **locp, + int soft_float) { /* Start with the function's type, and get the DW_AT_type attribute, which is the type of the return value. */ @@ -112,14 +120,31 @@ else return -1; } + if (tag == DW_TAG_base_type) + { + Dwarf_Word encoding; + if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding, + &attr_mem), &encoding) != 0) + return -1; + + if ((encoding == DW_ATE_float) && !soft_float) + { + *locp = loc_fpreg; + if (size <= 8) + return nloc_fpreg; + goto aggregate; + } + } if (size <= 16) { intreg: *locp = loc_intreg; return size <= 4 ? nloc_intreg : nloc_intregs ((size + 3) / 4); } + /* fall through. */ aggregate: + /* XXX TODO sometimes aggregates are returned in r0 (-mabi=aapcs) */ *locp = loc_aggregate; return nloc_aggregate; @@ -138,3 +163,18 @@ DWARF and might be valid. */ return -2; } + +/* return location for -mabi=apcs-gnu -msoft-float */ +int +arm_return_value_location_soft (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + return arm_return_value_location_ (functypedie, locp, 1); +} + +/* return location for -mabi=apcs-gnu -mhard-float (current default) */ +int +arm_return_value_location_hard (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + return arm_return_value_location_ (functypedie, locp, 0); +} + Index: b/libelf/elf.h =================================================================== --- a/libelf/elf.h +++ b/libelf/elf.h @@ -2318,6 +2318,9 @@ #define EF_ARM_EABI_VER4 0x04000000 #define EF_ARM_EABI_VER5 0x05000000 +/* EI_OSABI values */ +#define ELFOSABI_ARM_AEABI 64 /* Contains symbol versioning. */ + /* Additional symbol types for Thumb. */ #define STT_ARM_TFUNC STT_LOPROC /* A Thumb function. */ #define STT_ARM_16BIT STT_HIPROC /* A Thumb label. */ @@ -2335,12 +2338,19 @@ /* Processor specific values for the Phdr p_type field. */ #define PT_ARM_EXIDX (PT_LOPROC + 1) /* ARM unwind segment. */ +#define PT_ARM_UNWIND PT_ARM_EXIDX /* Processor specific values for the Shdr sh_type field. */ #define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */ #define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */ #define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */ +/* Processor specific values for the Dyn d_tag field. */ +#define DT_ARM_RESERVED1 (DT_LOPROC + 0) +#define DT_ARM_SYMTABSZ (DT_LOPROC + 1) +#define DT_ARM_PREEMTMAB (DT_LOPROC + 2) +#define DT_ARM_RESERVED2 (DT_LOPROC + 3) +#define DT_ARM_NUM 4 /* AArch64 relocs. */ @@ -2619,6 +2629,7 @@ TLS block (LDR, STR). */ #define R_ARM_TLS_IE12GP 111 /* 12 bit GOT entry relative to GOT origin (LDR). */ +/* 112 - 127 private range */ #define R_ARM_ME_TOO 128 /* Obsolete. */ #define R_ARM_THM_TLS_DESCSEQ 129 #define R_ARM_THM_TLS_DESCSEQ16 129 Index: b/backends/libebl_arm.h =================================================================== --- /dev/null +++ b/backends/libebl_arm.h @@ -0,0 +1,9 @@ +#ifndef _LIBEBL_ARM_H +#define _LIBEBL_ARM_H 1 + +#include + +extern int arm_return_value_location_soft(Dwarf_Die *, const Dwarf_Op **locp); +extern int arm_return_value_location_hard(Dwarf_Die *, const Dwarf_Op **locp); + +#endif Index: b/tests/run-allregs.sh =================================================================== --- a/tests/run-allregs.sh +++ b/tests/run-allregs.sh @@ -2671,7 +2671,28 @@ 13: sp (sp), address 32 bits 14: lr (lr), address 32 bits 15: pc (pc), address 32 bits - 128: spsr (spsr), unsigned 32 bits + 144: r8_usr (r8_usr), signed 32 bits + 145: r9_usr (r9_usr), signed 32 bits + 146: r10_usr (r10_usr), signed 32 bits + 147: r11_usr (r11_usr), signed 32 bits + 148: r12_usr (r12_usr), signed 32 bits + 149: r13_usr (r13_usr), signed 32 bits + 150: r14_usr (r14_usr), signed 32 bits + 151: r8_fiq (r8_fiq), signed 32 bits + 152: r9_fiq (r9_fiq), signed 32 bits + 153: r10_fiq (r10_fiq), signed 32 bits + 154: r11_fiq (r11_fiq), signed 32 bits + 155: r12_fiq (r12_fiq), signed 32 bits + 156: r13_fiq (r13_fiq), signed 32 bits + 157: r14_fiq (r14_fiq), signed 32 bits + 158: r13_irq (r13_irq), signed 32 bits + 159: r14_irq (r14_irq), signed 32 bits + 160: r13_abt (r13_abt), signed 32 bits + 161: r14_abt (r14_abt), signed 32 bits + 162: r13_und (r13_und), signed 32 bits + 163: r14_und (r14_und), signed 32 bits + 164: r13_svc (r13_svc), signed 32 bits + 165: r14_svc (r14_svc), signed 32 bits FPA registers: 16: f0 (f0), float 96 bits 17: f1 (f1), float 96 bits @@ -2689,7 +2710,72 @@ 101: f5 (f5), float 96 bits 102: f6 (f6), float 96 bits 103: f7 (f7), float 96 bits +MMX registers: + 104: wcgr0 (wcgr0), unsigned 32 bits + 105: wcgr1 (wcgr1), unsigned 32 bits + 106: wcgr2 (wcgr2), unsigned 32 bits + 107: wcgr3 (wcgr3), unsigned 32 bits + 108: wcgr4 (wcgr4), unsigned 32 bits + 109: wcgr5 (wcgr5), unsigned 32 bits + 110: wcgr6 (wcgr6), unsigned 32 bits + 111: wcgr7 (wcgr7), unsigned 32 bits + 112: wr0 (wr0), unsigned 64 bits + 113: wr1 (wr1), unsigned 64 bits + 114: wr2 (wr2), unsigned 64 bits + 115: wr3 (wr3), unsigned 64 bits + 116: wr4 (wr4), unsigned 64 bits + 117: wr5 (wr5), unsigned 64 bits + 118: wr6 (wr6), unsigned 64 bits + 119: wr7 (wr7), unsigned 64 bits + 120: wr8 (wr8), unsigned 64 bits + 121: wr9 (wr9), unsigned 64 bits + 122: wr10 (wr10), unsigned 64 bits + 123: wr11 (wr11), unsigned 64 bits + 124: wr12 (wr12), unsigned 64 bits + 125: wr13 (wr13), unsigned 64 bits + 126: wr14 (wr14), unsigned 64 bits + 127: wr15 (wr15), unsigned 64 bits + 192: wc0 (wc0), unsigned 32 bits + 193: wc1 (wc1), unsigned 32 bits + 194: wc2 (wc2), unsigned 32 bits + 195: wc3 (wc3), unsigned 32 bits + 196: wc4 (wc4), unsigned 32 bits + 197: wc5 (wc5), unsigned 32 bits + 198: wc6 (wc6), unsigned 32 bits + 199: wc7 (wc7), unsigned 32 bits VFP registers: + 64: s0 (s0), float 32 bits + 65: s1 (s1), float 32 bits + 66: s2 (s2), float 32 bits + 67: s3 (s3), float 32 bits + 68: s4 (s4), float 32 bits + 69: s5 (s5), float 32 bits + 70: s6 (s6), float 32 bits + 71: s7 (s7), float 32 bits + 72: s8 (s8), float 32 bits + 73: s9 (s9), float 32 bits + 74: s10 (s10), float 32 bits + 75: s11 (s11), float 32 bits + 76: s12 (s12), float 32 bits + 77: s13 (s13), float 32 bits + 78: s14 (s14), float 32 bits + 79: s15 (s15), float 32 bits + 80: s16 (s16), float 32 bits + 81: s17 (s17), float 32 bits + 82: s18 (s18), float 32 bits + 83: s19 (s19), float 32 bits + 84: s20 (s20), float 32 bits + 85: s21 (s21), float 32 bits + 86: s22 (s22), float 32 bits + 87: s23 (s23), float 32 bits + 88: s24 (s24), float 32 bits + 89: s25 (s25), float 32 bits + 90: s26 (s26), float 32 bits + 91: s27 (s27), float 32 bits + 92: s28 (s28), float 32 bits + 93: s29 (s29), float 32 bits + 94: s30 (s30), float 32 bits + 95: s31 (s31), float 32 bits 256: d0 (d0), float 64 bits 257: d1 (d1), float 64 bits 258: d2 (d2), float 64 bits @@ -2722,6 +2808,13 @@ 285: d29 (d29), float 64 bits 286: d30 (d30), float 64 bits 287: d31 (d31), float 64 bits +state registers: + 128: spsr (spsr), unsigned 32 bits + 129: spsr_fiq (spsr_fiq), unsigned 32 bits + 130: spsr_irq (spsr_irq), unsigned 32 bits + 131: spsr_abt (spsr_abt), unsigned 32 bits + 132: spsr_und (spsr_und), unsigned 32 bits + 133: spsr_svc (spsr_svc), unsigned 32 bits EOF # See run-readelf-mixed-corenote.sh for instructions to regenerate Index: b/tests/run-readelf-mixed-corenote.sh =================================================================== --- a/tests/run-readelf-mixed-corenote.sh +++ b/tests/run-readelf-mixed-corenote.sh @@ -30,12 +30,11 @@ pid: 11087, ppid: 11063, pgrp: 11087, sid: 11063 utime: 0.000000, stime: 0.010000, cutime: 0.000000, cstime: 0.000000 orig_r0: -1, fpvalid: 1 - r0: 1 r1: -1091672508 r2: -1091672500 - r3: 0 r4: 0 r5: 0 - r6: 33728 r7: 0 r8: 0 - r9: 0 r10: -1225703496 r11: -1091672844 - r12: 0 sp: 0xbeee64f4 lr: 0xb6dc3f48 - pc: 0x00008500 spsr: 0x60000010 + r0: 1 r1: -1091672508 r2: -1091672500 r3: 0 + r4: 0 r5: 0 r6: 33728 r7: 0 + r8: 0 r9: 0 r10: -1225703496 r11: -1091672844 + r12: 0 sp: 0xbeee64f4 lr: 0xb6dc3f48 pc: 0x00008500 + spsr: 0x60000010 CORE 124 PRPSINFO state: 0, sname: R, zomb: 0, nice: 0, flag: 0x00400500 uid: 0, gid: 0, pid: 11087, ppid: 11063, pgrp: 11087, sid: 11063 Index: b/tests/run-addrcfi.sh =================================================================== --- a/tests/run-addrcfi.sh +++ b/tests/run-addrcfi.sh @@ -2530,6 +2530,38 @@ FPA reg21 (f5): undefined FPA reg22 (f6): undefined FPA reg23 (f7): undefined + VFP reg64 (s0): undefined + VFP reg65 (s1): undefined + VFP reg66 (s2): undefined + VFP reg67 (s3): undefined + VFP reg68 (s4): undefined + VFP reg69 (s5): undefined + VFP reg70 (s6): undefined + VFP reg71 (s7): undefined + VFP reg72 (s8): undefined + VFP reg73 (s9): undefined + VFP reg74 (s10): undefined + VFP reg75 (s11): undefined + VFP reg76 (s12): undefined + VFP reg77 (s13): undefined + VFP reg78 (s14): undefined + VFP reg79 (s15): undefined + VFP reg80 (s16): undefined + VFP reg81 (s17): undefined + VFP reg82 (s18): undefined + VFP reg83 (s19): undefined + VFP reg84 (s20): undefined + VFP reg85 (s21): undefined + VFP reg86 (s22): undefined + VFP reg87 (s23): undefined + VFP reg88 (s24): undefined + VFP reg89 (s25): undefined + VFP reg90 (s26): undefined + VFP reg91 (s27): undefined + VFP reg92 (s28): undefined + VFP reg93 (s29): undefined + VFP reg94 (s30): undefined + VFP reg95 (s31): undefined FPA reg96 (f0): undefined FPA reg97 (f1): undefined FPA reg98 (f2): undefined @@ -2538,7 +2570,66 @@ FPA reg101 (f5): undefined FPA reg102 (f6): undefined FPA reg103 (f7): undefined - integer reg128 (spsr): undefined + MMX reg104 (wcgr0): undefined + MMX reg105 (wcgr1): undefined + MMX reg106 (wcgr2): undefined + MMX reg107 (wcgr3): undefined + MMX reg108 (wcgr4): undefined + MMX reg109 (wcgr5): undefined + MMX reg110 (wcgr6): undefined + MMX reg111 (wcgr7): undefined + MMX reg112 (wr0): undefined + MMX reg113 (wr1): undefined + MMX reg114 (wr2): undefined + MMX reg115 (wr3): undefined + MMX reg116 (wr4): undefined + MMX reg117 (wr5): undefined + MMX reg118 (wr6): undefined + MMX reg119 (wr7): undefined + MMX reg120 (wr8): undefined + MMX reg121 (wr9): undefined + MMX reg122 (wr10): undefined + MMX reg123 (wr11): undefined + MMX reg124 (wr12): undefined + MMX reg125 (wr13): undefined + MMX reg126 (wr14): undefined + MMX reg127 (wr15): undefined + state reg128 (spsr): undefined + state reg129 (spsr_fiq): undefined + state reg130 (spsr_irq): undefined + state reg131 (spsr_abt): undefined + state reg132 (spsr_und): undefined + state reg133 (spsr_svc): undefined + integer reg144 (r8_usr): undefined + integer reg145 (r9_usr): undefined + integer reg146 (r10_usr): undefined + integer reg147 (r11_usr): undefined + integer reg148 (r12_usr): undefined + integer reg149 (r13_usr): undefined + integer reg150 (r14_usr): undefined + integer reg151 (r8_fiq): undefined + integer reg152 (r9_fiq): undefined + integer reg153 (r10_fiq): undefined + integer reg154 (r11_fiq): undefined + integer reg155 (r12_fiq): undefined + integer reg156 (r13_fiq): undefined + integer reg157 (r14_fiq): undefined + integer reg158 (r13_irq): undefined + integer reg159 (r14_irq): undefined + integer reg160 (r13_abt): undefined + integer reg161 (r14_abt): undefined + integer reg162 (r13_und): undefined + integer reg163 (r14_und): undefined + integer reg164 (r13_svc): undefined + integer reg165 (r14_svc): undefined + MMX reg192 (wc0): undefined + MMX reg193 (wc1): undefined + MMX reg194 (wc2): undefined + MMX reg195 (wc3): undefined + MMX reg196 (wc4): undefined + MMX reg197 (wc5): undefined + MMX reg198 (wc6): undefined + MMX reg199 (wc7): undefined VFP reg256 (d0): undefined VFP reg257 (d1): undefined VFP reg258 (d2): undefined debian/patches/CVE-2017-7607-2.patch0000664000000000000000000000171713107076403013413 0ustar From 9d84fdd78705d7a1b9947a9f4ca77fbccdd76d4a Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 24 Mar 2017 12:15:02 +0100 Subject: [PATCH] readelf: Fix off by one sanity check in handle_gnu_hash. We sanity check to make sure we don't index outside the chain array by testing inner > max_nsyms. But inner is a zero-based index, while max_nsyms is the maximum number. Change the check to inner >= max_nsyms. https://sourceware.org/bugzilla/show_bug.cgi?id=21299 Signed-off-by: Mark Wielaard Index: elfutils-0.158/src/readelf.c =================================================================== --- elfutils-0.158.orig/src/readelf.c +++ elfutils-0.158/src/readelf.c @@ -3068,7 +3068,7 @@ handle_gnu_hash (Ebl *ebl, Elf_Scn *scn, ++nsyms; if (maxlength < ++lengths[cnt]) ++maxlength; - if (inner > max_nsyms) + if (inner >= max_nsyms) goto invalid_data; } while ((chain[inner++] & 1) == 0); debian/patches/mips_backend.diff0000664000000000000000000005634212262513521014101 0ustar Index: elfutils-0.155/backends/mips_init.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ elfutils-0.155/backends/mips_init.c 2013-07-06 21:45:45.000000000 +0200 @@ -0,0 +1,60 @@ +/* Initialization of mips specific backend library. + Copyright (C) 2006 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#define BACKEND mips_ +#define RELOC_PREFIX R_MIPS_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on mips_reloc.def. */ +#include "common-reloc.c" + +const char * +mips_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + if (machine == EM_MIPS) + eh->name = "MIPS R3000 big-endian"; + else if (machine == EM_MIPS_RS3_LE) + eh->name = "MIPS R3000 little-endian"; + + mips_init_reloc (eh); + HOOK (eh, reloc_simple_type); + HOOK (eh, return_value_location); + HOOK (eh, register_info); + + return MODVERSION; +} Index: elfutils-0.155/backends/mips_regs.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ elfutils-0.155/backends/mips_regs.c 2013-07-06 21:45:45.000000000 +0200 @@ -0,0 +1,104 @@ +/* Register names and numbers for MIPS DWARF. + Copyright (C) 2006 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#define BACKEND mips_ +#include "libebl_CPU.h" + +ssize_t +mips_register_info (Ebl *ebl __attribute__((unused)), + int regno, char *name, size_t namelen, + const char **prefix, const char **setname, + int *bits, int *type) +{ + if (name == NULL) + return 66; + + if (regno < 0 || regno > 65 || namelen < 4) + return -1; + + *prefix = "$"; + + if (regno < 32) + { + *setname = "integer"; + *type = DW_ATE_signed; + *bits = 32; + if (regno < 32 + 10) + { + name[0] = regno + '0'; + namelen = 1; + } + else + { + name[0] = (regno / 10) + '0'; + name[1] = (regno % 10) + '0'; + namelen = 2; + } + } + else if (regno < 64) + { + *setname = "FPU"; + *type = DW_ATE_float; + *bits = 32; + name[0] = 'f'; + if (regno < 32 + 10) + { + name[1] = (regno - 32) + '0'; + namelen = 2; + } + else + { + name[1] = (regno - 32) / 10 + '0'; + name[2] = (regno - 32) % 10 + '0'; + namelen = 3; + } + } + else if (regno == 64) + { + *type = DW_ATE_signed; + *bits = 32; + name[0] = 'h'; + name[1] = 'i'; + namelen = 2; + } + else + { + *type = DW_ATE_signed; + *bits = 32; + name[0] = 'l'; + name[1] = 'o'; + namelen = 2; + } + + name[namelen++] = '\0'; + return namelen; +} Index: elfutils-0.155/backends/mips_reloc.def =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ elfutils-0.155/backends/mips_reloc.def 2013-07-06 21:45:45.000000000 +0200 @@ -0,0 +1,79 @@ +/* List the relocation types for mips. -*- C -*- + Copyright (C) 2006 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, 0) +RELOC_TYPE (16, 0) +RELOC_TYPE (32, 0) +RELOC_TYPE (REL32, 0) +RELOC_TYPE (26, 0) +RELOC_TYPE (HI16, 0) +RELOC_TYPE (LO16, 0) +RELOC_TYPE (GPREL16, 0) +RELOC_TYPE (LITERAL, 0) +RELOC_TYPE (GOT16, 0) +RELOC_TYPE (PC16, 0) +RELOC_TYPE (CALL16, 0) +RELOC_TYPE (GPREL32, 0) + +RELOC_TYPE (SHIFT5, 0) +RELOC_TYPE (SHIFT6, 0) +RELOC_TYPE (64, 0) +RELOC_TYPE (GOT_DISP, 0) +RELOC_TYPE (GOT_PAGE, 0) +RELOC_TYPE (GOT_OFST, 0) +RELOC_TYPE (GOT_HI16, 0) +RELOC_TYPE (GOT_LO16, 0) +RELOC_TYPE (SUB, 0) +RELOC_TYPE (INSERT_A, 0) +RELOC_TYPE (INSERT_B, 0) +RELOC_TYPE (DELETE, 0) +RELOC_TYPE (HIGHER, 0) +RELOC_TYPE (HIGHEST, 0) +RELOC_TYPE (CALL_HI16, 0) +RELOC_TYPE (CALL_LO16, 0) +RELOC_TYPE (SCN_DISP, 0) +RELOC_TYPE (REL16, 0) +RELOC_TYPE (ADD_IMMEDIATE, 0) +RELOC_TYPE (PJUMP, 0) +RELOC_TYPE (RELGOT, 0) +RELOC_TYPE (JALR, 0) +RELOC_TYPE (TLS_DTPMOD32, 0) +RELOC_TYPE (TLS_DTPREL32, 0) +RELOC_TYPE (TLS_DTPMOD64, 0) +RELOC_TYPE (TLS_DTPREL64, 0) +RELOC_TYPE (TLS_GD, 0) +RELOC_TYPE (TLS_LDM, 0) +RELOC_TYPE (TLS_DTPREL_HI16, 0) +RELOC_TYPE (TLS_DTPREL_LO16, 0) +RELOC_TYPE (TLS_GOTTPREL, 0) +RELOC_TYPE (TLS_TPREL32, 0) +RELOC_TYPE (TLS_TPREL64, 0) +RELOC_TYPE (TLS_TPREL_HI16, 0) +RELOC_TYPE (TLS_TPREL_LO16, 0) + +#define NO_COPY_RELOC 1 +#define NO_RELATIVE_RELOC 1 Index: elfutils-0.155/backends/mips_retval.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ elfutils-0.155/backends/mips_retval.c 2013-07-06 21:45:45.000000000 +0200 @@ -0,0 +1,321 @@ +/* Function return value location for Linux/mips ABI. + Copyright (C) 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include + +#include "../libebl/libeblP.h" +#include "../libdw/libdwP.h" + +#define BACKEND mips_ +#include "libebl_CPU.h" + +/* The ABI of the file. Also see EF_MIPS_ABI2 above. */ +#define EF_MIPS_ABI 0x0000F000 + +/* The original o32 abi. */ +#define E_MIPS_ABI_O32 0x00001000 + +/* O32 extended to work on 64 bit architectures */ +#define E_MIPS_ABI_O64 0x00002000 + +/* EABI in 32 bit mode */ +#define E_MIPS_ABI_EABI32 0x00003000 + +/* EABI in 64 bit mode */ +#define E_MIPS_ABI_EABI64 0x00004000 + +/* All the possible MIPS ABIs. */ +enum mips_abi + { + MIPS_ABI_UNKNOWN = 0, + MIPS_ABI_N32, + MIPS_ABI_O32, + MIPS_ABI_N64, + MIPS_ABI_O64, + MIPS_ABI_EABI32, + MIPS_ABI_EABI64, + MIPS_ABI_LAST + }; + +/* Find the mips ABI of the current file */ +enum mips_abi find_mips_abi(Elf *elf) +{ + GElf_Ehdr ehdr_mem; + GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem); + + if (ehdr == NULL) + return MIPS_ABI_LAST; + + GElf_Word elf_flags = ehdr->e_flags; + + /* Check elf_flags to see if it specifies the ABI being used. */ + switch ((elf_flags & EF_MIPS_ABI)) + { + case E_MIPS_ABI_O32: + return MIPS_ABI_O32; + case E_MIPS_ABI_O64: + return MIPS_ABI_O64; + case E_MIPS_ABI_EABI32: + return MIPS_ABI_EABI32; + case E_MIPS_ABI_EABI64: + return MIPS_ABI_EABI64; + default: + if ((elf_flags & EF_MIPS_ABI2)) + return MIPS_ABI_N32; + } + + /* GCC creates a pseudo-section whose name describes the ABI. */ + size_t shstrndx; + if (elf_getshdrstrndx (elf, &shstrndx) < 0) + return MIPS_ABI_LAST; + + const char *name; + Elf_Scn *scn = NULL; + while ((scn = elf_nextscn (elf, scn)) != NULL) + { + GElf_Shdr shdr_mem; + GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); + if (shdr == NULL) + return MIPS_ABI_LAST; + + name = elf_strptr (elf, shstrndx, shdr->sh_name) ?: ""; + if (strncmp (name, ".mdebug.", 8) != 0) + continue; + + if (strcmp (name, ".mdebug.abi32") == 0) + return MIPS_ABI_O32; + else if (strcmp (name, ".mdebug.abiN32") == 0) + return MIPS_ABI_N32; + else if (strcmp (name, ".mdebug.abi64") == 0) + return MIPS_ABI_N64; + else if (strcmp (name, ".mdebug.abiO64") == 0) + return MIPS_ABI_O64; + else if (strcmp (name, ".mdebug.eabi32") == 0) + return MIPS_ABI_EABI32; + else if (strcmp (name, ".mdebug.eabi64") == 0) + return MIPS_ABI_EABI64; + else + return MIPS_ABI_UNKNOWN; + } + + return MIPS_ABI_UNKNOWN; +} + +unsigned int +mips_abi_regsize (enum mips_abi abi) +{ + switch (abi) + { + case MIPS_ABI_EABI32: + case MIPS_ABI_O32: + return 4; + case MIPS_ABI_N32: + case MIPS_ABI_N64: + case MIPS_ABI_O64: + case MIPS_ABI_EABI64: + return 8; + case MIPS_ABI_UNKNOWN: + case MIPS_ABI_LAST: + default: + return 0; + } +} + + +/* $v0 or pair $v0, $v1 */ +static const Dwarf_Op loc_intreg_o32[] = + { + { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 4 }, + { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 4 }, + }; + +static const Dwarf_Op loc_intreg[] = + { + { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 8 }, + { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 8 }, + }; +#define nloc_intreg 1 +#define nloc_intregpair 4 + +/* $f0 (float), or pair $f0, $f1 (double). + * f2/f3 are used for COMPLEX (= 2 doubles) returns in Fortran */ +static const Dwarf_Op loc_fpreg_o32[] = + { + { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 4 }, + { .atom = DW_OP_regx, .number = 33 }, { .atom = DW_OP_piece, .number = 4 }, + { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 4 }, + { .atom = DW_OP_regx, .number = 35 }, { .atom = DW_OP_piece, .number = 4 }, + }; + +/* $f0, or pair $f0, $f2. */ +static const Dwarf_Op loc_fpreg[] = + { + { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 8 }, + { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 8 }, + }; +#define nloc_fpreg 1 +#define nloc_fpregpair 4 +#define nloc_fpregquad 8 + +/* The return value is a structure and is actually stored in stack space + passed in a hidden argument by the caller. But, the compiler + helpfully returns the address of that space in $v0. */ +static const Dwarf_Op loc_aggregate[] = + { + { .atom = DW_OP_breg2, .number = 0 } + }; +#define nloc_aggregate 1 + +int +mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + /* First find the ABI used by the elf object */ + enum mips_abi abi = find_mips_abi(functypedie->cu->dbg->elf); + + /* Something went seriously wrong while trying to figure out the ABI */ + if (abi == MIPS_ABI_LAST) + return -1; + + /* We couldn't identify the ABI, but the file seems valid */ + if (abi == MIPS_ABI_UNKNOWN) + return -2; + + /* Can't handle EABI variants */ + if ((abi == MIPS_ABI_EABI32) || (abi == MIPS_ABI_EABI64)) + return -2; + + unsigned int regsize = mips_abi_regsize (abi); + if (!regsize) + return -2; + + /* Start with the function's type, and get the DW_AT_type attribute, + which is the type of the return value. */ + + Dwarf_Attribute attr_mem; + Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, &attr_mem); + if (attr == NULL) + /* The function has no return value, like a `void' function in C. */ + return 0; + + Dwarf_Die die_mem; + Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem); + int tag = dwarf_tag (typedie); + + /* Follow typedefs and qualifiers to get to the actual type. */ + while (tag == DW_TAG_typedef + || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type + || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type) + { + attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + + switch (tag) + { + case -1: + return -1; + + case DW_TAG_subrange_type: + if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size)) + { + attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + /* Fall through. */ + + case DW_TAG_base_type: + case DW_TAG_enumeration_type: + case DW_TAG_pointer_type: + case DW_TAG_ptr_to_member_type: + { + Dwarf_Word size; + if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, + &attr_mem), &size) != 0) + { + if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + size = regsize; + else + return -1; + } + if (tag == DW_TAG_base_type) + { + Dwarf_Word encoding; + if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding, + &attr_mem), &encoding) != 0) + return -1; + +#define ABI_LOC(loc, regsize) ((regsize) == 4 ? (loc ## _o32) : (loc)) + + if (encoding == DW_ATE_float) + { + *locp = ABI_LOC(loc_fpreg, regsize); + if (size <= regsize) + return nloc_fpreg; + + if (size <= 2*regsize) + return nloc_fpregpair; + + if (size <= 4*regsize && abi == MIPS_ABI_O32) + return nloc_fpregquad; + + goto aggregate; + } + } + *locp = ABI_LOC(loc_intreg, regsize); + if (size <= regsize) + return nloc_intreg; + if (size <= 2*regsize) + return nloc_intregpair; + + /* Else fall through. Shouldn't happen though (at least with gcc) */ + } + + case DW_TAG_structure_type: + case DW_TAG_class_type: + case DW_TAG_union_type: + case DW_TAG_array_type: + aggregate: + /* XXX TODO: Can't handle structure return with other ABI's yet :-/ */ + if ((abi != MIPS_ABI_O32) && (abi != MIPS_ABI_O64)) + return -2; + + *locp = loc_aggregate; + return nloc_aggregate; + } + + /* XXX We don't have a good way to return specific errors from ebl calls. + This value means we do not understand the type, but it is well-formed + DWARF and might be valid. */ + return -2; +} Index: elfutils-0.155/backends/mips_symbol.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ elfutils-0.155/backends/mips_symbol.c 2013-07-06 21:45:45.000000000 +0200 @@ -0,0 +1,52 @@ +/* MIPS specific symbolic name handling. + Copyright (C) 2002, 2003, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Jakub Jelinek , 2002. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#define BACKEND mips_ +#include "libebl_CPU.h" + +/* Check for the simple reloc types. */ +Elf_Type +mips_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_MIPS_16: + return ELF_T_HALF; + case R_MIPS_32: + return ELF_T_WORD; + case R_MIPS_64: + return ELF_T_XWORD; + default: + return ELF_T_NUM; + } +} Index: elfutils-0.155/libebl/eblopenbackend.c =================================================================== --- elfutils-0.155.orig/libebl/eblopenbackend.c 2013-07-06 21:45:45.000000000 +0200 +++ elfutils-0.155/libebl/eblopenbackend.c 2013-07-06 21:45:45.000000000 +0200 @@ -71,6 +71,8 @@ { "sparc", "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 }, { "sparc", "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 }, { "s390", "ebl_s390", "s390", 4, EM_S390, 0, 0 }, + { "mips", "elf_mips", "mips", 4, EM_MIPS, 0, 0 }, + { "mips", "elf_mipsel", "mipsel", 4, EM_MIPS_RS3_LE, 0, 0 }, { "m32", "elf_m32", "m32", 3, EM_M32, 0, 0 }, { "m68k", "elf_m68k", "m68k", 4, EM_68K, 0, 0 }, Index: elfutils-0.155/backends/common-reloc.c =================================================================== --- elfutils-0.155.orig/backends/common-reloc.c 2013-07-06 21:45:45.000000000 +0200 +++ elfutils-0.155/backends/common-reloc.c 2013-07-06 21:45:45.000000000 +0200 @@ -112,11 +112,13 @@ } +#ifndef NO_COPY_RELOC bool EBLHOOK(copy_reloc_p) (int reloc) { return reloc == R_TYPE (COPY); } +#endif bool EBLHOOK(none_reloc_p) (int reloc) @@ -138,7 +140,9 @@ ebl->reloc_type_name = EBLHOOK(reloc_type_name); ebl->reloc_type_check = EBLHOOK(reloc_type_check); ebl->reloc_valid_use = EBLHOOK(reloc_valid_use); +#ifndef NO_COPY_RELOC ebl->copy_reloc_p = EBLHOOK(copy_reloc_p); +#endif ebl->none_reloc_p = EBLHOOK(none_reloc_p); #ifndef NO_RELATIVE_RELOC ebl->relative_reloc_p = EBLHOOK(relative_reloc_p); Index: elfutils-0.155/backends/Makefile.am =================================================================== --- elfutils-0.155.orig/backends/Makefile.am 2013-07-06 21:45:45.000000000 +0200 +++ elfutils-0.155/backends/Makefile.am 2013-07-06 21:46:37.000000000 +0200 @@ -33,11 +33,11 @@ modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \ - tilegx parisc + tilegx parisc mips libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \ libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \ libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \ - libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a libebl_parisc_pic.a + libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a libebl_parisc_pic.a libebl_mips_pic.a noinst_LIBRARIES = $(libebl_pic) noinst_DATA = $(libebl_pic:_pic.a=.so) @@ -107,6 +108,10 @@ libebl_parisc_pic_a_SOURCES = $(parisc_SRCS) am_libebl_parisc_pic_a_OBJECTS = $(parisc_SRCS:.c=.os) +mips_SRCS = mips_init.c mips_symbol.c mips_regs.c mips_retval.c +libebl_mips_pic_a_SOURCES = $(mips_SRCS) +am_libebl_mips_pic_a_OBJECTS = $(mips_SRCS:.c=.os) + libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw) @rm -f $(@:.so=.map) echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \ debian/patches/CVE-2016-10255.patch0000664000000000000000000000246613107073322013323 0ustar From 09ec02ec7f7e6913d10943148e2a898264345b07 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 21 Oct 2016 15:24:34 +0200 Subject: [PATCH] libelf: Sanity check offset and size before trying to malloc and read data. Bad sh_off or sh_size could trigger a bad malloc or read. Sanity check the header values first before trying to malloc a huge buffer or reading any data that will certainly fail. https://bugzilla.redhat.com/show_bug.cgi?id=1387584 Signed-off-by: Mark Wielaard Index: elfutils-0.158/libelf/elf_getdata.c =================================================================== --- elfutils-0.158.orig/libelf/elf_getdata.c +++ elfutils-0.158/libelf/elf_getdata.c @@ -256,6 +256,17 @@ __libelf_set_rawdata_wrlock (Elf_Scn *sc } else if (likely (elf->fildes != -1)) { + /* First see whether the information in the section header is + valid and it does not ask for too much. Check for unsigned + overflow. */ + if (unlikely (offset > elf->maximum_size + || elf->maximum_size - offset < size)) + { + /* Something is wrong. */ + __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); + return 1; + } + /* We have to read the data from the file. Allocate the needed memory. */ scn->rawdata_base = scn->rawdata.d.d_buf debian/patches/mips_readelf_w.patch0000664000000000000000000000146512026150552014624 0ustar From: Kurt Roeckx Subject: Make readelf -w output debug information on mips Bug-Debian: http://bugs.debian.org/662041 Forwarded: not-needed Upstreams wants a change where this is handled by a hook that needs to be filled in by the backend for the arch. Index: elfutils-0.153/src/readelf.c =================================================================== --- elfutils-0.153.orig/src/readelf.c 2012-08-10 22:01:55.000000000 +0200 +++ elfutils-0.153/src/readelf.c 2012-09-18 21:46:27.000000000 +0200 @@ -7364,7 +7364,8 @@ GElf_Shdr shdr_mem; GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); - if (shdr != NULL && shdr->sh_type == SHT_PROGBITS) + if (shdr != NULL && ( + (shdr->sh_type == SHT_PROGBITS) || (shdr->sh_type == SHT_MIPS_DWARF))) { static const struct { debian/patches/CVE-2016-10254.patch0000664000000000000000000000433613107140016013313 0ustar From 191000fdedba3fafe4d5b8cddad3f3318b49c3fb Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 26 Oct 2016 13:08:52 +0200 Subject: [PATCH] libelf: Always set ELF maxsize when reading an ELF file for sanity checks. There are various sanity checks that depend on knowing the file size of the underlying ELF file which we only used when mmapping the ELF file. Although we probably won't crash if we use pread to try to read from the file, we still might return completely bogus data structures. This could cause us to malloc insane amounts of memory. Always try to get the maxsize when unknown in elf_begin.c (read_file). https://bugzilla.redhat.com/show_bug.cgi?id=1388057 Signed-off-by: Mark Wielaard Index: elfutils-0.158/libelf/elf_begin.c =================================================================== --- elfutils-0.158.orig/libelf/elf_begin.c +++ elfutils-0.158/libelf/elf_begin.c @@ -596,22 +596,30 @@ read_file (int fildes, off_t offset, siz use_mmap = 0; #endif - if (use_mmap) + if (parent == NULL) { - if (parent == NULL) + if (maxsize == ~((size_t) 0)) { - if (maxsize == ~((size_t) 0)) - { - /* We don't know in the moment how large the file is. - Determine it now. */ - struct stat st; + /* We don't know in the moment how large the file is. + Determine it now. */ + struct stat st; - if (fstat (fildes, &st) == 0 - && (sizeof (size_t) >= sizeof (st.st_size) - || st.st_size <= ~((size_t) 0))) - maxsize = (size_t) st.st_size; - } + if (fstat (fildes, &st) == 0 + && (sizeof (size_t) >= sizeof (st.st_size) + || st.st_size <= ~((size_t) 0))) + maxsize = (size_t) st.st_size; + } + } + else + { + /* The parent is already loaded. Use it. */ + assert (maxsize != ~((size_t) 0)); + } + if (use_mmap) + { + if (parent == NULL) + { /* We try to map the file ourself. */ map_address = mmap (NULL, maxsize, (cmd == ELF_C_READ_MMAP ? PROT_READ @@ -626,9 +634,6 @@ read_file (int fildes, off_t offset, siz } else { - /* The parent is already loaded. Use it. */ - assert (maxsize != ~((size_t) 0)); - map_address = parent->map_address; } } debian/patches/m68k_backend.diff0000664000000000000000000003465312262513635013725 0ustar From: Kurt Roeckx From: Thorsten Glaser Subject: m68k support Written by Kurt Roeckx, except for the retval support which was written by Thorsten Glaser Index: b/backends/m68k_init.c =================================================================== --- /dev/null +++ b/backends/m68k_init.c @@ -0,0 +1,50 @@ +/* Initialization of m68k specific backend library. + Copyright (C) 2007 Kurt Roeckx + + This software is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + This softare is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this software; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + +*/ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#define BACKEND m68k_ +#define RELOC_PREFIX R_68K_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on m68k_reloc.def. */ +#include "common-reloc.c" + + +const char * +m68k_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + eh->name = "m68k"; + m68k_init_reloc (eh); + HOOK (eh, reloc_simple_type); + HOOK (eh, return_value_location); + HOOK (eh, register_info); + + return MODVERSION; +} Index: b/backends/m68k_regs.c =================================================================== --- /dev/null +++ b/backends/m68k_regs.c @@ -0,0 +1,106 @@ +/* Register names and numbers for m68k DWARF. + Copyright (C) 2007 Kurt Roeckx + + This software is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + This software is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this software; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#define BACKEND m68k_ +#include "libebl_CPU.h" + +ssize_t +m68k_register_info (Ebl *ebl __attribute__ ((unused)), + int regno, char *name, size_t namelen, + const char **prefix, const char **setname, + int *bits, int *type) +{ + if (name == NULL) + return 25; + + if (regno < 0 || regno > 24 || namelen < 5) + return -1; + + *prefix = "%"; + *bits = 32; + *type = (regno < 8 ? DW_ATE_signed + : regno < 16 ? DW_ATE_address : DW_ATE_float); + + if (regno < 8) + { + *setname = "integer"; + } + else if (regno < 16) + { + *setname = "address"; + } + else if (regno < 24) + { + *setname = "FPU"; + } + else + { + *setname = "address"; + *type = DW_ATE_address; + } + + switch (regno) + { + case 0 ... 7: + name[0] = 'd'; + name[1] = regno + '0'; + namelen = 2; + break; + + case 8 ... 13: + name[0] = 'a'; + name[1] = regno - 8 + '0'; + namelen = 2; + break; + + case 14: + name[0] = 'f'; + name[1] = 'p'; + namelen = 2; + break; + + case 15: + name[0] = 's'; + name[1] = 'p'; + namelen = 2; + break; + + case 16 ... 23: + name[0] = 'f'; + name[1] = 'p'; + name[2] = regno - 16 + '0'; + namelen = 3; + break; + + case 24: + name[0] = 'p'; + name[1] = 'c'; + namelen = 2; + } + + name[namelen++] = '\0'; + return namelen; +} + Index: b/backends/m68k_reloc.def =================================================================== --- /dev/null +++ b/backends/m68k_reloc.def @@ -0,0 +1,45 @@ +/* List the relocation types for m68k. -*- C -*- + Copyright (C) 2007 Kurt Roeckx + + This software is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + This software is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this software; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. +*/ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, 0) +RELOC_TYPE (32, REL|EXEC|DYN) +RELOC_TYPE (16, REL) +RELOC_TYPE (8, REL) +RELOC_TYPE (PC32, REL|EXEC|DYN) +RELOC_TYPE (PC16, REL) +RELOC_TYPE (PC8, REL) +RELOC_TYPE (GOT32, REL) +RELOC_TYPE (GOT16, REL) +RELOC_TYPE (GOT8, REL) +RELOC_TYPE (GOT32O, REL) +RELOC_TYPE (GOT16O, REL) +RELOC_TYPE (GOT8O, REL) +RELOC_TYPE (PLT32, REL) +RELOC_TYPE (PLT16, REL) +RELOC_TYPE (PLT8, REL) +RELOC_TYPE (PLT32O, REL) +RELOC_TYPE (PLT16O, REL) +RELOC_TYPE (PLT8O, REL) +RELOC_TYPE (COPY, EXEC) +RELOC_TYPE (GLOB_DAT, EXEC|DYN) +RELOC_TYPE (JMP_SLOT, EXEC|DYN) +RELOC_TYPE (RELATIVE, EXEC|DYN) +RELOC_TYPE (GNU_VTINHERIT, REL) +RELOC_TYPE (GNU_VTENTRY, REL) + Index: b/libelf/elf.h =================================================================== --- a/libelf/elf.h +++ b/libelf/elf.h @@ -1157,6 +1157,9 @@ #define R_68K_GLOB_DAT 20 /* Create GOT entry */ #define R_68K_JMP_SLOT 21 /* Create PLT entry */ #define R_68K_RELATIVE 22 /* Adjust by program base */ +/* The next 2 are GNU extensions to enable C++ vtable garbage collection. */ +#define R_68K_GNU_VTINHERIT 23 +#define R_68K_GNU_VTENTRY 24 #define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */ #define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */ #define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */ Index: b/backends/Makefile.am =================================================================== --- a/backends/Makefile.am +++ b/backends/Makefile.am @@ -33,11 +33,11 @@ modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \ - tilegx parisc mips + tilegx parisc mips m68k libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \ libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \ libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \ - libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a libebl_parisc_pic.a libebl_mips_pic.a + libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a libebl_parisc_pic.a libebl_mips_pic.a libebl_m68k_pic.a noinst_LIBRARIES = $(libebl_pic) noinst_DATA = $(libebl_pic:_pic.a=.so) @@ -124,6 +124,10 @@ libebl_mips_pic_a_SOURCES = $(mips_SRCS) am_libebl_mips_pic_a_OBJECTS = $(mips_SRCS:.c=.os) +m68k_SRCS = m68k_init.c m68k_symbol.c m68k_regs.c m68k_retval.c +libebl_m68k_pic_a_SOURCES = $(m68k_SRCS) +am_libebl_m68k_pic_a_OBJECTS = $(m68k_SRCS:.c=.os) + libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw) @rm -f $(@:.so=.map) echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \ Index: b/backends/m68k_symbol.c =================================================================== --- /dev/null +++ b/backends/m68k_symbol.c @@ -0,0 +1,43 @@ +/* m68k specific symbolic name handling. + Copyright (C) 2007 Kurt Roeckx + + This software is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + This software distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this software; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. +*/ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#define BACKEND m68k_ +#include "libebl_CPU.h" + +/* Check for the simple reloc types. */ +Elf_Type +m68k_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_68K_32: + return ELF_T_SWORD; + case R_68K_16: + return ELF_T_HALF; + case R_68K_8: + return ELF_T_BYTE; + default: + return ELF_T_NUM; + } +} Index: b/backends/m68k_retval.c =================================================================== --- /dev/null +++ b/backends/m68k_retval.c @@ -0,0 +1,172 @@ +/* Function return value location for Linux/m68k ABI. + Copyright (C) 2005-2010 Red Hat, Inc. + Copyright (c) 2011 Thorsten Glaser, Debian. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#define BACKEND m68k_ +#include "libebl_CPU.h" + + +/* %d0, or pair %d0, %d1, or %a0 */ +static const Dwarf_Op loc_intreg[] = + { + { .atom = DW_OP_reg0 }, { .atom = DW_OP_piece, .number = 4 }, + { .atom = DW_OP_reg1 }, { .atom = DW_OP_piece, .number = 4 }, + }; +static const Dwarf_Op loc_ptrreg[] = + { + { .atom = DW_OP_reg8 }, + }; +#define nloc_intreg 1 +#define nloc_intregpair 4 +#define nloc_ptrreg 1 + +/* %f0 */ +static const Dwarf_Op loc_fpreg[] = + { + { .atom = DW_OP_reg16 } + }; +#define nloc_fpreg 1 + +/* Structures are a bit more complicated - small structures are returned + in %d0 / %d1 (-freg-struct-return which is enabled by default), large + structures use %a1 (in constrast to the SYSV psABI which says %a0) as + reentrant storage space indicator. */ +static const Dwarf_Op loc_aggregate[] = + { + { .atom = DW_OP_breg9, .number = 0 } + }; +#define nloc_aggregate 1 + +int +m68k_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + Dwarf_Word size; + + /* Start with the function's type, and get the DW_AT_type attribute, + which is the type of the return value. */ + + Dwarf_Attribute attr_mem; + Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, + &attr_mem); + if (attr == NULL) + /* The function has no return value, like a `void' function in C. */ + return 0; + + Dwarf_Die die_mem; + Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem); + int tag = dwarf_tag (typedie); + + /* Follow typedefs and qualifiers to get to the actual type. */ + while (tag == DW_TAG_typedef + || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type + || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type) + { + attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + + switch (tag) + { + case -1: + return -1; + + case DW_TAG_subrange_type: + if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size)) + { + attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + /* Fall through. */ + + case DW_TAG_base_type: + case DW_TAG_enumeration_type: + case DW_TAG_pointer_type: + case DW_TAG_ptr_to_member_type: + if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, + &attr_mem), &size) != 0) + { + if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + size = 4; + else + return -1; + } + if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + { + *locp = loc_ptrreg; + return nloc_ptrreg; + } + if (tag == DW_TAG_base_type) + { + Dwarf_Word encoding; + if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding, + &attr_mem), + &encoding) != 0) + return -1; + if (encoding == DW_ATE_float) + { + /* XXX really 10? */ + if (size > 10) + return -2; + *locp = loc_fpreg; + return nloc_fpreg; + } + } + if (size <= 8) + { + intreg: + /* XXX check endianness of dword pair, int64 vs aggregate */ + *locp = loc_intreg; + return size <= 4 ? nloc_intreg : nloc_intregpair; + } + + aggregate: + *locp = loc_aggregate; + return nloc_aggregate; + + case DW_TAG_structure_type: + case DW_TAG_class_type: + case DW_TAG_union_type: + case DW_TAG_array_type: + if (dwarf_aggregate_size (typedie, &size) == 0 + && size > 0 && size <= 8) + /* not accurate for a struct whose only member is a float */ + goto intreg; + goto aggregate; + } + + /* XXX We don't have a good way to return specific errors from ebl calls. + This value means we do not understand the type, but it is well-formed + DWARF and might be valid. */ + return -2; +} debian/patches/redhat-robustify.diff0000664000000000000000000016772012262514022014755 0ustar Index: b/libdwfl/ChangeLog =================================================================== --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -695,6 +695,11 @@ * dwfl_module_getdwarf.c (open_elf): Clear errno before CBFAIL. Reported by Kurt Roeckx . +2011-03-23 Petr Machata + + * relocate.c (relocate_section): Use gelf_fsize instead of relying + on shdr->sh_entsize. + 2011-02-11 Roland McGrath * linux-kernel-modules.c (try_kernel_name): Try .gz, .bz2, .xz Index: b/libdwfl/relocate.c =================================================================== --- a/libdwfl/relocate.c +++ b/libdwfl/relocate.c @@ -1,5 +1,5 @@ /* Relocate debug information. - Copyright (C) 2005-2010 Red Hat, Inc. + Copyright (C) 2005-2011 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -456,7 +456,10 @@ } } - size_t nrels = shdr->sh_size / shdr->sh_entsize; + size_t sh_entsize + = gelf_fsize (relocated, shdr->sh_type == SHT_REL ? ELF_T_REL : ELF_T_RELA, + 1, EV_CURRENT); + size_t nrels = shdr->sh_size / sh_entsize; size_t complete = 0; if (shdr->sh_type == SHT_REL) for (size_t relidx = 0; !result && relidx < nrels; ++relidx) @@ -558,7 +561,7 @@ nrels = next; } - shdr->sh_size = reldata->d_size = nrels * shdr->sh_entsize; + shdr->sh_size = reldata->d_size = nrels * sh_entsize; gelf_update_shdr (scn, shdr); } Index: b/libelf/ChangeLog =================================================================== --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -759,10 +759,53 @@ If section content hasn't been read yet, do it before looking for the block size. If no section data present, infer size of section header. +2005-05-14 Jakub Jelinek + + * libelfP.h (INVALID_NDX): Define. + * gelf_getdyn.c (gelf_getdyn): Use it. Remove ndx < 0 test if any. + * gelf_getlib.c (gelf_getlib): Likewise. + * gelf_getmove.c (gelf_getmove): Likewise. + * gelf_getrel.c (gelf_getrel): Likewise. + * gelf_getrela.c (gelf_getrela): Likewise. + * gelf_getsym.c (gelf_getsym): Likewise. + * gelf_getsyminfo.c (gelf_getsyminfo): Likewise. + * gelf_getsymshndx.c (gelf_getsymshndx): Likewise. + * gelf_getversym.c (gelf_getversym): Likewise. + * gelf_update_dyn.c (gelf_update_dyn): Likewise. + * gelf_update_lib.c (gelf_update_lib): Likewise. + * gelf_update_move.c (gelf_update_move): Likewise. + * gelf_update_rel.c (gelf_update_rel): Likewise. + * gelf_update_rela.c (gelf_update_rela): Likewise. + * gelf_update_sym.c (gelf_update_sym): Likewise. + * gelf_update_syminfo.c (gelf_update_syminfo): Likewise. + * gelf_update_symshndx.c (gelf_update_symshndx): Likewise. + * gelf_update_versym.c (gelf_update_versym): Likewise. + * elf_newscn.c (elf_newscn): Check for overflow. + * elf32_updatefile.c (__elfw2(LIBELFBITS,updatemmap)): Likewise. + (__elfw2(LIBELFBITS,updatefile)): Likewise. + * elf_begin.c (file_read_elf): Likewise. + * elf32_newphdr.c (elfw2(LIBELFBITS,newphdr)): Likewise. + * elf_getarsym.c (elf_getarsym): Likewise. + * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)): Likewise. 2005-05-11 Ulrich Drepper * elf.h: Update again. +2005-05-17 Jakub Jelinek + + * elf32_getphdr.c (elfw2(LIBELFBITS,getphdr)): Check if program header + table fits into object's bounds. + * elf_getshstrndx.c (elf_getshstrndx): Add elf->start_offset to + elf->map_address. Check if first section header fits into object's + bounds. + * elf32_getshdr.c (elfw2(LIBELFBITS,getshdr)): + Check if section header table fits into object's bounds. + * elf_begin.c (get_shnum): Ensure section headers fits into + object's bounds. + (file_read_elf): Make sure scncnt is small enough to allocate both + ElfXX_Shdr and Elf_Scn array. Make sure section and program header + tables fit into object's bounds. Avoid memory leak on failure. + 2005-05-09 Ulrich Drepper * elf.h: Update from glibc. Index: b/libelf/elf32_getphdr.c =================================================================== --- a/libelf/elf32_getphdr.c +++ b/libelf/elf32_getphdr.c @@ -93,6 +93,16 @@ 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 (elf->maximum_size - ehdr->e_phoff < 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); Index: b/libelf/elf32_getshdr.c =================================================================== --- a/libelf/elf32_getshdr.c +++ b/libelf/elf32_getshdr.c @@ -60,7 +60,8 @@ goto out; size_t shnum; - if (__elf_getshdrnum_rdlock (elf, &shnum) != 0) + if (__elf_getshdrnum_rdlock (elf, &shnum) != 0 + || shnum > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Shdr))) goto out; size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr)); @@ -77,6 +78,16 @@ 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 (elf->maximum_size - ehdr->e_shoff < 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 Index: b/libelf/elf32_newphdr.c =================================================================== --- a/libelf/elf32_newphdr.c +++ b/libelf/elf32_newphdr.c @@ -114,6 +114,12 @@ || count == PN_XNUM || 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) *) Index: b/libelf/elf32_updatefile.c =================================================================== --- a/libelf/elf32_updatefile.c +++ b/libelf/elf32_updatefile.c @@ -202,6 +202,9 @@ /* 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 @@ -624,6 +627,10 @@ /* 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]; Index: b/libelf/elf_begin.c =================================================================== --- a/libelf/elf_begin.c +++ b/libelf/elf_begin.c @@ -144,7 +144,8 @@ 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 (maxsize - ehdr.e32->e_shoff < sizeof (Elf32_Shdr))) /* Cannot read the first section header. */ return 0; @@ -192,7 +193,8 @@ 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; @@ -264,6 +266,15 @@ /* 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. Even if there are no section headers, we allocate space for a zeroth section in case we need it later. */ const size_t scnmax = (scncnt ?: (cmd == ELF_C_RDWR || cmd == ELF_C_RDWR_MMAP) @@ -303,6 +314,16 @@ { /* We can use the mmapped memory. */ elf->state.elf32.ehdr = ehdr; + + if (unlikely (ehdr->e_shoff >= maxsize) + || unlikely (maxsize - ehdr->e_shoff + < scncnt * sizeof (Elf32_Shdr))) + { + free_and_out: + free (elf); + __libelf_seterrno (ELF_E_INVALID_FILE); + return NULL; + } elf->state.elf32.shdr = (Elf32_Shdr *) ((char *) ehdr + ehdr->e_shoff); @@ -389,6 +410,11 @@ { /* 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); Index: b/libelf/elf_getarsym.c =================================================================== --- a/libelf/elf_getarsym.c +++ b/libelf/elf_getarsym.c @@ -183,6 +183,9 @@ 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 * w > index_size) { /* This index table cannot be right since it does not fit into Index: b/libelf/elf_getshdrstrndx.c =================================================================== --- a/libelf/elf_getshdrstrndx.c +++ b/libelf/elf_getshdrstrndx.c @@ -104,10 +104,25 @@ if (elf->map_address != NULL && elf->state.elf32.ehdr->e_ident[EI_DATA] == MY_ELFDATA && (ALLOW_UNALIGNED - || (((size_t) ((char *) elf->map_address + offset)) + || (((size_t) ((char *) elf->map_address + + elf->start_offset + offset)) & (__alignof__ (Elf32_Shdr) - 1)) == 0)) - /* We can directly access the memory. */ - num = ((Elf32_Shdr *) (elf->map_address + offset))->sh_link; + { + /* First see whether the information in the ELF header is + valid and it does not ask for too much. */ + if (unlikely (elf->maximum_size - offset + < sizeof (Elf32_Shdr))) + { + /* Something is wrong. */ + __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); + result = -1; + goto out; + } + + /* We can directly access the memory. */ + num = ((Elf32_Shdr *) (elf->map_address + elf->start_offset + + offset))->sh_link; + } else { /* We avoid reading in all the section headers. Just read @@ -142,10 +157,25 @@ if (elf->map_address != NULL && elf->state.elf64.ehdr->e_ident[EI_DATA] == MY_ELFDATA && (ALLOW_UNALIGNED - || (((size_t) ((char *) elf->map_address + offset)) + || (((size_t) ((char *) elf->map_address + + elf->start_offset + offset)) & (__alignof__ (Elf64_Shdr) - 1)) == 0)) - /* We can directly access the memory. */ - num = ((Elf64_Shdr *) (elf->map_address + offset))->sh_link; + { + /* First see whether the information in the ELF header is + valid and it does not ask for too much. */ + if (unlikely (elf->maximum_size - offset + < sizeof (Elf64_Shdr))) + { + /* Something is wrong. */ + __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); + result = -1; + goto out; + } + + /* We can directly access the memory. */ + num = ((Elf64_Shdr *) (elf->map_address + elf->start_offset + + offset))->sh_link; + } else { /* We avoid reading in all the section headers. Just read Index: b/libelf/elf_newscn.c =================================================================== --- a/libelf/elf_newscn.c +++ b/libelf/elf_newscn.c @@ -83,10 +83,18 @@ 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); Index: b/libelf/gelf_getdyn.c =================================================================== --- a/libelf/gelf_getdyn.c +++ b/libelf/gelf_getdyn.c @@ -1,5 +1,5 @@ /* Get information from dynamic table at the given index. - Copyright (C) 2000, 2001, 2002 Red Hat, Inc. + Copyright (C) 2000-2009 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2000. @@ -72,7 +72,7 @@ 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; @@ -93,7 +93,7 @@ /* 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; Index: b/libelf/gelf_getlib.c =================================================================== --- a/libelf/gelf_getlib.c +++ b/libelf/gelf_getlib.c @@ -1,5 +1,5 @@ /* Get library from table at the given index. - Copyright (C) 2004 Red Hat, Inc. + Copyright (C) 2004-2009 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2004. @@ -65,7 +65,7 @@ /* 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, data)) __libelf_seterrno (ELF_E_INVALID_INDEX); else { Index: b/libelf/gelf_getmove.c =================================================================== --- a/libelf/gelf_getmove.c +++ b/libelf/gelf_getmove.c @@ -1,5 +1,5 @@ /* Get move structure at the given index. - Copyright (C) 2000, 2001, 2002 Red Hat, Inc. + Copyright (C) 2000-2009 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2000. @@ -62,7 +62,7 @@ /* 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, data)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; Index: b/libelf/gelf_getrela.c =================================================================== --- a/libelf/gelf_getrela.c +++ b/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 elfutils. Written by Ulrich Drepper , 2000. @@ -50,12 +50,6 @@ 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); @@ -72,7 +66,7 @@ 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); result = NULL; @@ -93,7 +87,7 @@ { /* 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); result = NULL; Index: b/libelf/gelf_getrel.c =================================================================== --- a/libelf/gelf_getrel.c +++ b/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 elfutils. Written by Ulrich Drepper , 2000. @@ -50,12 +50,6 @@ 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); @@ -72,7 +66,7 @@ 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); result = NULL; @@ -92,7 +86,7 @@ { /* 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); result = NULL; Index: b/libelf/gelf_getsym.c =================================================================== --- a/libelf/gelf_getsym.c +++ b/libelf/gelf_getsym.c @@ -1,5 +1,5 @@ /* Get symbol information from symbol table at the given index. - Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc. + Copyright (C) 1999-2009 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 1999. @@ -69,7 +69,7 @@ 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, data)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; @@ -98,7 +98,7 @@ /* 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, data)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; Index: b/libelf/gelf_getsyminfo.c =================================================================== --- a/libelf/gelf_getsyminfo.c +++ b/libelf/gelf_getsyminfo.c @@ -1,5 +1,5 @@ /* Get additional symbol information from symbol table at the given index. - Copyright (C) 2000, 2001, 2002 Red Hat, Inc. + Copyright (C) 2000-2009 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2000. @@ -63,7 +63,7 @@ /* 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, data)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; Index: b/libelf/gelf_getsymshndx.c =================================================================== --- a/libelf/gelf_getsymshndx.c +++ b/libelf/gelf_getsymshndx.c @@ -1,6 +1,6 @@ /* Get symbol information and separate section index from symbol table at the given index. - Copyright (C) 2000, 2001, 2002 Red Hat, Inc. + Copyright (C) 2000-2009 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2000. @@ -69,7 +69,7 @@ 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, &shndxdata_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; @@ -89,7 +89,7 @@ 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, symdata)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; @@ -118,7 +118,7 @@ /* 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, symdata)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; Index: b/libelf/gelf_getversym.c =================================================================== --- a/libelf/gelf_getversym.c +++ b/libelf/gelf_getversym.c @@ -1,5 +1,5 @@ /* Get symbol version information at the given index. - Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc. + Copyright (C) 1999-2009 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 1999. @@ -71,7 +71,7 @@ /* 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, data)) { __libelf_seterrno (ELF_E_INVALID_INDEX); result = NULL; Index: b/libelf/gelf_update_dyn.c =================================================================== --- a/libelf/gelf_update_dyn.c +++ b/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 elfutils. Written by Ulrich Drepper , 2000. @@ -50,12 +50,6 @@ 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. */ @@ -81,7 +75,7 @@ } /* 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; @@ -95,7 +89,7 @@ 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; Index: b/libelf/gelf_update_lib.c =================================================================== --- a/libelf/gelf_update_lib.c +++ b/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 elfutils. Written by Ulrich Drepper , 2004. @@ -47,12 +47,6 @@ 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)) { @@ -66,7 +60,7 @@ /* 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, &data_scn->d)) __libelf_seterrno (ELF_E_INVALID_INDEX); else { Index: b/libelf/gelf_update_move.c =================================================================== --- a/libelf/gelf_update_move.c +++ b/libelf/gelf_update_move.c @@ -1,5 +1,5 @@ /* Update move structure at the given index. - Copyright (C) 2000, 2001, 2002 Red Hat, Inc. + Copyright (C) 2000-2009 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2000. @@ -54,8 +54,7 @@ assert (sizeof (GElf_Move) == sizeof (Elf64_Move)); /* Check whether we have to resize the data buffer. */ - if (unlikely (ndx < 0) - || 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; Index: b/libelf/gelf_update_rela.c =================================================================== --- a/libelf/gelf_update_rela.c +++ b/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 elfutils. Written by Ulrich Drepper , 2000. @@ -47,12 +47,6 @@ 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. */ @@ -80,7 +74,7 @@ } /* 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; @@ -96,7 +90,7 @@ 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; Index: b/libelf/gelf_update_rel.c =================================================================== --- a/libelf/gelf_update_rel.c +++ b/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 elfutils. Written by Ulrich Drepper , 2000. @@ -47,12 +47,6 @@ 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. */ @@ -78,7 +72,7 @@ } /* 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; @@ -93,7 +87,7 @@ 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; Index: b/libelf/gelf_update_sym.c =================================================================== --- a/libelf/gelf_update_sym.c +++ b/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 elfutils. Written by Ulrich Drepper , 2000. @@ -51,12 +51,6 @@ 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. */ @@ -81,7 +75,7 @@ } /* 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; @@ -104,7 +98,7 @@ 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; Index: b/libelf/gelf_update_syminfo.c =================================================================== --- a/libelf/gelf_update_syminfo.c +++ b/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 elfutils. Written by Ulrich Drepper , 2000. @@ -51,12 +51,6 @@ 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. */ @@ -72,7 +66,7 @@ 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, &data_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; Index: b/libelf/gelf_update_symshndx.c =================================================================== --- a/libelf/gelf_update_symshndx.c +++ b/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 elfutils. Written by Ulrich Drepper , 2000. @@ -56,12 +56,6 @@ 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. */ @@ -107,7 +101,7 @@ } /* 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, &symdata_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; @@ -130,7 +124,7 @@ 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, &symdata_scn->d)) { __libelf_seterrno (ELF_E_INVALID_INDEX); goto out; Index: b/libelf/gelf_update_versym.c =================================================================== --- a/libelf/gelf_update_versym.c +++ b/libelf/gelf_update_versym.c @@ -1,5 +1,5 @@ /* Update symbol version information. - Copyright (C) 2001, 2002 Red Hat, Inc. + Copyright (C) 2001-2009 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2001. @@ -54,8 +54,7 @@ assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym)); /* Check whether we have to resize the data buffer. */ - if (unlikely (ndx < 0) - || 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; Index: b/libelf/libelfP.h =================================================================== --- a/libelf/libelfP.h +++ b/libelf/libelfP.h @@ -587,4 +587,8 @@ /* Align offset to 4 bytes as needed for note name and descriptor data. */ #define NOTE_ALIGN(n) (((n) + 3) & -4U) +/* Convenience macro. */ +#define INVALID_NDX(ndx, type, data) \ + unlikely ((data)->d_size / sizeof (type) <= (unsigned int) (ndx)) + #endif /* libelfP.h */ Index: b/src/ChangeLog =================================================================== --- a/src/ChangeLog +++ b/src/ChangeLog @@ -702,6 +702,12 @@ * readelf.c (dwarf_attr_string): Grok DW_AT_GNU_odr_signature. +2011-03-23 Petr Machata + + * readelf.c (handle_dynamic, handle_relocs_rel) + (handle_relocs_rela, handle_versym, print_liblist): + Use gelf_fsize instead of relying on shdr->sh_entsize. + 2011-02-11 Roland McGrath * elfcmp.c (verbose): New variable. @@ -2439,6 +2445,16 @@ object symbols or symbols with unknown type. (check_rel): Likewise. +2005-06-09 Roland McGrath + + * readelf.c (handle_dynamic, handle_symtab): Check for bogus sh_link. + (handle_verneed, handle_verdef, handle_versym, handle_hash): Likewise. + (handle_scngrp): Check for bogus sh_info. + + * strip.c (handle_elf): Check for bogus values in sh_link, sh_info, + st_shndx, e_shstrndx, and SHT_GROUP or SHT_SYMTAB_SHNDX data. + Don't use assert on input values, instead bail with "illformed" error. + 2005-06-08 Roland McGrath * readelf.c (print_ops): Add consts. @@ -2489,6 +2505,19 @@ * readelf.c (dwarf_tag_string): Add new tags. +2005-05-17 Jakub Jelinek + + * elflint.c (check_hash): Don't check entries beyond end of section. + (check_note): Don't crash if gelf_rawchunk fails. + (section_name): Return if gelf_getshdr returns NULL. + +2005-05-14 Jakub Jelinek + + * elflint.c (section_name): Return "" instead of + crashing on invalid section name. + (check_symtab, is_rel_dyn, check_rela, check_rel, check_dynamic, + check_symtab_shndx, check_hash, check_versym): Robustify. + 2005-05-08 Roland McGrath * strip.c (handle_elf): Don't translate hash and versym data formats, Index: b/src/elflint.c =================================================================== --- a/src/elflint.c +++ b/src/elflint.c @@ -123,6 +123,10 @@ /* Array to count references in section groups. */ static int *scnref; +/* Numbers of sections and program headers. */ +static unsigned int shnum; +static unsigned int phnum; + int main (int argc, char *argv[]) @@ -311,10 +315,19 @@ { 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; } @@ -337,11 +350,6 @@ (sizeof (valid_e_machine) / sizeof (valid_e_machine[0])) -/* Numbers of sections and program headers. */ -static unsigned int shnum; -static unsigned int phnum; - - static void check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size) { @@ -625,7 +633,8 @@ } } - 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)); @@ -663,7 +672,7 @@ 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) @@ -683,7 +692,8 @@ 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) @@ -1040,9 +1050,11 @@ { 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); @@ -1052,7 +1064,9 @@ { 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) { @@ -1066,7 +1080,9 @@ /* 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), @@ -1226,7 +1242,8 @@ } } - 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"), @@ -1449,7 +1466,8 @@ 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); @@ -1499,7 +1517,8 @@ 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); @@ -1598,7 +1617,8 @@ 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)); @@ -1608,7 +1628,7 @@ 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); @@ -1880,6 +1900,8 @@ 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 ("\ @@ -1906,6 +1928,12 @@ } 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")); @@ -1948,7 +1976,7 @@ size_t maxidx = nchain; - if (symshdr != NULL) + if (symshdr != NULL && symshdr->sh_entsize != 0) { size_t symsize = symshdr->sh_size / symshdr->sh_entsize; @@ -1959,18 +1987,28 @@ 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); + } } @@ -2000,18 +2038,28 @@ 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); + } } @@ -2036,7 +2084,7 @@ 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; @@ -2708,8 +2756,9 @@ /* 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), Index: b/src/readelf.c =================================================================== --- a/src/readelf.c +++ b/src/readelf.c @@ -1364,6 +1364,8 @@ 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", @@ -1376,8 +1378,8 @@ 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); @@ -1528,10 +1530,12 @@ 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; + size_t sh_entsize; /* Get the data of the section. */ data = elf_getdata (scn, NULL); @@ -1543,21 +1547,26 @@ error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); + sh_entsize = gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT); + + 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", "\ \nDynamic segment contains %lu entries:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", - shdr->sh_size / shdr->sh_entsize), - (unsigned long int) (shdr->sh_size / shdr->sh_entsize), + shdr->sh_size / sh_entsize), + (unsigned long int) (shdr->sh_size / sh_entsize), 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) + for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) { GElf_Dyn dynmem; GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dynmem); @@ -1706,7 +1715,8 @@ handle_relocs_rel (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr) { int class = gelf_getclass (ebl->elf); - int nentries = shdr->sh_size / shdr->sh_entsize; + size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT); + int nentries = shdr->sh_size / sh_entsize; /* Get the data of the section. */ Elf_Data *data = elf_getdata (scn, NULL); @@ -1892,7 +1902,8 @@ handle_relocs_rela (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr) { int class = gelf_getclass (ebl->elf); - int nentries = shdr->sh_size / shdr->sh_entsize; + size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT); + int nentries = shdr->sh_size / sh_entsize; /* Get the data of the section. */ Elf_Data *data = elf_getdata (scn, NULL); @@ -2139,6 +2150,13 @@ 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) @@ -2149,15 +2167,12 @@ 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 ("\ @@ -2393,7 +2408,13 @@ 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", "\ @@ -2404,9 +2425,7 @@ 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; ) @@ -2459,8 +2478,14 @@ 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", "\ @@ -2472,9 +2497,7 @@ 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; ) @@ -2736,25 +2759,30 @@ filename = NULL; } + GElf_Shdr glink_mem; + GElf_Shdr *glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), + &glink_mem); + size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_HALF, 1, EV_CURRENT); + 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'", "\ \nVersion symbols section [%2u] '%s' contains %d entries:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'", - shdr->sh_size / shdr->sh_entsize), + shdr->sh_size / sh_entsize), (unsigned int) elf_ndxscn (scn), elf_strptr (ebl->elf, shstrndx, shdr->sh_name), - (int) (shdr->sh_size / shdr->sh_entsize), + (int) (shdr->sh_size / sh_entsize), 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) + for (unsigned int cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) { if (cnt % 2 == 0) printf ("\n %4d:", cnt); @@ -2803,7 +2831,17 @@ 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", "\ @@ -2816,9 +2854,7 @@ 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); @@ -3078,7 +3114,8 @@ if (shdr != NULL && shdr->sh_type == SHT_GNU_LIBLIST) { - int nentries = shdr->sh_size / shdr->sh_entsize; + size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_LIB, 1, EV_CURRENT); + int nentries = shdr->sh_size / sh_entsize; printf (ngettext ("\ \nLibrary list section [%2zu] '%s' at offset %#0" PRIx64 " contains %d entry:\n", "\ @@ -4403,6 +4440,16 @@ return; } + GElf_Shdr glink_mem; + GElf_Shdr *glink; + glink = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_link), &glink_mem); + if (glink == NULL) + { + error (0, 0, gettext ("invalid sh_link value in section %Zu"), + elf_ndxscn (scn)); + return; + } + printf (ngettext ("\ \nDWARF section [%2zu] '%s' at offset %#" PRIx64 " contains %zu entry:\n", "\ Index: b/src/strip.c =================================================================== --- a/src/strip.c +++ b/src/strip.c @@ -581,6 +581,11 @@ 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. @@ -602,7 +607,7 @@ { /* 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; @@ -615,6 +620,7 @@ shdr_info[cnt].shdr.sh_name); if (shdr_info[cnt].name == NULL) { + illformed: error (0, 0, gettext ("illformed file '%s'"), fname); goto fail_close; } @@ -624,6 +630,8 @@ /* 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 @@ -636,7 +644,7 @@ 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)) @@ -653,7 +661,12 @@ 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 @@ -664,7 +677,7 @@ } 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; } @@ -672,7 +685,7 @@ 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) { @@ -748,10 +761,14 @@ { /* 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) - shdr_info[cnt].idx = 1; + { + 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 a group section is marked as being removed make sure all the sections it contains are being removed, too. */ @@ -795,7 +812,7 @@ 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, @@ -835,6 +852,9 @@ 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 @@ -865,12 +885,16 @@ } /* 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; @@ -1011,7 +1035,7 @@ 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); @@ -1048,7 +1072,7 @@ 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) @@ -1105,7 +1129,7 @@ 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. */ @@ -1195,20 +1219,20 @@ 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); } @@ -1263,7 +1287,7 @@ sec = shdr_info[sym->st_shndx].idx; else { - assert (shndxdata != NULL); + elf_assert (shndxdata != NULL); sec = shdr_info[xshndx].idx; } @@ -1284,7 +1308,7 @@ 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)) @@ -1311,9 +1335,11 @@ { size_t sidx = (sym->st_shndx != SHN_XINDEX ? sym->st_shndx : xshndx); - assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION - || (shdr_info[sidx].shdr.sh_type == SHT_GROUP - && shdr_info[sidx].shdr.sh_info == inner)); + elf_assert (GELF_ST_TYPE (sym->st_info) == STT_SECTION + || ((shdr_info[sidx].shdr.sh_type + == SHT_GROUP) + && (shdr_info[sidx].shdr.sh_info + == inner))); } } @@ -1501,11 +1527,11 @@ { 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) @@ -1524,8 +1550,8 @@ else { /* Alpha and S390 64-bit use 64-bit SHT_HASH entries. */ - assert (shdr_info[cnt].shdr.sh_entsize - == sizeof (Elf64_Xword)); + elf_assert (shdr_info[cnt].shdr.sh_entsize + == sizeof (Elf64_Xword)); Elf64_Xword *bucket = (Elf64_Xword *) hashd->d_buf; @@ -1555,11 +1581,11 @@ { 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) debian/patches/testsuite-ignore-elflint.diff0000664000000000000000000000266312175210112016415 0ustar On many architectures this test fails because binaries/libs produced by binutils don't pass elflint. However elfutils shouldn't FTBFS because of this. So we run the tests on all archs to see what breaks, but if it breaks we ignore the result (exitcode 77 means: this test was skipped). Index: elfutils-0.156/tests/run-elflint-self.sh =================================================================== --- elfutils-0.156.orig/tests/run-elflint-self.sh 2013-07-28 14:35:36.000000000 +0200 +++ elfutils-0.156/tests/run-elflint-self.sh 2013-07-28 14:36:10.000000000 +0200 @@ -18,4 +18,4 @@ . $srcdir/test-subr.sh -testrun_on_self ${abs_top_builddir}/src/elflint --quiet --gnu-ld +testrun_on_self_skip ${abs_top_builddir}/src/elflint --quiet --gnu-ld Index: elfutils-0.156/tests/test-subr.sh =================================================================== --- elfutils-0.156.orig/tests/test-subr.sh 2013-07-28 14:35:36.000000000 +0200 +++ elfutils-0.156/tests/test-subr.sh 2013-07-28 14:35:36.000000000 +0200 @@ -149,3 +149,18 @@ # Only exit if something failed if test $exit_status != 0; then exit $exit_status; fi } + +# Same as testrun_on_self(), but skip on failure. +testrun_on_self_skip() +{ + exit_status=0 + + for file in $self_test_files; do + testrun $* $file \ + || { echo "*** failure in $* $file"; exit_status=77; } + done + + # Only exit if something failed + if test $exit_status != 0; then exit $exit_status; fi +} + debian/patches/hppa_backend.diff0000664000000000000000000006074712262513261014066 0ustar Index: b/backends/parisc_init.c =================================================================== --- /dev/null +++ b/backends/parisc_init.c @@ -0,0 +1,74 @@ +/* Initialization of PA-RISC specific backend library. + Copyright (C) 2002, 2005, 2006 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2002. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#define BACKEND parisc_ +#define RELOC_PREFIX R_PARISC_ +#include "libebl_CPU.h" +#include "libebl_parisc.h" + +/* This defines the common reloc hooks based on parisc_reloc.def. */ +#include "common-reloc.c" + + +const char * +parisc_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + int pa64 = 0; + + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + if (elf) { + GElf_Ehdr ehdr_mem; + GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem); + if (ehdr && (ehdr->e_flags & EF_PARISC_WIDE)) + pa64 = 1; + } + /* We handle it. */ + eh->name = "PA-RISC"; + parisc_init_reloc (eh); + HOOK (eh, reloc_simple_type); + HOOK (eh, machine_flag_check); + HOOK (eh, symbol_type_name); + HOOK (eh, segment_type_name); + HOOK (eh, section_type_name); + HOOK (eh, register_info); + if (pa64) + eh->return_value_location = parisc_return_value_location_64; + else + eh->return_value_location = parisc_return_value_location_32; + + return MODVERSION; +} Index: b/backends/parisc_regs.c =================================================================== --- /dev/null +++ b/backends/parisc_regs.c @@ -0,0 +1,159 @@ +/* Register names and numbers for PA-RISC DWARF. + Copyright (C) 2005, 2006 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#define BACKEND parisc_ +#include "libebl_CPU.h" + +ssize_t +parisc_register_info (Ebl *ebl, int regno, char *name, size_t namelen, + const char **prefix, const char **setname, + int *bits, int *type) +{ + int pa64 = 0; + + if (ebl->elf) { + GElf_Ehdr ehdr_mem; + GElf_Ehdr *ehdr = gelf_getehdr (ebl->elf, &ehdr_mem); + if (ehdr->e_flags & EF_PARISC_WIDE) + pa64 = 1; + } + + int nregs = pa64 ? 127 : 128; + + if (name == NULL) + return nregs; + + if (regno < 0 || regno >= nregs || namelen < 6) + return -1; + + *prefix = "%"; + + if (regno < 32) + { + *setname = "integer"; + *type = DW_ATE_signed; + if (pa64) + { + *bits = 64; + } + else + { + *bits = 32; + } + } + else if (regno == 32) + { + *setname = "special"; + if (pa64) + { + *bits = 6; + } + else + { + *bits = 5; + } + *type = DW_ATE_unsigned; + } + else + { + *setname = "FPU"; + *type = DW_ATE_float; + if (pa64) + { + *bits = 64; + } + else + { + *bits = 32; + } + } + + if (regno < 33) { + switch (regno) + { + case 0 ... 9: + name[0] = 'r'; + name[1] = regno + '0'; + namelen = 2; + break; + case 10 ... 31: + name[0] = 'r'; + name[1] = regno / 10 + '0'; + name[2] = regno % 10 + '0'; + namelen = 3; + break; + case 32: + *prefix = NULL; + name[0] = 'S'; + name[1] = 'A'; + name[2] = 'R'; + namelen = 3; + break; + } + } + else { + if (pa64 && ((regno - 72) % 2)) { + *setname = NULL; + return 0; + } + + switch (regno) + { + case 72 + 0 ... 72 + 11: + name[0] = 'f'; + name[1] = 'r'; + name[2] = (regno + 8 - 72) / 2 + '0'; + namelen = 3; + if ((regno + 8 - 72) % 2) { + name[3] = 'R'; + namelen++; + } + break; + case 72 + 12 ... 72 + 55: + name[0] = 'f'; + name[1] = 'r'; + name[2] = (regno + 8 - 72) / 2 / 10 + '0'; + name[3] = (regno + 8 - 72) / 2 % 10 + '0'; + namelen = 4; + if ((regno + 8 - 72) % 2) { + name[4] = 'R'; + namelen++; + } + break; + default: + *setname = NULL; + return 0; + } + } + name[namelen++] = '\0'; + return namelen; +} Index: b/backends/parisc_reloc.def =================================================================== --- /dev/null +++ b/backends/parisc_reloc.def @@ -0,0 +1,128 @@ +/* List the relocation types for PA-RISC. -*- C -*- + Copyright (C) 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, EXEC|DYN) +RELOC_TYPE (DIR32, REL|EXEC|DYN) +RELOC_TYPE (DIR21L, REL|EXEC|DYN) +RELOC_TYPE (DIR17R, REL) +RELOC_TYPE (DIR17F, REL) +RELOC_TYPE (DIR14R, REL|DYN) +RELOC_TYPE (PCREL32, REL) +RELOC_TYPE (PCREL21L, REL) +RELOC_TYPE (PCREL17R, REL) +RELOC_TYPE (PCREL17F, REL) +RELOC_TYPE (PCREL14R, REL|EXEC) +RELOC_TYPE (DPREL21L, REL) +RELOC_TYPE (DPREL14WR, REL) +RELOC_TYPE (DPREL14DR, REL) +RELOC_TYPE (DPREL14R, REL) +RELOC_TYPE (GPREL21L, 0) +RELOC_TYPE (GPREL14R, 0) +RELOC_TYPE (LTOFF21L, REL) +RELOC_TYPE (LTOFF14R, REL) +RELOC_TYPE (DLTIND14F, 0) +RELOC_TYPE (SETBASE, 0) +RELOC_TYPE (SECREL32, REL) +RELOC_TYPE (BASEREL21L, 0) +RELOC_TYPE (BASEREL17R, 0) +RELOC_TYPE (BASEREL14R, 0) +RELOC_TYPE (SEGBASE, 0) +RELOC_TYPE (SEGREL32, REL) +RELOC_TYPE (PLTOFF21L, 0) +RELOC_TYPE (PLTOFF14R, 0) +RELOC_TYPE (PLTOFF14F, 0) +RELOC_TYPE (LTOFF_FPTR32, 0) +RELOC_TYPE (LTOFF_FPTR21L, 0) +RELOC_TYPE (LTOFF_FPTR14R, 0) +RELOC_TYPE (FPTR64, 0) +RELOC_TYPE (PLABEL32, REL|DYN) +RELOC_TYPE (PCREL64, 0) +RELOC_TYPE (PCREL22C, 0) +RELOC_TYPE (PCREL22F, 0) +RELOC_TYPE (PCREL14WR, 0) +RELOC_TYPE (PCREL14DR, 0) +RELOC_TYPE (PCREL16F, 0) +RELOC_TYPE (PCREL16WF, 0) +RELOC_TYPE (PCREL16DF, 0) +RELOC_TYPE (DIR64, REL|DYN) +RELOC_TYPE (DIR14WR, REL) +RELOC_TYPE (DIR14DR, REL) +RELOC_TYPE (DIR16F, REL) +RELOC_TYPE (DIR16WF, REL) +RELOC_TYPE (DIR16DF, REL) +RELOC_TYPE (GPREL64, 0) +RELOC_TYPE (GPREL14WR, 0) +RELOC_TYPE (GPREL14DR, 0) +RELOC_TYPE (GPREL16F, 0) +RELOC_TYPE (GPREL16WF, 0) +RELOC_TYPE (GPREL16DF, 0) +RELOC_TYPE (LTOFF64, 0) +RELOC_TYPE (LTOFF14WR, 0) +RELOC_TYPE (LTOFF14DR, 0) +RELOC_TYPE (LTOFF16F, 0) +RELOC_TYPE (LTOFF16WF, 0) +RELOC_TYPE (LTOFF16DF, 0) +RELOC_TYPE (SECREL64, 0) +RELOC_TYPE (BASEREL14WR, 0) +RELOC_TYPE (BASEREL14DR, 0) +RELOC_TYPE (SEGREL64, 0) +RELOC_TYPE (PLTOFF14WR, 0) +RELOC_TYPE (PLTOFF14DR, 0) +RELOC_TYPE (PLTOFF16F, 0) +RELOC_TYPE (PLTOFF16WF, 0) +RELOC_TYPE (PLTOFF16DF, 0) +RELOC_TYPE (LTOFF_FPTR64, 0) +RELOC_TYPE (LTOFF_FPTR14WR, 0) +RELOC_TYPE (LTOFF_FPTR14DR, 0) +RELOC_TYPE (LTOFF_FPTR16F, 0) +RELOC_TYPE (LTOFF_FPTR16WF, 0) +RELOC_TYPE (LTOFF_FPTR16DF, 0) +RELOC_TYPE (COPY, EXEC) +RELOC_TYPE (IPLT, EXEC|DYN) +RELOC_TYPE (EPLT, 0) +RELOC_TYPE (TPREL32, DYN) +RELOC_TYPE (TPREL21L, 0) +RELOC_TYPE (TPREL14R, 0) +RELOC_TYPE (LTOFF_TP21L, 0) +RELOC_TYPE (LTOFF_TP14R, 0) +RELOC_TYPE (LTOFF_TP14F, 0) +RELOC_TYPE (TPREL64, 0) +RELOC_TYPE (TPREL14WR, 0) +RELOC_TYPE (TPREL14DR, 0) +RELOC_TYPE (TPREL16F, 0) +RELOC_TYPE (TPREL16WF, 0) +RELOC_TYPE (TPREL16DF, 0) +RELOC_TYPE (LTOFF_TP64, 0) +RELOC_TYPE (LTOFF_TP14WR, 0) +RELOC_TYPE (LTOFF_TP14DR, 0) +RELOC_TYPE (LTOFF_TP16F, 0) +RELOC_TYPE (LTOFF_TP16WF, 0) +RELOC_TYPE (LTOFF_TP16DF, 0) +RELOC_TYPE (TLS_DTPMOD32, DYN) +RELOC_TYPE (TLS_DTPMOD64, DYN) + +#define NO_RELATIVE_RELOC 1 Index: b/backends/parisc_retval.c =================================================================== --- /dev/null +++ b/backends/parisc_retval.c @@ -0,0 +1,213 @@ +/* Function return value location for Linux/PA-RISC ABI. + Copyright (C) 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#define BACKEND parisc_ +#include "libebl_CPU.h" +#include "libebl_parisc.h" + +/* %r28, or pair %r28, %r29. */ +static const Dwarf_Op loc_intreg32[] = + { + { .atom = DW_OP_reg28 }, { .atom = DW_OP_piece, .number = 4 }, + { .atom = DW_OP_reg29 }, { .atom = DW_OP_piece, .number = 4 }, + }; + +static const Dwarf_Op loc_intreg[] = + { + { .atom = DW_OP_reg28 }, { .atom = DW_OP_piece, .number = 8 }, + { .atom = DW_OP_reg29 }, { .atom = DW_OP_piece, .number = 8 }, + }; +#define nloc_intreg 1 +#define nloc_intregpair 4 + +/* %fr4L, or pair %fr4L, %fr4R on pa-32 */ +static const Dwarf_Op loc_fpreg32[] = + { + { .atom = DW_OP_regx, .number = 72 }, { .atom = DW_OP_piece, .number = 4 }, + { .atom = DW_OP_regx, .number = 73 }, { .atom = DW_OP_piece, .number = 4 }, + }; +#define nloc_fpreg32 2 +#define nloc_fpregpair32 4 + +/* $fr4 */ +static const Dwarf_Op loc_fpreg[] = + { + { .atom = DW_OP_regx, .number = 72 }, + }; +#define nloc_fpreg 1 + +#if 0 +/* The return value is a structure and is actually stored in stack space + passed in a hidden argument by the caller. Address of the location is stored + in %r28 before function call, but it may be changed by function. */ +static const Dwarf_Op loc_aggregate[] = + { + { .atom = DW_OP_breg28 }, + }; +#define nloc_aggregate 1 +#endif + +static int +parisc_return_value_location_ (Dwarf_Die *functypedie, const Dwarf_Op **locp, int pa64) +{ + Dwarf_Word regsize = pa64 ? 8 : 4; + + /* Start with the function's type, and get the DW_AT_type attribute, + which is the type of the return value. */ + + Dwarf_Attribute attr_mem; + Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, &attr_mem); + if (attr == NULL) + /* The function has no return value, like a `void' function in C. */ + return 0; + + Dwarf_Die die_mem; + Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem); + int tag = dwarf_tag (typedie); + + /* Follow typedefs and qualifiers to get to the actual type. */ + while (tag == DW_TAG_typedef + || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type + || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type) + { + attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + + switch (tag) + { + case -1: + return -1; + + case DW_TAG_subrange_type: + if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size)) + { + attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + /* Fall through. */ + + case DW_TAG_base_type: + case DW_TAG_enumeration_type: + case DW_TAG_pointer_type: + case DW_TAG_ptr_to_member_type: + { + Dwarf_Word size; + if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, + &attr_mem), &size) != 0) + { + if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + size = 4; + else + return -1; + } + if (tag == DW_TAG_base_type) + { + Dwarf_Word encoding; + if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding, + &attr_mem), &encoding) != 0) + return -1; + + if (encoding == DW_ATE_float) + { + if (pa64) { + *locp = loc_fpreg; + if (size <= 8) + return nloc_fpreg; + } + else { + *locp = loc_fpreg32; + if (size <= 4) + return nloc_fpreg32; + else if (size <= 8) + return nloc_fpregpair32; + } + goto aggregate; + } + } + if (pa64) + *locp = loc_intreg; + else + *locp = loc_intreg32; + if (size <= regsize) + return nloc_intreg; + if (size <= 2 * regsize) + return nloc_intregpair; + + /* Else fall through. */ + } + + case DW_TAG_structure_type: + case DW_TAG_class_type: + case DW_TAG_union_type: + case DW_TAG_array_type: + aggregate: { + Dwarf_Word size; + if (dwarf_aggregate_size (typedie, &size) != 0) + return -1; + if (pa64) + *locp = loc_intreg; + else + *locp = loc_intreg32; + if (size <= regsize) + return nloc_intreg; + if (size <= 2 * regsize) + return nloc_intregpair; +#if 0 + /* there should be some way to know this location... But I do not see it. */ + *locp = loc_aggregate; + return nloc_aggregate; +#endif + /* fall through. */ + } + } + + /* XXX We don't have a good way to return specific errors from ebl calls. + This value means we do not understand the type, but it is well-formed + DWARF and might be valid. */ + return -2; +} + +int +parisc_return_value_location_32 (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + return parisc_return_value_location_ (functypedie, locp, 0); +} + +int +parisc_return_value_location_64 (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + return parisc_return_value_location_ (functypedie, locp, 1); +} + Index: b/backends/parisc_symbol.c =================================================================== --- /dev/null +++ b/backends/parisc_symbol.c @@ -0,0 +1,112 @@ +/* PA-RISC specific symbolic name handling. + Copyright (C) 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper , 2002. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#define BACKEND parisc_ +#include "libebl_CPU.h" + +const char * +parisc_segment_type_name (int segment, char *buf __attribute__ ((unused)), + size_t len __attribute__ ((unused))) +{ + switch (segment) + { + case PT_PARISC_ARCHEXT: + return "PARISC_ARCHEXT"; + case PT_PARISC_UNWIND: + return "PARISC_UNWIND"; + default: + break; + } + return NULL; +} + +/* Return symbolic representation of symbol type. */ +const char * +parisc_symbol_type_name(int symbol, char *buf __attribute__ ((unused)), + size_t len __attribute__ ((unused))) +{ + if (symbol == STT_PARISC_MILLICODE) + return "PARISC_MILLI"; + return NULL; +} + +/* Return symbolic representation of section type. */ +const char * +parisc_section_type_name (int type, + char *buf __attribute__ ((unused)), + size_t len __attribute__ ((unused))) +{ + switch (type) + { + case SHT_PARISC_EXT: + return "PARISC_EXT"; + case SHT_PARISC_UNWIND: + return "PARISC_UNWIND"; + case SHT_PARISC_DOC: + return "PARISC_DOC"; + } + + return NULL; +} + +/* Check whether machine flags are valid. */ +bool +parisc_machine_flag_check (GElf_Word flags) +{ + if (flags &~ (EF_PARISC_TRAPNIL | EF_PARISC_EXT | EF_PARISC_LSB | + EF_PARISC_WIDE | EF_PARISC_NO_KABP | + EF_PARISC_LAZYSWAP | EF_PARISC_ARCH)) + return 0; + + GElf_Word arch = flags & EF_PARISC_ARCH; + + return ((arch == EFA_PARISC_1_0) || (arch == EFA_PARISC_1_1) || + (arch == EFA_PARISC_2_0)); +} + +/* Check for the simple reloc types. */ +Elf_Type +parisc_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_PARISC_DIR64: + case R_PARISC_SECREL64: + return ELF_T_XWORD; + case R_PARISC_DIR32: + case R_PARISC_SECREL32: + return ELF_T_WORD; + default: + return ELF_T_NUM; + } +} Index: b/backends/libebl_parisc.h =================================================================== --- /dev/null +++ b/backends/libebl_parisc.h @@ -0,0 +1,9 @@ +#ifndef _LIBEBL_HPPA_H +#define _LIBEBL_HPPA_H 1 + +#include + +extern int parisc_return_value_location_32(Dwarf_Die *, const Dwarf_Op **locp); +extern int parisc_return_value_location_64(Dwarf_Die *, const Dwarf_Op **locp); + +#endif Index: b/backends/Makefile.am =================================================================== --- a/backends/Makefile.am +++ b/backends/Makefile.am @@ -33,11 +33,11 @@ modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \ - tilegx + tilegx parisc libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \ libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \ libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \ - libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a + libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a libebl_parisc_pic.a noinst_LIBRARIES = $(libebl_pic) noinst_DATA = $(libebl_pic:_pic.a=.so) @@ -116,6 +116,9 @@ libebl_tilegx_pic_a_SOURCES = $(tilegx_SRCS) am_libebl_tilegx_pic_a_OBJECTS = $(tilegx_SRCS:.c=.os) +parisc_SRCS = parisc_init.c parisc_symbol.c parisc_regs.c parisc_retval.c +libebl_parisc_pic_a_SOURCES = $(parisc_SRCS) +am_libebl_parisc_pic_a_OBJECTS = $(parisc_SRCS:.c=.os) libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw) @rm -f $(@:.so=.map) Index: b/libelf/elf.h =================================================================== --- a/libelf/elf.h +++ b/libelf/elf.h @@ -1814,16 +1814,24 @@ #define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ #define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ #define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ +#define R_PARISC_DPREL14WR 19 +#define R_PARISC_DPREL14DR 20 #define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ #define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ #define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ #define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ #define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ +#define R_PARISC_DLTIND14F 39 +#define R_PARISC_SETBASE 40 #define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ +#define R_PARISC_BASEREL21L 42 +#define R_PARISC_BASEREL17R 43 +#define R_PARISC_BASEREL14R 46 #define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ #define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ #define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ #define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ +#define R_PARISC_PLTOFF14F 55 #define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ #define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ #define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ @@ -1832,6 +1840,7 @@ #define R_PARISC_PLABEL21L 66 /* Left 21 bits of fdesc address. */ #define R_PARISC_PLABEL14R 70 /* Right 14 bits of fdesc address. */ #define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ +#define R_PARISC_PCREL22C 73 #define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ #define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ #define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ @@ -1857,6 +1866,8 @@ #define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ #define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ #define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ +#define R_PARISC_BASEREL14WR 107 +#define R_PARISC_BASEREL14DR 108 #define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ #define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ #define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ debian/patches/CVE-2014-9447.patch0000664000000000000000000000300512456300761013250 0ustar From 147018e729e7c22eeabf15b82d26e4bf68a0d18e Mon Sep 17 00:00:00 2001 From: Alexander Cherepanov Date: Sun, 28 Dec 2014 19:57:19 +0300 Subject: libelf: Fix dir traversal vuln in ar extraction. read_long_names terminates names at the first '/' found but then skips one character without checking (it's supposed to be '\n'). Hence the next name could start with any character including '/'. This leads to a directory traversal vulnerability at the time the contents of the archive is extracted. The danger is mitigated by the fact that only one '/' is possible in a resulting filename and only in the leading position. Hence only files in the root directory can be written via this vuln and only when ar is executed as root. The fix for the vuln is to not skip any characters while looking for '/'. Signed-off-by: Alexander Cherepanov Origin: upstream, https://git.fedorahosted.org/cgit/elfutils.git/commit/?id=147018e729e7c22eeabf15b82d26e4bf68a0d18e Index: elfutils-0.158/libelf/elf_begin.c =================================================================== --- elfutils-0.158.orig/libelf/elf_begin.c 2015-01-16 15:26:06.934645584 -0600 +++ elfutils-0.158/libelf/elf_begin.c 2015-01-16 15:26:06.930645603 -0600 @@ -741,10 +741,7 @@ read_long_names (Elf *elf) break; /* NUL-terminate the string. */ - *runp = '\0'; - - /* Skip the NUL byte and the \012. */ - runp += 2; + *runp++ = '\0'; /* A sanity check. Somebody might have generated invalid archive. */ debian/patches/series0000664000000000000000000000066213107077432012044 0ustar redhat-portability.diff redhat-robustify.diff hppa_backend.diff arm_backend.diff mips_backend.diff m68k_backend.diff testsuite-ignore-elflint.diff scanf-format.patch mips_readelf_w.patch core-filename.diff CVE-2014-0172.patch CVE-2014-9447.patch CVE-2016-10254.patch CVE-2016-10255.patch CVE-2017-7607-1.patch CVE-2017-7607-2.patch CVE-2017-7608.patch CVE-2017-7610.patch CVE-2017-7611.patch CVE-2017-7612.patch CVE-2017-7613.patch debian/patches/core-filename.diff0000664000000000000000000000101612262576274014172 0ustar --- elfutils-0.158.orig/tests/backtrace-subr.sh +++ elfutils-0.158/tests/backtrace-subr.sh @@ -111,6 +111,11 @@ check_native_core() # Skip the test if we cannot adjust core ulimit. core="core.`ulimit -c unlimited || exit 77; set +ex; testrun ${abs_builddir}/$child --gencore; true`" + # see if /proc/sys/kernel/core_uses_pid is set to 0 + if [ -f core ]; then + mv core "$core" + fi + if [ ! -f "$core" ]; then exit 77; fi if [ "x$SAVED_VALGRIND_CMD" != "x" ]; then VALGRIND_CMD="$SAVED_VALGRIND_CMD" debian/patches/CVE-2017-7608.patch0000664000000000000000000000710013107076407013251 0ustar From b0b58c5e0b34e54194aa042f2310af58ee7de603 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 24 Mar 2017 14:10:26 +0100 Subject: [PATCH] Use the empty string for note names with zero size (without any data). ELF notes can have a zero sized name. In which case there is no data at all (so also no zero terminator). Make sure to use the empty string for such notes if the code does not otherwise explicitly check n_namesz. https://sourceware.org/bugzilla/show_bug.cgi?id=21300 Signed-off-by: Mark Wielaard Index: elfutils-0.158/libdwfl/linux-core-attach.c =================================================================== --- elfutils-0.158.orig/libdwfl/linux-core-attach.c +++ elfutils-0.158/libdwfl/linux-core-attach.c @@ -158,7 +158,8 @@ core_next_thread (Dwfl *dwfl __attribute &desc_offset)) > 0) { /* Do not check NAME for now, help broken Linux kernels. */ - const char *name = note_data->d_buf + name_offset; + const char *name = (nhdr.n_namesz == 0 + ? "" : note_data->d_buf + name_offset); const char *desc = note_data->d_buf + desc_offset; GElf_Word regs_offset; size_t nregloc; @@ -211,7 +212,8 @@ core_set_initial_registers (Dwfl_Thread /* __libdwfl_attach_state_for_core already verified the note is there. */ assert (getnote_err != 0); /* Do not check NAME for now, help broken Linux kernels. */ - const char *name = note_data->d_buf + name_offset; + const char *name = (nhdr.n_namesz == 0 + ? "" : note_data->d_buf + name_offset); const char *desc = note_data->d_buf + desc_offset; GElf_Word regs_offset; size_t nregloc; @@ -392,7 +394,8 @@ dwfl_core_file_attach (Dwfl *dwfl, Elf * &nhdr, &name_offset, &desc_offset)) > 0) { /* Do not check NAME for now, help broken Linux kernels. */ - const char *name = note_data->d_buf + name_offset; + const char *name = (nhdr.n_namesz == 0 + ? "" : note_data->d_buf + name_offset); const char *desc = note_data->d_buf + desc_offset; GElf_Word regs_offset; size_t nregloc; Index: elfutils-0.158/src/elfcmp.c =================================================================== --- elfutils-0.158.orig/src/elfcmp.c +++ elfutils-0.158/src/elfcmp.c @@ -413,7 +413,8 @@ main (int argc, char *argv[]) && (off1 = gelf_getnote (data1, off1, ¬e1, &name_offset, &desc_offset)) > 0) { - const char *name1 = data1->d_buf + name_offset; + const char *name1 = (note1.n_namesz == 0 + ? "" : data1->d_buf + name_offset); const void *desc1 = data1->d_buf + desc_offset; if (off2 >= data2->d_size) { @@ -429,7 +430,8 @@ main (int argc, char *argv[]) error (2, 0, gettext ("\ cannot read note section [%zu] '%s' in '%s': %s"), elf_ndxscn (scn2), sname2, fname2, elf_errmsg (-1)); - const char *name2 = data2->d_buf + name_offset; + const char *name2 = (note2.n_namesz == 0 + ? "" : data2->d_buf + name_offset); const void *desc2 = data2->d_buf + desc_offset; if (note1.n_namesz != note2.n_namesz Index: elfutils-0.158/src/readelf.c =================================================================== --- elfutils-0.158.orig/src/readelf.c +++ elfutils-0.158/src/readelf.c @@ -8912,7 +8912,7 @@ handle_notes_data (Ebl *ebl, const GElf_ && (offset = gelf_getnote (data, offset, &nhdr, &name_offset, &desc_offset)) > 0) { - const char *name = data->d_buf + name_offset; + const char *name = nhdr.n_namesz == 0 ? "" : data->d_buf + name_offset; const char *desc = data->d_buf + desc_offset; char buf[100]; debian/patches/CVE-2017-7610.patch0000664000000000000000000000154113107077436013250 0ustar From fb6709f1a41b58a9557ea45b7f53ae678c660b21 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 28 Mar 2017 13:33:03 +0200 Subject: [PATCH] elflint: Don't check section group without flags word. https://sourceware.org/bugzilla/show_bug.cgi?id=21320 Signed-off-by: Mark Wielaard Index: elfutils-0.158/src/elflint.c =================================================================== --- elfutils-0.158.orig/src/elflint.c +++ elfutils-0.158/src/elflint.c @@ -2496,9 +2496,12 @@ section [%2d] '%s': section size not mul idx, section_name (ebl, idx)); if (data->d_size < elsize) - ERROR (gettext ("\ + { + ERROR (gettext ("\ section [%2d] '%s': section group without flags word\n"), idx, section_name (ebl, idx)); + return; + } else if (be_strict) { if (data->d_size < 2 * elsize) debian/patches/CVE-2017-7607-1.patch0000664000000000000000000000674413107076376013430 0ustar From 6b246e0620bdbaf8240f3bf391ec773eea3f7f48 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 7 Nov 2014 12:54:02 +0100 Subject: [PATCH] readelf: Sanity check hash section contents before processing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported by: Hanno Böck Signed-off-by: Mark Wielaard Index: elfutils-0.158/src/readelf.c =================================================================== --- elfutils-0.158.orig/src/readelf.c +++ elfutils-0.158/src/readelf.c @@ -2909,8 +2909,21 @@ handle_sysv_hash (Ebl *ebl, Elf_Scn *scn return; } + if (unlikely (data->d_size < 2 * sizeof (Elf32_Word))) + { + invalid_data: + error (0, 0, gettext ("invalid data in sysv.hash section %d"), + (int) elf_ndxscn (scn)); + return; + } + Elf32_Word nbucket = ((Elf32_Word *) data->d_buf)[0]; Elf32_Word nchain = ((Elf32_Word *) data->d_buf)[1]; + + uint64_t used_buf = (2ULL + nchain + nbucket) * sizeof (Elf32_Word); + if (used_buf > data->d_size) + goto invalid_data; + Elf32_Word *bucket = &((Elf32_Word *) data->d_buf)[2]; Elf32_Word *chain = &((Elf32_Word *) data->d_buf)[2 + nbucket]; @@ -2951,8 +2964,21 @@ handle_sysv_hash64 (Ebl *ebl, Elf_Scn *s return; } + if (unlikely (data->d_size < 2 * sizeof (Elf64_Xword))) + { + invalid_data: + error (0, 0, gettext ("invalid data in sysv.hash64 section %d"), + (int) elf_ndxscn (scn)); + return; + } + Elf64_Xword nbucket = ((Elf64_Xword *) data->d_buf)[0]; Elf64_Xword nchain = ((Elf64_Xword *) data->d_buf)[1]; + + uint64_t used_buf = (2ULL + nchain + nbucket) * sizeof (Elf64_Xword); + if (used_buf > data->d_size) + goto invalid_data; + Elf64_Xword *bucket = &((Elf64_Xword *) data->d_buf)[2]; Elf64_Xword *chain = &((Elf64_Xword *) data->d_buf)[2 + nbucket]; @@ -2992,18 +3018,37 @@ handle_gnu_hash (Ebl *ebl, Elf_Scn *scn, return; } + if (unlikely (data->d_size < 4 * sizeof (Elf32_Word))) + { + invalid_data: + error (0, 0, gettext ("invalid data in gnu.hash section %d"), + (int) elf_ndxscn (scn)); + return; + } + Elf32_Word nbucket = ((Elf32_Word *) data->d_buf)[0]; Elf32_Word symbias = ((Elf32_Word *) data->d_buf)[1]; /* Next comes the size of the bitmap. It's measured in words for the architecture. It's 32 bits for 32 bit archs, and 64 bits for - 64 bit archs. */ + 64 bit archs. There is always a bloom filter present, so zero is + an invalid value. */ Elf32_Word bitmask_words = ((Elf32_Word *) data->d_buf)[2]; if (gelf_getclass (ebl->elf) == ELFCLASS64) bitmask_words *= 2; + if (bitmask_words == 0) + goto invalid_data; + Elf32_Word shift = ((Elf32_Word *) data->d_buf)[3]; + /* Is there still room for the sym chain? + Use uint64_t calculation to prevent 32bit overlow. */ + uint64_t used_buf = (4ULL + bitmask_words + nbucket) * sizeof (Elf32_Word); + uint32_t max_nsyms = (data->d_size - used_buf) / sizeof (Elf32_Word); + if (used_buf > data->d_size) + goto invalid_data; + uint32_t *lengths = (uint32_t *) xcalloc (nbucket, sizeof (uint32_t)); Elf32_Word *bitmask = &((Elf32_Word *) data->d_buf)[4]; @@ -3023,6 +3068,8 @@ handle_gnu_hash (Ebl *ebl, Elf_Scn *scn, ++nsyms; if (maxlength < ++lengths[cnt]) ++maxlength; + if (inner > max_nsyms) + goto invalid_data; } while ((chain[inner++] & 1) == 0); } debian/patches/CVE-2017-7612.patch0000664000000000000000000000632713107104015013241 0ustar From 61fe61898747f63eb35a81c2261f3590a3dab8fd Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 28 Mar 2017 00:38:52 +0200 Subject: [PATCH] elflint: Don't trust sh_entsize when checking hash sections. Calculate and use the expected entsize instead of relying on the one given by the ELF file section header. Return early if there isn't enough data in the section to check the full hash table. https://sourceware.org/bugzilla/show_bug.cgi?id=21311 Signed-off-by: Mark Wielaard Index: elfutils-0.158/src/elflint.c =================================================================== --- elfutils-0.158.orig/src/elflint.c +++ elfutils-0.158/src/elflint.c @@ -1969,11 +1969,14 @@ check_sysv_hash (Ebl *ebl, GElf_Shdr *sh Elf32_Word nbucket = ((Elf32_Word *) data->d_buf)[0]; Elf32_Word nchain = ((Elf32_Word *) data->d_buf)[1]; - if (shdr->sh_size < (2 + nbucket + nchain) * shdr->sh_entsize) - ERROR (gettext ("\ + if (shdr->sh_size < (2 + nbucket + nchain) * sizeof (Elf32_Word)) + { + ERROR (gettext ("\ section [%2d] '%s': hash table section is too small (is %ld, expected %ld)\n"), - idx, section_name (ebl, idx), (long int) shdr->sh_size, - (long int) ((2 + nbucket + nchain) * shdr->sh_entsize)); + idx, section_name (ebl, idx), (long int) shdr->sh_size, + (long int) ((2 + nbucket + nchain) * sizeof (Elf32_Word))); + return; + } size_t maxidx = nchain; @@ -2020,11 +2023,14 @@ check_sysv_hash64 (Ebl *ebl, GElf_Shdr * Elf64_Xword nbucket = ((Elf64_Xword *) data->d_buf)[0]; Elf64_Xword nchain = ((Elf64_Xword *) data->d_buf)[1]; - if (shdr->sh_size < (2 + nbucket + nchain) * shdr->sh_entsize) - ERROR (gettext ("\ + if (shdr->sh_size < (2 + nbucket + nchain) * sizeof (Elf64_Xword)) + { + ERROR (gettext ("\ section [%2d] '%s': hash table section is too small (is %ld, expected %ld)\n"), - idx, section_name (ebl, idx), (long int) shdr->sh_size, - (long int) ((2 + nbucket + nchain) * shdr->sh_entsize)); + idx, section_name (ebl, idx), (long int) shdr->sh_size, + (long int) ((2 + nbucket + nchain) * sizeof (Elf64_Xword))); + return; + } size_t maxidx = nchain; @@ -2233,10 +2239,12 @@ section [%2d] '%s': relocatable files ca section [%2d] '%s': hash table not for dynamic symbol table\n"), idx, section_name (ebl, idx)); - if (shdr->sh_entsize != (tag == SHT_GNU_HASH + size_t expect_entsize = (tag == SHT_GNU_HASH ? (gelf_getclass (ebl->elf) == ELFCLASS32 ? sizeof (Elf32_Word) : 0) - : (size_t) ebl_sysvhash_entrysize (ebl))) + : (size_t) ebl_sysvhash_entrysize (ebl)); + + if (shdr->sh_entsize != expect_entsize) ERROR (gettext ("\ section [%2d] '%s': hash table entry size incorrect\n"), idx, section_name (ebl, idx)); @@ -2245,7 +2253,7 @@ section [%2d] '%s': hash table entry siz ERROR (gettext ("section [%2d] '%s': not marked to be allocated\n"), idx, section_name (ebl, idx)); - if (shdr->sh_size < (tag == SHT_GNU_HASH ? 4 : 2) * (shdr->sh_entsize ?: 4)) + if (shdr->sh_size < (tag == SHT_GNU_HASH ? 4 : 2) * (expect_entsize ?: 4)) { ERROR (gettext ("\ section [%2d] '%s': hash table has not even room for initial administrative entries\n"), debian/patches/CVE-2017-7611.patch0000664000000000000000000000170013107077442013243 0ustar From 9a0d9d314a6342b56e3277bd7ad7ecb6e73a7d38 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 27 Mar 2017 23:59:02 +0200 Subject: [PATCH] elflint: Check symbol table data is big enough before checking. Before checking symbol index zero we should make sure the data size is big enough. https://sourceware.org/bugzilla/show_bug.cgi?id=21310 Signed-off-by: Mark Wielaard Index: elfutils-0.158/src/elflint.c =================================================================== --- elfutils-0.158.orig/src/elflint.c +++ elfutils-0.158/src/elflint.c @@ -1935,7 +1935,8 @@ section [%2d] '%s': extended section ind return; } - if (*((Elf32_Word *) data->d_buf) != 0) + if (data->d_size < sizeof (Elf32_Word) + || *((Elf32_Word *) data->d_buf) != 0) ERROR (gettext ("symbol 0 should have zero extended section index\n")); for (size_t cnt = 1; cnt < data->d_size / sizeof (Elf32_Word); ++cnt) debian/libasm1.symbols0000664000000000000000000000026011177064432012135 0ustar libasm.so.1 libasm1 #MINVER# *@ELFUTILS_1.0 0.120 disasm_begin@ELFUTILS_1.0 0.132 disasm_cb@ELFUTILS_1.0 0.132 disasm_end@ELFUTILS_1.0 0.132 disasm_str@ELFUTILS_1.0 0.132 debian/libelf1.install0000664000000000000000000000007611721766100012102 0ustar usr/lib/*/libelf.so.1 usr/lib/*/libelf-*.so usr/share/locale/ debian/libdw1.install0000664000000000000000000000010011721766100011732 0ustar usr/lib/*/libdw.so.1 usr/lib/*/libdw-0.*.so usr/lib/*/elfutils/ debian/compat0000664000000000000000000000000211721766100010367 0ustar 9 debian/libelf-dev.install0000664000000000000000000000024711721766100012575 0ustar usr/include/libelf.h usr/include/gelf.h usr/include/nlist.h usr/include/elfutils/elf-knowledge.h usr/include/elfutils/version.h usr/lib/*/libelf.a usr/lib/*/libelf.so debian/test-expected.ppc64el0000664000000000000000000000007312265153732013153 0ustar FAIL: run-backtrace-dwarf.sh FAIL: run-backtrace-native.sh debian/changelog0000664000000000000000000004723013107160060011042 0ustar elfutils (0.158-0ubuntu5.3) trusty-security; urgency=medium * SECURITY UPDATE: Denial of service via invalid memory read when handling crafted ELF files - debian/patches/CVE-2016-10254.patch: Always set ELF maxsize when reading an ELF file for sanity checks. Based on upstream patch. - CVE-2016-10254 * SECURITY UPDATE: Denial of service via memory consumption when handling crafted ELF files - debian/patches/CVE-2016-10255.patch: Sanity check offset and size before trying to malloc and read data. Based on upstream patch. - CVE-2016-10255 * SECURITY UPDATE: Denial of service via invalid memory read when handling crafted ELF files - debian/patches/CVE-2017-7607-1.patch: Sanity check hash section contents before processing. Based on upstream patch. - debian/patches/CVE-2017-7607-2.patch: Fix off by one sanity check in handle_gnu_hash. Based on upstream patch. - CVE-2017-7607 * SECURITY UPDATE: Denial of service via invalid memory read when handling crafted ELF files - debian/patches/CVE-2017-7608.patch: Use the empty string for note names with zero size. Based on upstream patch. - CVE-2017-7608 * SECURITY UPDATE: Denial of service via invalid memory read when handling crafted ELF files - debian/patches/CVE-2017-7610.patch: Don't check section group without flags word. Based on upstream patch. - CVE-2017-7610 * SECURITY UPDATE: Denial of service via invalid memory read when handling crafted ELF files - debian/patches/CVE-2017-7611.patch: Check symbol table data is big enough before checking. Based on upstream patch. - CVE-2017-7611 * SECURITY UPDATE: Denial of service via invalid memory read when handling crafted ELF files - debian/patches/CVE-2017-7612.patch: Don't trust sh_entsize when checking hash sections. Based on upstream patch. - CVE-2017-7612 * SECURITY UPDATE: Denial of service via memory consumption when handling crafted ELF files - debian/patches/CVE-2017-7613.patch: Sanity check the number of phdrs and shdrs available. Based on upstream patch. - CVE-2017-7613 -- Tyler Hicks Wed, 17 May 2017 23:27:15 +0000 elfutils (0.158-0ubuntu5.2) trusty-security; urgency=medium * SECURITY UPDATE: Directory traversal via crafted ar archive - debian/patches/CVE-2014-9447.patch: Prevent root directory traversal while extracting ar archives - CVE-2014-9447 -- Tyler Hicks Tue, 20 Jan 2015 15:22:53 -0600 elfutils (0.158-0ubuntu5.1) trusty-security; urgency=medium * SECURITY UPDATE: denial of service and possible code execution in libdw via malicious ELF file - debian/patches/CVE-2014-0172.patch: check for overflow in libdw/dwarf_begin_elf.c. - CVE-2014-0172 -- Marc Deslauriers Tue, 15 Apr 2014 14:39:39 -0400 elfutils (0.158-0ubuntu5) trusty; urgency=medium * debian/rules: force -O2 to work around build failure with -O3. -- Adam Conrad Mon, 17 Feb 2014 12:56:43 -0700 elfutils (0.158-0ubuntu4) trusty; urgency=medium * Show test-suite log and logs of failing tests in case of failures. -- Matthias Klose Tue, 14 Jan 2014 09:50:09 +0100 elfutils (0.158-0ubuntu3) trusty; urgency=medium * Ignore run-backtrace-native.sh and run-backtrace-dwarf.sh test failures on powerpc and ppc64el. See LP #1268847. -- Matthias Klose Tue, 14 Jan 2014 07:27:16 +0100 elfutils (0.158-0ubuntu2) trusty; urgency=medium * Fix test cases, when /proc/sys/kernel/core_uses_pid is set to 0. -- Matthias Klose Mon, 06 Jan 2014 19:55:50 +0100 elfutils (0.158-0ubuntu1) trusty; urgency=medium * New upstream version, adding AArch64 support. -- Matthias Klose Mon, 06 Jan 2014 12:37:48 +0100 elfutils (0.157-3) unstable; urgency=low * Build-Depend on gcc-multilib on [any-amd64] instead of [amd64] -- Kurt Roeckx Sun, 17 Nov 2013 22:54:31 +0100 elfutils (0.157-2) unstable; urgency=low * Application in the readelf binary package, libdw1 itself use internal APIs from libelf and so need a strict dependency on the same libelf1 binary package. libasm1 also needs a strict dependency on libdw1 since it uses libebl.a and so uses the MODVERSION to openthe backends. The dependency from libasm1 to libdw1 was missing. Disabling the thread safety resulted in struct Elf's size changing causing things like eu-readelf to break when an older libelf1 was installed. * Apply patch from upstream to fix the IA64 regression failure with a powerpc binary -- Kurt Roeckx Sun, 03 Nov 2013 15:20:06 +0100 elfutils (0.157-1) unstable; urgency=low * New upstream release - Update portability and robustify patch - Make arm_backend.diff apply to the new upstream version - Adjust symbol files for new symbols * Adjust addrcfi test results for arm to work with our arm patch. -- Kurt Roeckx Tue, 01 Oct 2013 18:21:23 +0200 elfutils (0.156-1) unstable; urgency=low * New upstream release - Update portability and robustify patch - Make hppa_backend.diff, arm_backend.diff, mips_backend.diff, m68k_backend.diff, testsuite-ignore-elflint apply to the new upstream version - Drop patches elf_end_unlock.patch, alldts.patch, strip_sh_type.patch: applied upstream - Works with binutils-gold (Closes: #647359) - Works with gcc 4.8 (Closes: #701271) * drop elf_additions.diff, it's not used. * Remove config.h.in and test-driver during clean (Closes: #695927) * Add build dependency on gcc-multilib [amd64] to have a working gcc -m32 for the test suite. * arm backend: change r12 back to signed, no idea why it was made unsigned. * arm backend: rename the "special" set to "state". * Our arm backend patch adds more registers, update the arm_backend.diff to expectd those changes in the test suite * disable thread safety, it's not tested upstream. * Update libdw1.symbols -- Kurt Roeckx Sun, 28 Jul 2013 14:32:23 +0200 elfutils (0.153-2) unstable; urgency=low * Make it actually build properly using build-arch. (Closes: #684528) * Call rwlock_unlock() before rwlock_fini(). The lock was still held causing problems on kfreebsd. (Closes: #662041) * Don't exclude sh_type >= SHT_NUM from stripping, it's set to SHT_MIPS_DWARF on mips. (Closes: #662041) * readelf -w didn't show the content of debug sections on mips because sh_type was set to SHT_MIPS_DWARF. -- Kurt Roeckx Tue, 18 Sep 2012 21:12:08 +0200 elfutils (0.153-1) unstable; urgency=low [ Jonathan Nieder ] * Run autotools at build time. - debian/control: Build-Depends: autoconf, automake. - debian/rules: - config.status: - depend on configure.ac, not configure. - autoreconf -fis. - clean: remove autotools-generated files to avoid .diff.gz changes when built twice in a row. - debian/patches: remove do-autoreconf.diff. [ Marcin Juszkiewicz ] * Convert to multiarch. (Closes: #657139) * Added build-{arch,indep} targets. * Switched to use 'dh_prep' instead of 'dh_clean -k' [ Kurt Roeckx ] * New upstream release - Portability patch has workaround for broken bswap_32 macro. This should also have been fixed in glibc code. (Closes: #595496) - Fix bashism in configure script (Closes: #647350) * Remove Christian Aichinger from uploaders (Closes: #661119) * Make the m68k port functional, thanks to a patch from Thorsten Glaser (Patch in #595496, #384794) * Fix test suite to set up test environment (alldts.patch). * Use dpkg-buildflags. Build-Depend on dpkg-dev (>= 1.16.1~) for buildflags.mk. * Call configure with --enable-maintainer-mode so all files get regenerated Also add Build-Depends on gawk for this to work. * Revert %m[ to %a[ change in addr2line and line2addr from the portability patch. * Clean up more files (Makefile.in, libdw/known-dwarf.h) * Set libdir to the multiarch dir, so that the rpath gets set up correctly and that we don't have to move the files in the rules file. -- Kurt Roeckx Fri, 24 Feb 2012 20:23:08 +0100 elfutils (0.152-1) unstable; urgency=low * New upstream release - Update portability and robustify patch. - Update symbol file for libdw1, 2 new functions. * Remove obsolete files from the debian dir. * Update watch file to work with newer versions. -- Kurt Roeckx Wed, 08 Sep 2010 19:54:20 +0200 elfutils (0.148-1) unstable; urgency=low * New upstream release - Drop debug_filename.patch, applied upstream. - New symbols in libdw1, update symbols file. -- Kurt Roeckx Sat, 03 Jul 2010 15:01:59 +0200 elfutils (0.147-2) unstable; urgency=low * Open the proper file with debug info in case they have the same name. (Closes: #555549) -- Kurt Roeckx Thu, 17 Jun 2010 18:38:27 +0200 elfutils (0.147-1) unstable; urgency=low * New upstream release -- Kurt Roeckx Mon, 24 May 2010 10:49:05 +0200 elfutils (0.146-1) unstable; urgency=low * New upstream release - adds better support for the sh arch - Add build-depedency on liblzma-dev - Add build-depedency on gettext - Add tanslations to libelf1. All packges making use of those files depend on it. - New symbols dwfl_core_file_report in libdw1, update symbol file. * Call configure with --enable-thread-safety -- Kurt Roeckx Sat, 24 Apr 2010 11:55:24 +0200 elfutils (0.145-1) unstable; urgency=low * New upstream release * Make elfutils depend libdw1 (= ${binary:Version}). The static libebl.a that it used by the applications in changes MODVERSION on rebuild. It's the only thing making use of libebl.a -- Kurt Roeckx Wed, 24 Feb 2010 19:36:07 +0100 elfutils (0.144-1) unstable; urgency=low * New upstream version - Fixes segfault in systemtap (Closes: #556133) - Remove elflint-comment.diff and nobits.diff, applied upstream. - dwarf_aggregate_size got added in libdw1, elf_getphdrnum got added to libelf: update symbol file. * Switch to dpkg-source 3.0 (quilt) format * hppa: Use dwarf_aggregate_size(). * Add ${misc:Depends} to all packages * Change Standards-Version to 3.8.4, no changes required. -- Kurt Roeckx Mon, 15 Feb 2010 23:27:18 +0100 elfutils (0.143-2) unstable; urgency=low * Prevent segfault from debug only files. (Closes: #556133) -- Kurt Roeckx Mon, 16 Nov 2009 18:22:43 +0100 elfutils (0.143-1) unstable; urgency=low * New upstream release. - Upstream added new symbols in libdw1, adjust symbol file. * Remove the fix-bswap-warnings.diff and pointer_cast.diff patch, they weren't used anyway. * Remove posix_fadvise.diff and namelen.diff, applied upstream. * Add elflint-comment.diff, from upstream git. Fixes a regression suite error with newer binutils. -- Kurt Roeckx Mon, 21 Sep 2009 21:06:21 +0000 elfutils (0.142-1) unstable; urgency=low * New upstream version * Provide a static version of libdw. Do not use it unless you know what you're doing. (Closes: #538375) * Replace elf_getshstrndx by elf_getshdrstrndx in the mips backend. elf_getshstrndx has been deprecated. * Upstream added new symbols, adjust symbol files. -- Kurt Roeckx Fri, 14 Aug 2009 13:56:30 +0200 elfutils (0.141-2) unstable; urgency=low * Make libdw-dev Depend on libdw1 (Closes: #526824) -- Kurt Roeckx Sun, 03 May 2009 22:07:59 +0200 elfutils (0.141-1) unstable; urgency=low * New upstream release - Update redhat-robustify.diff and redhat-portability.diff - Remove redhat-strip-copy-symtab.diff, does not seem to be used anymore. Also remove things in the rules file that deal with it, and drop sharutils from build-depends. - Remove elflint_initialization.diff, unaligned.diff, pointer_cast.diff, gnu_inline.diff, readelf_subelf.diff, gcc-4.3_support: applied or fixed some other way upstream * Update watch file to new location. * Make libasm-dev conflict with libasm0-dev (Closes: #509042) * Create a shared version of libdw, and move libebl's file in the libdw1 package. Drop the static versions of libdw and libebl. There is no libebl-dev anymore. (Closes: #457543) * Add elfutils/version.h to libelf-dev * Run test suite with LC_CTYPE=C, to have the same sort ordering. * Add Build-Dependency on zlib1g-dev, libbz2-dev and m4. * Start using dpkg-gensymbols: - libasm1: Upstream added disasm_begin, disasm_cb, disasm_end and disasm_str to ELFUTILS_1.0 in 0.132, the others are there since 0.120. - libelf1: ELFUTILS_1.2 was added in 0.122, ELFUTILS_1.3 in 0.130 and ELFUTILS_1.4 in 0.132. gelf_rawchunk and gelf_freechunk got removed in 0.131. - libdw1: Versions are when get got introduced. dwarf_getelf was removed from ELFUTILS_0.122 and changed to ELFUTILS_0.126 in 0.126 * libasm1 and libelf1 added new functions, bump shlibs * Update Standards-Version to 3.8.1 - Change ${Source-Version} to ${binary:Version} - Add support for DEB_BUILD_OPTIONS nocheck - Add upstream Homepage * Don't use -$(MAKE) distclean * Remove debian/dirs file. -- Kurt Roeckx Sat, 02 May 2009 16:30:39 +0200 elfutils (0.131-4) unstable; urgency=low * Move static functions the only file that uses it. Avoids warning using gcc-4.3. Thanks to Maximiliano Curia for the patch. (Closes: #467103) -- Kurt Roeckx Sat, 05 Apr 2008 13:40:13 +0000 elfutils (0.131-3) unstable; urgency=low * Add m68k backend. * Fix copyright file to point to /usr/share/common-licenses/GPL-2 -- Kurt Roeckx Wed, 26 Dec 2007 19:53:09 +0100 elfutils (0.131-2) unstable; urgency=low * Bump shlibs for libelf1 since it added new functions. -- Kurt Roeckx Mon, 17 Dec 2007 18:33:45 +0100 elfutils (0.131-1) unstable; urgency=low * New usptream version. (Closes: #455878) - ebl_core_note() changed function arguments. - libelf: Add functions: gelf_getauxv(), gelf_update_auxv(), gelf_getnote(), elf_getdata_rawchunk(). removed gelf_rawchunk(), gelf_freechunk() - Changed some types from off_t to off64_t. The library was always build with LFS, so it's just a correction of the types. * merge patches * arm, hppa and mips backend: Use dwarf_attr_integrate() instead of dwarf_attr(), and dwarf_hasattr_integrate() instead of dwarf_hasattr(). * Add patch from Aurelien Jarno to support GNU/kFreeBSD (Closes: #452428) -- Kurt Roeckx Sat, 15 Dec 2007 20:31:14 +0100 elfutils (0.128-1) unstable; urgency=low * New upstream release: Remove patch alpha_backend_regs.diff, upstream implemented it themself (with the aliases for the register names). * Make libasm-dev conflict with libelfsh0-dev again, the 0.123-3 change got lost. (Closes: #404054) * First cast main to an intptr_t before casting it to a 64 bit int. Directly casting from a pointer to 64 bit int gives a warning on 32 bit systems (with gcc-4.2). (Closes: #431455) * Also check for /proc/$$. -- Kurt Roeckx Sun, 08 Jul 2007 19:28:46 +0000 elfutils (0.127-4) unstable; urgency=low * Use the gnu_inline attribute for inline functions so it build with gcc-4.2. (Closes: #424548) * Add check for maps and auxv file in the proc dir to try and debug the sparc build failure. -- Kurt Roeckx Fri, 18 May 2007 13:41:35 +0200 elfutils (0.127-3) unstable; urgency=low * Update unaligned patch to also work when we're using -O2. -- Kurt Roeckx Sun, 13 May 2007 22:48:57 +0200 elfutils (0.127-2) unstable; urgency=low * Remove duplicate initialization of DT_PLTRELSZ in elflint. (Closes: #393812) * Only using posix_fadvise() when we have POSIX_FADV_SEQUENTIAL since some arches like kFreeBSD don't support it. (Closes: #404091) * Fix unaligned accesses on IA64. Added patch unaligned.diff. -- Kurt Roeckx Sun, 13 May 2007 18:12:01 +0200 elfutils (0.127-1) unstable; urgency=low * New upstream release: Remove patches applied upstream: fix-testsuite.diff, maintainer_mode.diff, fix-distclean-to-really-distclean.diff, sparc_retval-backend.diff, elflint-alpha.diff, fix-readelf.diff, fix-alignment-sparc.diff, native-pid.diff, unalligned-endian.diff * register_name() got replaced by register_info(). Update backends to add dwarf type and number of bits info for those backends: alpha, arm, hppa, mips * Added redhat-strip-copy-symtab.diff patch. Inlucde testfile16.symtab.bz2 and testfile16.symtab.debug.bz2 test files. Add sharutils to build-depends for uudecode. * Updated redhat-portability.diff: Now includes fix-mipsel-ftbfs.diff so remove it. * Add various types to elf.h * Update watch file to use a different url. -- Kurt Roeckx Sat, 5 May 2007 15:59:46 +0200 elfutils (0.123-2) unstable; urgency=low [ Kurt Roeckx ] * Add backend support for alpha: adding the registers. * Add backend support for arm: adding regs and retval. Thanks to Eugeniy Meshcheryakov * Add backend support for hppa, thanks to Eugeniy Meshcheryakov * Add some missing ELFOSABI_* and EM_* to elf.h [ Christian Aichinger ] * Fix sparc backend retval * Add mips backend. * Rewrite the static backend so making changes to the backends is easier. -- Kurt Roeckx Sun, 27 Aug 2006 15:48:23 +0000 elfutils (0.123-1) unstable; urgency=low * New upstream release - Add IA64 backend support - Remove redhat-fix-cast.diff, applied upstream - Make patches apply to new upstream version. * Include configure and all Makefile.in's in the configure patch. -- Kurt Roeckx Tue, 15 Aug 2006 19:42:44 +0000 elfutils (0.122-4) unstable; urgency=low [ Kurt Roeckx ] * The backends init functions should be functions, not pointers to functions. Also thanks to Eugeniy Meshcheryakov for pointing out the same. This should fix the segmentation faults seen on ia64. * When doing x && y &, bash retuns the pid for x, while the script expected the one for y. Other shells I've tried return that of y. As a result the run-native-test.sh keeps a "native" process running. Removed the &&, so it always gets the correct pid. (Closes: #382758) * Fix endiannes problems for opening files of your own endiannes when not avoiding unaligned access. This didn't affect i386 and amd64. -- Kurt Roeckx Sun, 13 Aug 2006 15:08:32 +0000 elfutils (0.122-3) unstable; urgency=low [ Kurt Roeckx ] * Add build dependency on bzip2, so that all the regression tests can run. * elflint: Add EM_ALPHA to valid_e_machine. [ Christian Aichinger] * Add retval to the sparc backend. * Ignore testsuite failures that elflint reports. * readelf should check destshdr instead of shdr. * Fix alignment problems in libdw_alloc seen on sparc. -- Kurt Roeckx Wed, 9 Aug 2006 19:21:05 +0000 elfutils (0.122-2) unstable; urgency=low * Make libelf-dev Conflict with libelfg0-dev since they both ship the same library and headers. -- Kurt Roeckx Fri, 4 Aug 2006 19:38:32 +0000 elfutils (0.122-1) unstable; urgency=low * Initial release (Closes: #368248) -- Kurt Roeckx Sun, 21 May 2006 15:03:01 +0000 debian/libasm1.install0000664000000000000000000000005411721766100012110 0ustar usr/lib/*/libasm.so.1 usr/lib/*/libasm-*.so debian/libelf1.symbols0000664000000000000000000000031711337307261012124 0ustar libelf.so.1 libelf1 #MINVER# *@ELFUTILS_1.0 0.131 *@ELFUTILS_1.1 0.131 *@ELFUTILS_1.1.1 0.131 *@ELFUTILS_1.2 0.131 *@ELFUTILS_1.3 0.131 *@ELFUTILS_1.4 0.132 *@ELFUTILS_1.5 0.142 *@ELFUTILS_1.6 0.144 debian/elfutils.install0000664000000000000000000000001011155535207012402 0ustar usr/bin debian/copyright0000664000000000000000000001221611241251615011123 0ustar This package was debianized by Kurt Roeckx on Sun, 21 May 2006 15:03:01 +0000. It was downloaded from https://fedorahosted.org/releases/e/l/elfutils/ It was original a .tar.bz2. It has been decompressed and recompressed again using gzip. Copyright Holder: Copyright (C) 2000 - 2009 Red Hat, Inc. Written by: Ulrich Drepper Jeff Johnson Alexander Larsson Jakub Jelinek Roland McGrath License: Most of the libraries (lib, libelf, libebl, libdw, libdwfl) have the following license: Red Hat elfutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. Red Hat elfutils is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Red Hat elfutils; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. In addition, as a special exception, Red Hat, Inc. gives You the additional right to link the code of Red Hat elfutils with code licensed under any Open Source Initiative certified open source license (http://www.opensource.org/licenses/index.php) which requires the distribution of source code with any binary distribution and to distribute linked combinations of the two. Non-GPL Code permitted under this exception must only link to the code of Red Hat elfutils through those well defined interfaces identified in the file named EXCEPTION found in the source code files (the "Approved Interfaces"). The files of Non-GPL Code may instantiate templates or use macros or inline functions from the Approved Interfaces without causing the resulting work to be covered by the GNU General Public License. Only Red Hat, Inc. may make changes or additions to the list of Approved Interfaces. Red Hat's grant of this exception is conditioned upon your not adding any new exceptions. If you wish to add a new Approved Interface or exception, please contact Red Hat. You must obey the GNU General Public License in all respects for all of the Red Hat elfutils code and other code used in conjunction with Red Hat elfutils except the Non-GPL Code covered by this exception. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to provide this exception without modification, you must delete this exception statement from your version and license this file solely under the GPL without exception. Red Hat elfutils is an included package of the Open Invention Network. An included package of the Open Invention Network is a package for which Open Invention Network licensees cross-license their patents. No patent license is granted, either expressly or impliedly, by designation as an included package. Should you wish to participate in the Open Invention Network licensing program, please visit www.openinventionnetwork.com . The EXCEPTION file contains: This file describes the limits of the Exception under which you are allowed to distribute Non-GPL Code in linked combination with Red Hat elfutils. For the full text of the license, please see one of the header files included with the source distribution or the file COPYING found in the top level directory of the source. The Approved Interfaces are the functions declared in the files: libelf.h libdw.h libdwfl.h The other files are covered by the following license: Red Hat elfutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. Red Hat elfutils is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Red Hat elfutils; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. Red Hat elfutils is an included package of the Open Invention Network. An included package of the Open Invention Network is a package for which Open Invention Network licensees cross-license their patents. No patent license is granted, either expressly or impliedly, by designation as an included package. Should you wish to participate in the Open Invention Network licensing program, please visit www.openinventionnetwork.com . On Debian GNU/Linux systems, the complete text of the GNU General Public License version 2 can be found in `/usr/share/common-licenses/GPL-2'. debian/watch0000664000000000000000000000027711532202647010231 0ustar # Watch control file for uscan # See uscan(1) for format # Compulsory line, this is a version 3 file version=3 https://fedorahosted.org/releases/e/l/elfutils/(\d.\d*)/elfutils-(.*).tar.bz2 debian/source/0000775000000000000000000000000011336345101010465 5ustar debian/source/format0000664000000000000000000000001411336345101011673 0ustar 3.0 (quilt) debian/libdw-dev.install0000664000000000000000000000016511721766100012440 0ustar usr/include/dwarf.h usr/include/elfutils/libdw.h usr/include/elfutils/libdwfl.h usr/lib/*/libdw.so usr/lib/*/libdw.a debian/rules0000775000000000000000000001165012300464751010255 0ustar #!/usr/bin/make -f # -*- makefile -*- # Copyright 2006, Kurt Roeckx # Based on the sample file from dh-make: # Sample debian/rules that uses debhelper. # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # These are used for cross-compiling and for saving the configure script # from having to guess our platform (since we know it already) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) confflags += --build=$(DEB_HOST_GNU_TYPE) make_check = yes else confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) make_check = no endif ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) make_check = no endif DPKG_EXPORT_BUILDFLAGS = 1 include /usr/share/dpkg/buildflags.mk CFLAGS := $(subst -O3,-O2,$(CFLAGS)) config.status: configure.ac dh_testdir autoreconf -fis CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" \ ./configure $(confflags) --prefix=/usr \ --libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \ --enable-maintainer-mode \ --program-prefix=eu- build: build-stamp build-stamp: config.status dh_testdir $(MAKE) ifeq ($(make_check), yes) # Check that those files exist. -ls -l /proc/$$$$/maps -ls -l /proc/$$$$/auxv -ls -l /proc/$$$$/ LC_CTYPE=C $(MAKE) check 2>&1 | tee test.log rv=0; \ fails=$$(awk '/^# FAIL:/ { print $$3 }' test.log); \ if [ "$$fails" -eq 0 ]; then \ echo "all tests did pass on $(DEB_HOST_ARCH)"; \ else \ if [ -f debian/test-expected.$(DEB_HOST_ARCH) ]; then \ cp debian/test-expected.$(DEB_HOST_ARCH) test-expected.log; \ else \ rm -f test-expected.log; touch test-expected.log; \ fi; \ grep '^FAIL: ' test.log | sort > test-fail.log; \ comm -13 test-expected.log test-fail.log > test-regress.log; \ comm -23 test-expected.log test-fail.log > test-progress.log; \ if [ -z "$$(cat test-regress.log)" ]; then \ echo "expected test failures on $(DEB_HOST_ARCH)"; \ if [ -n "$$(cat test-progress.log)" ]; then \ echo "unexpected test progressions on $(DEB_HOST_ARCH)"; \ cat test-progress.log; \ fi; \ else \ echo "unexpected test failures on $(DEB_HOST_ARCH)"; \ cat test-regress.log; \ rv=1; \ fi; \ if [ -n "$$(cat test-fail.log)" ]; then \ for t in $$(awk '{print $$2}' test-fail.log); do \ echo "=============== $$t ==============="; \ cat tests/$$t.log; \ done; \ echo "=============== tests/test-suite.log ==============="; \ cat tests/test-suite.log; \ fi; \ fi; \ exit $$rv endif touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp [ ! -f Makefile ] || $(MAKE) distclean rm -f configure version.h rm -f INSTALL aclocal.m4 rm -f config/depcomp config/install-sh config/missing config/compile config/ylwrap rm -f config/config.guess config/config.sub elfutils.spec rm -f config.h.in rm -f config/test-driver rm -rf autom4te.cache rm -f rm Makefile.in backends/Makefile.in config/Makefile.in lib/Makefile.in libasm/Makefile.in libcpu/Makefile.in libdw/Makefile.in libdwfl/Makefile.in libebl/Makefile.in libelf/Makefile.in m4/Makefile.in src/Makefile.in tests/Makefile.in rm -f libdw/known-dwarf.h rm -f test*.log dh_clean install: build dh_testdir dh_testroot dh_prep dh_installdirs # Add here commands to install the package into debian/tmp $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp # We do not provide a libebl anymore, use libdw instead. rm debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libebl.a rm debian/tmp/usr/include/elfutils/libebl.h # Build architecture-independent files here. build-indep: build binary-indep: build-indep install # We have nothing to do. # Build architecture-dependent files here. build-arch: build binary-arch: build-arch install dh_testdir dh_testroot dh_installchangelogs ChangeLog dh_installdocs dh_install --fail-missing --sourcedir=debian/tmp dh_strip dh_compress dh_fixperms dpkg-gensymbols -Pdebian/libdw1/ -plibdw1 -c4 dpkg-gensymbols -Pdebian/libasm1/ -plibasm1 -c4 dpkg-gensymbols -Pdebian/libelf1/ -plibelf1 -c4 dh_makeshlibs -plibelf1 -V "libelf1 (>= 0.132)" dh_makeshlibs -plibasm1 -V "libasm1 (>= 0.132)" dh_makeshlibs -plibdw1 -V "libdw1 (>= 0.138)" dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch maint-unpatch: bash debian/unpatch.sh debian/patches .PHONY: build clean binary-indep binary-arch binary install maint-unpatch debian/libasm-dev.install0000664000000000000000000000010511721766100012600 0ustar usr/include/elfutils/libasm.h usr/lib/*/libasm.a usr/lib/*/libasm.so debian/test-expected.powerpc0000664000000000000000000000007312265153722013354 0ustar FAIL: run-backtrace-dwarf.sh FAIL: run-backtrace-native.sh debian/libdw1.symbols0000664000000000000000000000062712262514526011776 0ustar libdw.so.1 libdw1 #MINVER# *@ELFUTILS_0.122 0.126 *@ELFUTILS_0.126 0.126 *@ELFUTILS_0.127 0.127 *@ELFUTILS_0.130 0.130 *@ELFUTILS_0.136 0.136 *@ELFUTILS_0.138 0.138 *@ELFUTILS_0.142 0.142 *@ELFUTILS_0.143 0.143 *@ELFUTILS_0.144 0.144 *@ELFUTILS_0.146 0.146 *@ELFUTILS_0.148 0.148 *@ELFUTILS_0.149 0.149 *@ELFUTILS_0.156 0.156 *@ELFUTILS_0.157 0.157 *@ELFUTILS_0.158 0.158 *@ELFUTILS_0 0.126