]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: test dwflsyms on ET_EXEC with minisymtab
authorJosh Stone <jistone@redhat.com>
Wed, 12 Mar 2014 01:13:55 +0000 (18:13 -0700)
committerJosh Stone <jistone@redhat.com>
Wed, 12 Mar 2014 01:13:55 +0000 (18:13 -0700)
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 <jistone@redhat.com>
tests/ChangeLog
tests/Makefile.am
tests/run-dwflsyms.sh
tests/run-readelf-s.sh
tests/testfilebaxmin.bz2 [new file with mode: 0755]

index a279982c94a0585009190fec7a0a3c1a473d8f34..9b0e7aceb5515d9784ee167cc6119d5707754fb3 100644 (file)
@@ -1,3 +1,10 @@
+2014-03-11  Josh Stone  <jistone@redhat.com>
+
+       * 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  <mjw@redhat.com>
 
        * backtrace-subr.sh (check_unsupported): Special case arm*.
index c75e7969fb11666c30713c0eed384db9713b8aa9..5e640955a1fe7f9d4097642b493ec07a3c47e182 100644 (file)
@@ -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 \
index 452b9617233e6d5a2b5855c90ffda1bb238400e9..9726bcf19d77eaff187c9c66b5850d61e5cd0e94 100755 (executable)
@@ -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
index 931516da1d255db2778dec5c2a748731bd7e3cd7..59407d14de5104c9e8eb0a9db7e548c667962748 100755 (executable)
 # 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 <<EOF
+
+Symbol table [ 5] '.dynsym' contains 3 entries:
+ 1 local symbol  String table: [ 6] '.dynstr'
+  Num:            Value   Size Type    Bind   Vis          Ndx Name
+    0: 0000000000000000      0 NOTYPE  LOCAL  DEFAULT    UNDEF 
+    1: 0000000000000000      0 FUNC    GLOBAL DEFAULT    UNDEF __libc_start_main@GLIBC_2.2.5 (2)
+    2: 0000000000000000      0 NOTYPE  WEAK   DEFAULT    UNDEF __gmon_start__
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf --elf-section -s testfilebaxmin <<\EOF
+
+Symbol table [27] '.symtab' contains 42 entries:
+ 35 local symbols  String table: [28] '.strtab'
+  Num:            Value   Size Type    Bind   Vis          Ndx Name
+    0: 0000000000000000      0 NOTYPE  LOCAL  DEFAULT    UNDEF 
+    1: 0000000000400430      0 FUNC    LOCAL  DEFAULT       13 deregister_tm_clones
+    2: 0000000000400460      0 FUNC    LOCAL  DEFAULT       13 register_tm_clones
+    3: 00000000004004a0      0 FUNC    LOCAL  DEFAULT       13 __do_global_dtors_aux
+    4: 0000000000600e18      0 OBJECT  LOCAL  DEFAULT       19 __do_global_dtors_aux_fini_array_entry
+    5: 00000000004004c0      0 FUNC    LOCAL  DEFAULT       13 frame_dummy
+    6: 0000000000600e10      0 OBJECT  LOCAL  DEFAULT       18 __frame_dummy_init_array_entry
+    7: 00000000004004f0     20 FUNC    LOCAL  DEFAULT       13 foo
+    8: 0000000000600e18      0 NOTYPE  LOCAL  DEFAULT       18 __init_array_end
+    9: 0000000000600e10      0 NOTYPE  LOCAL  DEFAULT       18 __init_array_start
+   10: 0000000000400238      0 SECTION LOCAL  DEFAULT        1 
+   11: 0000000000400254      0 SECTION LOCAL  DEFAULT        2 
+   12: 0000000000400274      0 SECTION LOCAL  DEFAULT        3 
+   13: 0000000000400298      0 SECTION LOCAL  DEFAULT        4 
+   14: 00000000004002b8      0 SECTION LOCAL  DEFAULT        5 
+   15: 0000000000400300      0 SECTION LOCAL  DEFAULT        6 
+   16: 0000000000400338      0 SECTION LOCAL  DEFAULT        7 
+   17: 0000000000400340      0 SECTION LOCAL  DEFAULT        8 
+   18: 0000000000400360      0 SECTION LOCAL  DEFAULT        9 
+   19: 0000000000400378      0 SECTION LOCAL  DEFAULT       10 
+   20: 00000000004003a8      0 SECTION LOCAL  DEFAULT       11 
+   21: 00000000004003d0      0 SECTION LOCAL  DEFAULT       12 
+   22: 0000000000400400      0 SECTION LOCAL  DEFAULT       13 
+   23: 00000000004005c4      0 SECTION LOCAL  DEFAULT       14 
+   24: 00000000004005d0      0 SECTION LOCAL  DEFAULT       15 
+   25: 00000000004005e0      0 SECTION LOCAL  DEFAULT       16 
+   26: 0000000000400628      0 SECTION LOCAL  DEFAULT       17 
+   27: 0000000000600e10      0 SECTION LOCAL  DEFAULT       18 
+   28: 0000000000600e18      0 SECTION LOCAL  DEFAULT       19 
+   29: 0000000000600e20      0 SECTION LOCAL  DEFAULT       20 
+   30: 0000000000600e28      0 SECTION LOCAL  DEFAULT       21 
+   31: 0000000000600ff8      0 SECTION LOCAL  DEFAULT       22 
+   32: 0000000000601000      0 SECTION LOCAL  DEFAULT       23 
+   33: 0000000000601028      0 SECTION LOCAL  DEFAULT       24 
+   34: 0000000000601034      0 SECTION LOCAL  DEFAULT       25 
+   35: 00000000004005c0      2 FUNC    GLOBAL DEFAULT       13 __libc_csu_fini
+   36: 0000000000400504     40 FUNC    GLOBAL DEFAULT       13 bar
+   37: 00000000004005c4      0 FUNC    GLOBAL DEFAULT       14 _fini
+   38: 0000000000400550    101 FUNC    GLOBAL DEFAULT       13 __libc_csu_init
+   39: 0000000000400400      0 FUNC    GLOBAL DEFAULT       13 _start
+   40: 000000000040052c     35 FUNC    GLOBAL DEFAULT       13 main
+   41: 00000000004003a8      0 FUNC    GLOBAL DEFAULT       11 _init
+EOF
+
 exit 0
diff --git a/tests/testfilebaxmin.bz2 b/tests/testfilebaxmin.bz2
new file mode 100755 (executable)
index 0000000..c450cc8
Binary files /dev/null and b/tests/testfilebaxmin.bz2 differ