aboutsummaryrefslogtreecommitdiff
path: root/binutils/testsuite
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-11-21 13:12:04 +0000
committerNick Clifton <nickc@redhat.com>2017-11-21 13:12:04 +0000
commitd85bf2ba86fea1cf918f065d179b98eb4ddbde86 (patch)
treeb63b374b40e58403431a94352c421751d85127e9 /binutils/testsuite
parent0fc7642151cc5e62f05ac8ea91fe4d5b44bee11a (diff)
downloadgdb-d85bf2ba86fea1cf918f065d179b98eb4ddbde86.zip
gdb-d85bf2ba86fea1cf918f065d179b98eb4ddbde86.tar.gz
gdb-d85bf2ba86fea1cf918f065d179b98eb4ddbde86.tar.bz2
Add ability to follow dwo links to readelf/objdump.
* dwarf.c (dwo_name, dwo_dir, dwo_id, dwo_id_len): New variables. (read_and_display_attr_value): Record dwo variables if requested. (display_augmentation_data): Rename to display_data and make generic. (load_dwo_file): New function. Loads a separate dwarf object file. (load_separate_debug_file): Add reporting and loading of separate dwarf objet files. * readelf.c (process_section_headers): Add do_debug_links to list of flags requiring a debug dump. (display_debug_section): Tidy up code. * doc/debug.options.texi: Add note that dwo links will also be followed. * testsuite/binutils-all/debuglink.s: Tidy code. * testsuite/binutils-all/dwo.s: New test file. * testsuite/binutils-all/readelf.wk2: New file - expected output from readelf. * testsuite/binutils-all/readelf.exp: Run the new test.
Diffstat (limited to 'binutils/testsuite')
-rw-r--r--binutils/testsuite/binutils-all/debuglink.s16
-rw-r--r--binutils/testsuite/binutils-all/dwo.s84
-rw-r--r--binutils/testsuite/binutils-all/readelf.exp30
-rw-r--r--binutils/testsuite/binutils-all/readelf.k24
4 files changed, 114 insertions, 20 deletions
diff --git a/binutils/testsuite/binutils-all/debuglink.s b/binutils/testsuite/binutils-all/debuglink.s
index a3691a0..daabf7a 100644
--- a/binutils/testsuite/binutils-all/debuglink.s
+++ b/binutils/testsuite/binutils-all/debuglink.s
@@ -17,14 +17,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/* Create a fake .gnu_debuglink section. */
+ /* Create a fake .gnu_debuglink section. */
.section .gnu_debuglink,"",%progbits
.asciz "this_is_a_debuglink.debug"
.balign 4
.4byte 0x12345678
-/* Create a fake .gnu_debugaltlink section. */
+ /* Create a fake .gnu_debugaltlink section. */
.section .gnu_debugaltlink,"",%progbits
.asciz "linkdebug.debug"
@@ -32,9 +32,9 @@
.dc.b 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
.dc.b 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef
-/* Create a .debug_str section for local use. This is also to check
- the ability to dump the same section twice, if it exists in
- both the main file and the separate debug info file. */
+ /* Create a .debug_str section for local use. This is also to check
+ the ability to dump the same section twice, if it exists in
+ both the main file and the separate debug info file. */
.section .debug_str,"MS",%progbits,1
string1:
@@ -43,9 +43,9 @@ string1:
.balign 2
string_end:
-/* Create a .debug_info section that contains strings references into the
- separate debug info file. Plus the abbreviations are stored in the
- separate file too... */
+ /* Create a .debug_info section that contains string references into
+ the separate debug info file. Plus the abbreviations are stored
+ in the separate file too... */
.section .debug_info,"",%progbits
.4byte debugE - debugS ;# Length of Compilation Unit Info
diff --git a/binutils/testsuite/binutils-all/dwo.s b/binutils/testsuite/binutils-all/dwo.s
new file mode 100644
index 0000000..0d13471
--- /dev/null
+++ b/binutils/testsuite/binutils-all/dwo.s
@@ -0,0 +1,84 @@
+/* Assembler source used to create an object file for testing readelf's
+ and objdump's ability to process separate dwarf object files.
+
+ Copyright (C) 2017 Free Software Foundation, Inc.
+
+ This program 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.
+
+ This program 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/>. */
+
+
+ /* Create a .debug_str section for local use. This is also to check
+ the ability to dump the same section twice, if it exists in
+ both the main file and the separate debug info file. */
+
+ .section .debug_str,"MS",%progbits,1
+string1:
+ .asciz "debugfile.dwo"
+string2:
+ .asciz "/path/to/dwo/files"
+string3:
+ .asciz "/another/path/"
+ .balign 2
+string_end:
+
+ /* Create a .debug_info section that contains the dwo links. */
+
+ .section .debug_info,"",%progbits
+ .4byte debugE - debugS ;# Length of Compilation Unit Info
+debugS:
+ .short 0x4 ;# DWARF version number.
+ .4byte 0x0 ;# Offset into .debug_abbrev section.
+ .byte 0x4 ;# Pointer Size (in bytes).
+
+ .uleb128 0x1 ;# Use abbrev #1. This needs strings from the .debug_str section.
+ .4byte string1
+ .4byte string2
+
+ .uleb128 0x2 ;# Use abbrev #2.
+ .asciz "file.dwo"
+ .4byte string3
+ .8byte 0x12345678aabbccdd
+
+ ;# Minimal section alignment on alpha-* is 2, so ensure no new invalid CU
+ ;# will be started.
+ .balign 2, 0
+debugE:
+
+ .section .debug_abbrev,"",%progbits
+
+ /* Create an abbrev containing a DWARF5 style dwo link. */
+ .uleb128 0x01 ;# Abbrev code.
+ .uleb128 0x11 ;# DW_TAG_compile_unit
+ .byte 0x00 ;# DW_children_no
+ .uleb128 0x76 ;# DW_AT_dwo_name
+ .uleb128 0x0e ;# DW_FORM_strp
+ .uleb128 0x1b ;# DW_AT_comp_dir
+ .uleb128 0x0e ;# DW_FORM_strp
+ .byte 0x00 ;# End of abbrev
+ .byte 0x00
+
+ /* Create an abbrev containing a GNU style dwo link. */
+ .uleb128 0x02 ;# Abbrev code.
+ .uleb128 0x11 ;# DW_TAG_compile_unit
+ .byte 0x00 ;# DW_children_no
+ .uleb128 0x2130 ;# DW_AT_GNU_dwo_name
+ .uleb128 0x08 ;# DW_FORM_string
+ .uleb128 0x1b ;# DW_AT_comp_dir
+ .uleb128 0x0e ;# DW_FORM_strp
+ .uleb128 0x2131 ;# DW_AT_GNU_dwo_id
+ .uleb128 0x07 ;# DW_FORM_data8
+ .byte 0x00 ;# End of abbrev
+ .byte 0x00
+
+ .byte 0x0 ;# Abbrevs terminator
+
diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp
index fdb310c..f126255 100644
--- a/binutils/testsuite/binutils-all/readelf.exp
+++ b/binutils/testsuite/binutils-all/readelf.exp
@@ -469,7 +469,7 @@ if {![binutils_assemble_flags $srcdir/$subdir/dwarf-attributes.S tmpdir/dwarf-at
# Check that debug link sections can be dumped.
if {![binutils_assemble $srcdir/$subdir/debuglink.s tmpdir/debuglink.o]} then {
- unresolved "readelf --debug-dump=links (failed to assemble)"
+ unresolved "readelf --debug-dump=links (failed to assemble debuglink.s)"
} else {
if ![is_remote host] {
set tempfile tmpdir/debuglink.o
@@ -478,23 +478,29 @@ if {![binutils_assemble $srcdir/$subdir/debuglink.s tmpdir/debuglink.o]} then {
}
readelf_test {--debug-dump=links} $tempfile readelf.k {}
-}
-# Check that debug link sections can be followed.
-if {![binutils_assemble $srcdir/$subdir/debuglink.s tmpdir/debuglink.o]} then {
- unresolved "readelf --debug-dump=follow-links (failed to assemble1)"
-} else {
+ # Check that debug link sections can be followed.
if {![binutils_assemble $srcdir/$subdir/linkdebug.s tmpdir/linkdebug.debug]} then {
- unresolved "readelf --debug-dump=follow-links (failed to assemble2)"
+ unresolved "readelf --debug-dump=follow-links (failed to assemble linkdebug.s)"
} else {
- if ![is_remote host] {
- set tempfile tmpdir/debuglink.o
- } else {
- set tempfile [remote_download host tmpdir/linkdebug.debug]
- set tempfile [remote_download host tmpdir/debuglink.o]
+ if [is_remote host] {
+ set tempfile2 [remote_download host tmpdir/linkdebug.debug]
}
readelf_test {-wKis} $tempfile objdump.WK2 {}
}
}
+if {![binutils_assemble $srcdir/$subdir/dwo.s tmpdir/dwo.o]} then {
+ unresolved "readelf --debug-dump=links (failed to assemble dwo.s)"
+} else {
+ if ![is_remote host] {
+ set tempfile tmpdir/dwo.o
+ } else {
+ set tempfile [remote_download host tmpdir/dwo.o]
+ }
+
+ readelf_test {--debug-dump=links} $tempfile readelf.k2 {}
+}
+
+
diff --git a/binutils/testsuite/binutils-all/readelf.k2 b/binutils/testsuite/binutils-all/readelf.k2
new file mode 100644
index 0000000..89ee4b4
--- /dev/null
+++ b/binutils/testsuite/binutils-all/readelf.k2
@@ -0,0 +1,4 @@
+The \.debug_info section contains a link to a dwo file:
+ Name: file\.dwo
+ Directory: /another/path/
+ ID: (12|dd) (34|cc) (56|bb) (78|aa) (78|aa) (56|bb) (34|cc) (12|dd)