From: Josh Stone Date: Wed, 12 Mar 2014 01:13:55 +0000 (-0700) Subject: libdwfl: test dwflsyms on ET_EXEC with minisymtab X-Git-Tag: elfutils-0.159~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=51fff30ac9d9eb245e7df8eb5c07658d04d6ad45;p=thirdparty%2Felfutils.git libdwfl: test dwflsyms on ET_EXEC with minisymtab This adds testfilebaxmin, an ET_EXEC binary with .gnu_debugdata that doesn't match the load address of the main file. A previous bug made this trigger a kernel heuristic that forces the module to act like ET_DYN, which makes things like dwfl_module_relocate_address report relative addresses rather than proper absolute addresses. For example, before the fix dwflsyms would print: deregister_tm_clones (0) 0x400430, rel: 0x430 (.text) Now it properly prints: deregister_tm_clones (0) 0x400430, rel: 0x400430 (.text) These new test additions confirm that it's fixed. Signed-off-by: Josh Stone --- diff --git a/tests/ChangeLog b/tests/ChangeLog index a279982c9..9b0e7aceb 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,10 @@ +2014-03-11 Josh Stone + + * testfilebaxmin.bz2: New testfile. + * Makefile.am (EXTRA_DIST): Add testfilebaxmin.bz2. + * run-readelf-s.sh: Test testfilebaxmin. + * run-dwflsyms.sh: Likewise. + 2014-01-26 Mark Wielaard * backtrace-subr.sh (check_unsupported): Special case arm*. diff --git a/tests/Makefile.am b/tests/Makefile.am index c75e7969f..5e640955a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -215,7 +215,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ testfilegdbindex7.bz2 \ run-readelf-s.sh testfilebazdbg.bz2 testfilebazdyn.bz2 \ testfilebazmin.bz2 testfilebazdbg.debug.bz2 testfilebazmdb.bz2 \ - testfilebaztab.bz2 testfilebasmin.bz2 \ + testfilebaztab.bz2 testfilebasmin.bz2 testfilebaxmin.bz2 \ testfilebazdbg_pl.bz2 testfilebazmin_pl.bz2 \ testfilebazdbg_plr.bz2 testfilebazmin_plr.bz2 \ testfilebazdbgppc64.bz2 testfilebazdbgppc64.debug.bz2 \ diff --git a/tests/run-dwflsyms.sh b/tests/run-dwflsyms.sh index 452b96172..9726bcf19 100755 --- a/tests/run-dwflsyms.sh +++ b/tests/run-dwflsyms.sh @@ -32,6 +32,7 @@ testfiles testfilebazmin testfiles testfilebazmin_pl testfiles testfilebazmin_plr testfiles testfilebasmin +testfiles testfilebaxmin tempfiles testfile.dynsym.in testfile.symtab.in testfile.minsym.in dwflsyms.out tempfiles testfile.symtab_pl.in testfile.minsym_pl.in @@ -362,6 +363,53 @@ testrun_compare ${abs_builddir}/dwflsyms -e testfilebasmin <<\EOF 8: FUNC GLOBAL bar (44) 0x40017a, rel: 0x40017a (.text) EOF +testrun_compare ${abs_builddir}/dwflsyms -e testfilebaxmin <<\EOF + 0: NOTYPE LOCAL (0) 0 + 1: FUNC LOCAL deregister_tm_clones (0) 0x400430, rel: 0x400430 (.text) + 2: FUNC LOCAL register_tm_clones (0) 0x400460, rel: 0x400460 (.text) + 3: FUNC LOCAL __do_global_dtors_aux (0) 0x4004a0, rel: 0x4004a0 (.text) + 4: OBJECT LOCAL __do_global_dtors_aux_fini_array_entry (0) 0x600e18 + 5: FUNC LOCAL frame_dummy (0) 0x4004c0, rel: 0x4004c0 (.text) + 6: OBJECT LOCAL __frame_dummy_init_array_entry (0) 0x600e10 + 7: FUNC LOCAL foo (20) 0x4004f0, rel: 0x4004f0 (.text) + 8: NOTYPE LOCAL __init_array_end (0) 0x600e18 + 9: NOTYPE LOCAL __init_array_start (0) 0x600e10 + 10: SECTION LOCAL (0) 0x400238 + 11: SECTION LOCAL (0) 0x400254 + 12: SECTION LOCAL (0) 0x400274 + 13: SECTION LOCAL (0) 0x400298 + 14: SECTION LOCAL (0) 0x4002b8 + 15: SECTION LOCAL (0) 0x400300 + 16: SECTION LOCAL (0) 0x400338 + 17: SECTION LOCAL (0) 0x400340 + 18: SECTION LOCAL (0) 0x400360 + 19: SECTION LOCAL (0) 0x400378 + 20: SECTION LOCAL (0) 0x4003a8 + 21: SECTION LOCAL (0) 0x4003d0 + 22: SECTION LOCAL (0) 0x400400 + 23: SECTION LOCAL (0) 0x4005c4 + 24: SECTION LOCAL (0) 0x4005d0 + 25: SECTION LOCAL (0) 0x4005e0 + 26: SECTION LOCAL (0) 0x400628 + 27: SECTION LOCAL (0) 0x600e10 + 28: SECTION LOCAL (0) 0x600e18 + 29: SECTION LOCAL (0) 0x600e20 + 30: SECTION LOCAL (0) 0x600e28 + 31: SECTION LOCAL (0) 0x600ff8 + 32: SECTION LOCAL (0) 0x601000 + 33: SECTION LOCAL (0) 0x601028 + 34: SECTION LOCAL (0) 0x601034 + 35: FUNC GLOBAL __libc_start_main (0) 0 + 36: NOTYPE WEAK __gmon_start__ (0) 0 + 37: FUNC GLOBAL __libc_csu_fini (2) 0x4005c0, rel: 0x4005c0 (.text) + 38: FUNC GLOBAL bar (40) 0x400504, rel: 0x400504 (.text) + 39: FUNC GLOBAL _fini (0) 0x4005c4, rel: 0x4005c4 (.fini) + 40: FUNC GLOBAL __libc_csu_init (101) 0x400550, rel: 0x400550 (.text) + 41: FUNC GLOBAL _start (0) 0x400400, rel: 0x400400 (.text) + 42: FUNC GLOBAL main (35) 0x40052c, rel: 0x40052c (.text) + 43: FUNC GLOBAL _init (0) 0x4003a8, rel: 0x4003a8 (.init) +EOF + testfiles testfile66 testrun_compare ${abs_builddir}/dwflsyms -e testfile66 <<\EOF 0: NOTYPE LOCAL (0) 0 diff --git a/tests/run-readelf-s.sh b/tests/run-readelf-s.sh index 931516da1..59407d14d 100755 --- a/tests/run-readelf-s.sh +++ b/tests/run-readelf-s.sh @@ -93,6 +93,23 @@ # objcopy --add-section .gnu_debugdata=mini_debuginfo.xz bas # rm bas.debug # mv bas testfilebasmin +# +# +# Make sure that find_aux_sym doesn't corrupt relocations, avoiding a kernel +# heuristic that forces ET_EXEC->ET_DYN. NB: ld.gold doesn't seem to produce +# the mismatched load addrs between the main file and the mini_debuginfo, so +# this is forcing ld.bfd. +# +# gcc -g -o bax foo.c bar.c -fuse-ld=bfd +# eu-strip --remove-comment -f bax.debug bax +# nm -D bax --format=posix --defined-only | awk '{ print $1 }' | sort > dynsyms +# nm bax.debug --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > funcsyms +# comm -13 dynsyms funcsyms > keep_symbols +# objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols=keep_symbols bax.debug mini_debuginfo +# rm -f mini_debuginfo.xz +# xz mini_debuginfo +# objcopy --add-section .gnu_debugdata=mini_debuginfo.xz bax +# objcopy --remove-section=.gnu_debuglink bax testfilebaxmin testfiles testfilebaztab @@ -101,6 +118,7 @@ testfiles testfilebazdyn testfiles testfilebazmdb testfiles testfilebazmin testfiles testfilebasmin +testfiles testfilebaxmin tempfiles testfile.dynsym.in testfile.symtab.in testfile.minsym.in @@ -298,4 +316,63 @@ Symbol table [ 6] '.symtab' contains 9 entries: 8: 000000000040017a 44 FUNC GLOBAL DEFAULT 2 bar EOF +testrun_compare ${abs_top_builddir}/src/readelf -s testfilebaxmin <