summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2018-04-30 02:54:07 +0200
committerMark Wielaard <[email protected]>2018-05-30 12:14:10 +0200
commit4ac4a42376428248f7174c7bb713fff27bb4d4b0 (patch)
tree3853c641731266985a8b98a2076060bc44143bbe /tests
parent50dfd98101dde72b32ea2d4df89166ce148a28f2 (diff)
readelf: Handle .debug_str_offsets.
The .debug_str_offsets tables are indirect string offsets into the .debug_str section. For DWARF5 they can be in both the main, skeleton and split dwarf (.dwo) files. For DWARF4 with the GNU DebugFission extension the tables will not have an header and they will only be in the split DWARF (.dwo) file, never in the main (skeleton) file. For DWARF5 the (non-split) unit DIE will have a DW_AT_str_offsets_base attribute pointing at the actual index (after the header). The split unit will never have this attribute (and use the table at offset zero). Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog6
-rw-r--r--tests/Makefile.am4
-rwxr-xr-xtests/run-readelf-str.sh211
3 files changed, 219 insertions, 2 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 69915519..7ac6bd3c 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2018-04-29 Mark Wielaard <[email protected]>
+
+ * run-readelf-addr.sh: New test.
+ * Makefile.am (TESTS): Add run-readelf-addr.sh.
+ (EXTRA_DIST): Likewise.
+
2018-04-27 Mark Wielaard <[email protected]>
* run-readelf-ranges.sh: Adjust expected output for address base.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e15fe519..4cd06656 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -130,7 +130,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
run-backtrace-core-aarch64.sh run-backtrace-core-sparc.sh \
run-backtrace-demangle.sh run-stack-d-test.sh run-stack-i-test.sh \
run-stack-demangled-test.sh run-readelf-zx.sh run-readelf-zp.sh \
- run-readelf-addr.sh \
+ run-readelf-addr.sh run-readelf-str.sh \
run-readelf-dwz-multi.sh run-allfcts-multi.sh run-deleted.sh \
run-linkmap-cut.sh run-aggregate-size.sh run-peel-type.sh \
vdsosyms run-readelf-A.sh \
@@ -246,7 +246,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
run-readelf-dwz-multi.sh libtestfile_multi_shared.so.bz2 \
testfile_multi.dwz.bz2 testfile_multi_main.bz2 \
testfile-dwzstr.bz2 testfile-dwzstr.multi.bz2 \
- run-readelf-addr.sh \
+ run-readelf-addr.sh run-readelf-str.sh \
run-allfcts-multi.sh \
test-offset-loop.bz2 test-offset-loop.alt.bz2 \
run-prelink-addr-test.sh \
diff --git a/tests/run-readelf-str.sh b/tests/run-readelf-str.sh
new file mode 100755
index 00000000..8b894e8d
--- /dev/null
+++ b/tests/run-readelf-str.sh
@@ -0,0 +1,211 @@
+#! /bin/sh
+# Copyright (C) 2018 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file 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; either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# See tests/testfile-dwarf-45.source
+testfiles testfile-splitdwarf-4 testfile-splitdwarf-5
+testfiles testfile-hello4.dwo testfile-hello5.dwo
+testfiles testfile-world4.dwo testfile-world5.dwo
+
+# DWARF4 GNU DebugFission No real table header.
+# We don't really need the skeleton, but we don't want any Warnings.
+testrun_compare ${abs_top_builddir}/src/readelf --dwarf-skeleton testfile-splitdwarf-4 --debug-dump=str testfile-hello4.dwo testfile-world4.dwo<<\EOF
+
+testfile-hello4.dwo:
+
+
+DWARF section [ 5] '.debug_str_offsets.dwo' at offset 0x335:
+Table at offset 0
+ Offsets start at 0x0:
+ [ 0] [ 0] "long long int"
+ [ 1] [ e] "frob"
+ [ 2] [ 13] "long unsigned int"
+ [ 3] [ 25] "/home/mark/src/elfutils/tests"
+ [ 4] [ 43] "wchar_t"
+ [ 5] [ 4b] "main"
+ [ 6] [ 50] "long int"
+ [ 7] [ 59] "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-4 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
+ [ 8] [ e9] "long double"
+ [ 9] [ f5] "hello.c"
+
+
+DWARF section [ 6] '.debug_str.dwo' at offset 0x35d:
+ Offset String
+ [ 0] "long long int"
+ [ e] "frob"
+ [ 13] "long unsigned int"
+ [ 25] "/home/mark/src/elfutils/tests"
+ [ 43] "wchar_t"
+ [ 4b] "main"
+ [ 50] "long int"
+ [ 59] "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-4 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
+ [ e9] "long double"
+ [ f5] "hello.c"
+
+testfile-world4.dwo:
+
+
+DWARF section [ 5] '.debug_str_offsets.dwo' at offset 0x2e7:
+Table at offset 0
+ Offsets start at 0x0:
+ [ 0] [ 0] "long long unsigned int"
+ [ 1] [ 17] "/home/mark/src/elfutils/tests"
+ [ 2] [ 35] "long long int"
+ [ 3] [ 43] "signed char"
+ [ 4] [ 4f] "long int"
+ [ 5] [ 58] "world.c"
+ [ 6] [ 60] "unsigned int"
+ [ 7] [ 6d] "long unsigned int"
+ [ 8] [ 7f] "short unsigned int"
+ [ 9] [ 92] "frob"
+ [10] [ 97] "calc"
+ [11] [ 9c] "unsigned char"
+ [12] [ aa] "short int"
+ [13] [ b4] "exit"
+ [14] [ b9] "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-4 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
+ [15] [ 149] "char"
+ [16] [ 14e] "word"
+ [17] [ 153] "argv"
+ [18] [ 158] "argc"
+ [19] [ 15d] "main"
+
+
+DWARF section [ 6] '.debug_str.dwo' at offset 0x337:
+ Offset String
+ [ 0] "long long unsigned int"
+ [ 17] "/home/mark/src/elfutils/tests"
+ [ 35] "long long int"
+ [ 43] "signed char"
+ [ 4f] "long int"
+ [ 58] "world.c"
+ [ 60] "unsigned int"
+ [ 6d] "long unsigned int"
+ [ 7f] "short unsigned int"
+ [ 92] "frob"
+ [ 97] "calc"
+ [ 9c] "unsigned char"
+ [ aa] "short int"
+ [ b4] "exit"
+ [ b9] "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-4 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
+ [ 149] "char"
+ [ 14e] "word"
+ [ 153] "argv"
+ [ 158] "argc"
+ [ 15d] "main"
+EOF
+
+# DWARF5 Real table header.
+# We don't really need the skeleton, but we don't want any Warnings.
+testrun_compare ${abs_top_builddir}/src/readelf --dwarf-skeleton testfile-splitdwarf-5 --debug-dump=str testfile-hello5.dwo testfile-world5.dwo<<\EOF
+
+testfile-hello5.dwo:
+
+
+DWARF section [ 5] '.debug_str_offsets.dwo' at offset 0x353:
+Table at offset 0
+
+ Length: 44
+ Offset size: 4
+ DWARF version: 5
+ Padding: 0
+
+ Offsets start at 0x8:
+ [ 0] [ 0] "long long int"
+ [ 1] [ e] "frob"
+ [ 2] [ 13] "long unsigned int"
+ [ 3] [ 25] "/home/mark/src/elfutils/tests"
+ [ 4] [ 43] "wchar_t"
+ [ 5] [ 4b] "main"
+ [ 6] [ 50] "long int"
+ [ 7] [ 59] "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
+ [ 8] [ e9] "long double"
+ [ 9] [ f5] "hello.c"
+
+
+DWARF section [ 6] '.debug_str.dwo' at offset 0x383:
+ Offset String
+ [ 0] "long long int"
+ [ e] "frob"
+ [ 13] "long unsigned int"
+ [ 25] "/home/mark/src/elfutils/tests"
+ [ 43] "wchar_t"
+ [ 4b] "main"
+ [ 50] "long int"
+ [ 59] "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
+ [ e9] "long double"
+ [ f5] "hello.c"
+
+testfile-world5.dwo:
+
+
+DWARF section [ 5] '.debug_str_offsets.dwo' at offset 0x313:
+Table at offset 0
+
+ Length: 84
+ Offset size: 4
+ DWARF version: 5
+ Padding: 0
+
+ Offsets start at 0x8:
+ [ 0] [ 0] "long long unsigned int"
+ [ 1] [ 17] "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
+ [ 2] [ a7] "/home/mark/src/elfutils/tests"
+ [ 3] [ c5] "long long int"
+ [ 4] [ d3] "signed char"
+ [ 5] [ df] "long int"
+ [ 6] [ e8] "world.c"
+ [ 7] [ f0] "unsigned int"
+ [ 8] [ fd] "long unsigned int"
+ [ 9] [ 10f] "short unsigned int"
+ [10] [ 122] "frob"
+ [11] [ 127] "calc"
+ [12] [ 12c] "unsigned char"
+ [13] [ 13a] "short int"
+ [14] [ 144] "exit"
+ [15] [ 149] "char"
+ [16] [ 14e] "word"
+ [17] [ 153] "argv"
+ [18] [ 158] "argc"
+ [19] [ 15d] "main"
+
+
+DWARF section [ 6] '.debug_str.dwo' at offset 0x36b:
+ Offset String
+ [ 0] "long long unsigned int"
+ [ 17] "GNU C17 9.0.0 20180515 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -gsplit-dwarf -gno-as-loc-support -gno-variable-location-views -O2"
+ [ a7] "/home/mark/src/elfutils/tests"
+ [ c5] "long long int"
+ [ d3] "signed char"
+ [ df] "long int"
+ [ e8] "world.c"
+ [ f0] "unsigned int"
+ [ fd] "long unsigned int"
+ [ 10f] "short unsigned int"
+ [ 122] "frob"
+ [ 127] "calc"
+ [ 12c] "unsigned char"
+ [ 13a] "short int"
+ [ 144] "exit"
+ [ 149] "char"
+ [ 14e] "word"
+ [ 153] "argv"
+ [ 158] "argc"
+ [ 15d] "main"
+EOF
+
+exit 0