Add support to readelf and objdump for following links to separate debug information files.
Hi Guys, I am applying the rather large patch attached to this email to enhance the readelf and objdump programs so that they now have the ability to follow links to separate debug info files. (As requested by PR 15152). So for example whereas before we had this output: $ readelf -wi main.exe Contents of the .debug_info section: [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) [...] With the new option enabled we get: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] <15> DW_AT_comp_dir : (alt indirect string, offset: 0x30c) /home/nickc/Downloads/dwzm [...] The link following feature also means that we can get two lots of output if the same section exists in both the main file and the separate debug info file: $ readelf -wiK main.exe main.exe: Found separate debug info file: dwz.debug Contents of the .debug_info section (loaded from main.exe): [...] Contents of the .debug_info section (loaded from dwz.debug): [...] The patch also adds the ability to display the contents of debuglink sections: $ readelf -wk main.exe Contents of the .gnu_debugaltlink section: Separate debug info file: dwz.debug Build-ID (0x14 bytes): c4 a8 89 8d 64 cf 70 8a 35 68 21 f2 ed 24 45 3e 18 7a 7a 93 Naturally there are long versions of these options (=follow-links and =links). The documentation has been updated as well, and since both readelf and objdump use the same set of debug display options, I have moved the text into a separate file. There are also a couple of new binutils tests to exercise the new behaviour. There are a couple of missing features in the current patch however, although I do intend to address them in follow up submissions: Firstly the code does not check the build-id inside separate debug info files when it is searching for a file specified by a .gnu_debugaltlink section. It just assumes that if the file is there, then it contains the information being sought. Secondly I have not checked the DWARF-5 version of these link features, so there will probably be code to add there. Thirdly I have only implemented link following for the DW_FORM_GNU_strp_alt format. Other alternate formats (eg DW_FORM_GNU_ref_alt) have yet to be implemented. Lastly, whilst implementing this feature I found it necessary to move some of the global variables used by readelf (eg section_headers) into a structure that can be passed around. I have moved all of the global variables that were necessary to get the patch working, but I need to complete the operation and move the remaining, file-specific variables (eg dynamic_strings). Cheers Nick binutils PR 15152 * dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink, gnu_debugaltlink and separate_debug_str. (struct dwarf_section): Add filename field. Add prototypes for load_separate_debug_file, close_debug_file and open_debug_file. * dwarf.c (do_debug_links): New. (do_follow_links): New. (separate_debug_file, separate_debug_filename): New. (fetch_alt_indirect_string): New function. Retrieves a string from the debug string table in the separate debug info file. (read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt. (load_debug_section_with_follow): New function. Like load_debug_section, but if the first attempt fails, then tries again in the separate debug info file. (introduce): New function. (process_debug_info): Use load_debug_section_with_follow and introduce. (load_debug_info): Likewise. (display_debug_lines_raw): Likewise. (display_debug_lines_decoded): Likewise. (display_debug_macinfo): Likewise. (display_debug_macro): Likewise. (display_debug_abbrev): Likewise. (display_debug_loc): Likewise. (display_debug_str): Likewise. (display_debug_aranges): Likewise. (display_debug_addr); Likewise. (display_debug_frames): Likewise. (display_gdb_index): Likewise. (process_cu_tu_index): Likewise. (load_cu_tu_indexes): Likewise. (display_debug_links): New function. Displays the contents of a .gnu_debuglink or .gnu_debugaltlink section. (calc_gnu_debuglink_ctc32):New function. Calculates a CRC32 value. (check_gnu_debuglink): New function. Checks the CRC of a potential separate debug info file. (parse_gnu_debuglink): New function. Reads a CRC value out of a .gnu_debuglink section. (check_gnu_debugaltlink): New function. (parse_gnu_debugaltlink): New function. Reads the build-id value out of a .gnu_debugaltlink section. (load_separate_debug_info): New function. Finds and loads a separate debug info file. (load_separate_debug_file): New function. Attempts to find and follow a link to a separate debug info file. (free_debug_memory): Free the separate debug info file information. (opts_table): Add "follow-links" and "links". (dwarf_select_sections_by_letters): Add "k" and "K". (debug_displays): Reformat. Add .gnu-debuglink and .gnu_debugaltlink. Add an extra entry for .debug_str in a separate debug info file. * doc/binutils.texi: Move description of debug dump features common to both readelf and objdump into... * objdump.c (usage): Add -Wk and -WK. (load_specific_debug_section): Initialise the filename field in the dwarf_section structure. (close_debug_file): New function. (open_debug_file): New function. (dump_dwarf): Load and dump the separate debug info sections. * readelf.c (struct filedata): New structure. Contains various variables that used to be global: (current_file_size, string_table, string_table_length, elf_header) (section_headers, program_headers, dump_sects, num_dump_sects): Move into filedata structure. (cmdline): New global variable. Contains list of sections to dump by number, as specified on the command line. Add filedata parameter to most functions. (load_debug_section): Load the string table if it has not already been retrieved. (close_file): New function. (close_debug_file): New function. (open_file): New function. (open_debug_file): New function. (process_object): Process sections in any separate debug info files. * doc/debug.options.texi: New file. Add description of =links and =follow-links options. * NEWS: Mention the new feature. * elfcomm.c: Have the byte gte functions take a const pointer. * elfcomm.h: Update prototypes. * testsuite/binutils-all/dw5.W: Update expected output. * testsuite/binutils-all/objdump.WL: Update expected output. * testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk. * testsuite/binutils-all/readelf.exp: Add test of -wK and -wk. * testsuite/binutils-all/readelf.k: New file. * testsuite/binutils-all/objdump.Wk: New file. * testsuite/binutils-all/objdump.WK2: New file. * testsuite/binutils-all/linkdebug.s: New file. * testsuite/binutils-all/debuglink.s: New file. gas * testsuite/gas/avr/large-debug-line-table.d: Update expected output. * testsuite/gas/elf/dwarf2-11.d: Likewise. * testsuite/gas/elf/dwarf2-12.d: Likewise. * testsuite/gas/elf/dwarf2-13.d: Likewise. * testsuite/gas/elf/dwarf2-14.d: Likewise. * testsuite/gas/elf/dwarf2-15.d: Likewise. * testsuite/gas/elf/dwarf2-16.d: Likewise. * testsuite/gas/elf/dwarf2-17.d: Likewise. * testsuite/gas/elf/dwarf2-18.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/elf/dwarf2-6.d: Likewise. * testsuite/gas/elf/dwarf2-7.d: Likewise. ld * testsuite/ld-avr/gc-section-debugline.d: Update expected output.
This commit is contained in:
parent
a602f924c8
commit
dda8d76d0d
@ -1,3 +1,97 @@
|
||||
2017-11-15 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
PR 15152
|
||||
* dwarf.h (enum dwarf_section_display_enum): Add gnu_debuglink,
|
||||
gnu_debugaltlink and separate_debug_str.
|
||||
(struct dwarf_section): Add filename field.
|
||||
Add prototypes for load_separate_debug_file, close_debug_file and
|
||||
open_debug_file.
|
||||
* dwarf.c (do_debug_links): New.
|
||||
(do_follow_links): New.
|
||||
(separate_debug_file, separate_debug_filename): New.
|
||||
(fetch_alt_indirect_string): New function. Retrieves a string
|
||||
from the debug string table in the separate debug info file.
|
||||
(read_and_display_attr_value): Use it with DW_FORM_GNU_strp_alt.
|
||||
(load_debug_section_with_follow): New function. Like
|
||||
load_debug_section, but if the first attempt fails, then tries
|
||||
again in the separate debug info file.
|
||||
(introduce): New function.
|
||||
(process_debug_info): Use load_debug_section_with_follow and
|
||||
introduce.
|
||||
(load_debug_info): Likewise.
|
||||
(display_debug_lines_raw): Likewise.
|
||||
(display_debug_lines_decoded): Likewise.
|
||||
(display_debug_macinfo): Likewise.
|
||||
(display_debug_macro): Likewise.
|
||||
(display_debug_abbrev): Likewise.
|
||||
(display_debug_loc): Likewise.
|
||||
(display_debug_str): Likewise.
|
||||
(display_debug_aranges): Likewise.
|
||||
(display_debug_addr); Likewise.
|
||||
(display_debug_frames): Likewise.
|
||||
(display_gdb_index): Likewise.
|
||||
(process_cu_tu_index): Likewise.
|
||||
(load_cu_tu_indexes): Likewise.
|
||||
(display_debug_links): New function. Displays the contents of a
|
||||
.gnu_debuglink or .gnu_debugaltlink section.
|
||||
(calc_gnu_debuglink_ctc32):New function. Calculates a CRC32
|
||||
value.
|
||||
(check_gnu_debuglink): New function. Checks the CRC of a
|
||||
potential separate debug info file.
|
||||
(parse_gnu_debuglink): New function. Reads a CRC value out of a
|
||||
.gnu_debuglink section.
|
||||
(check_gnu_debugaltlink): New function.
|
||||
(parse_gnu_debugaltlink): New function. Reads the build-id value
|
||||
out of a .gnu_debugaltlink section.
|
||||
(load_separate_debug_info): New function. Finds and loads a
|
||||
separate debug info file.
|
||||
(load_separate_debug_file): New function. Attempts to find and
|
||||
follow a link to a separate debug info file.
|
||||
(free_debug_memory): Free the separate debug info file
|
||||
information.
|
||||
(opts_table): Add "follow-links" and "links".
|
||||
(dwarf_select_sections_by_letters): Add "k" and "K".
|
||||
(debug_displays): Reformat. Add .gnu-debuglink and
|
||||
.gnu_debugaltlink.
|
||||
Add an extra entry for .debug_str in a separate debug info file.
|
||||
* doc/binutils.texi: Move description of debug dump features
|
||||
common to both readelf and objdump into...
|
||||
* objdump.c (usage): Add -Wk and -WK.
|
||||
(load_specific_debug_section): Initialise the filename field in
|
||||
the dwarf_section structure.
|
||||
(close_debug_file): New function.
|
||||
(open_debug_file): New function.
|
||||
(dump_dwarf): Load and dump the separate debug info sections.
|
||||
* readelf.c (struct filedata): New structure. Contains various
|
||||
variables that used to be global:
|
||||
(current_file_size, string_table, string_table_length, elf_header)
|
||||
(section_headers, program_headers, dump_sects, num_dump_sects):
|
||||
Move into filedata structure.
|
||||
(cmdline): New global variable. Contains list of sections to dump
|
||||
by number, as specified on the command line.
|
||||
Add filedata parameter to most functions.
|
||||
(load_debug_section): Load the string table if it has not already
|
||||
been retrieved.
|
||||
(close_file): New function.
|
||||
(close_debug_file): New function.
|
||||
(open_file): New function.
|
||||
(open_debug_file): New function.
|
||||
(process_object): Process sections in any separate debug info files.
|
||||
* doc/debug.options.texi: New file. Add description of =links and
|
||||
=follow-links options.
|
||||
* NEWS: Mention the new feature.
|
||||
* elfcomm.c: Have the byte get functions take a const pointer.
|
||||
* elfcomm.h: Update prototypes.
|
||||
* testsuite/binutils-all/dw5.W: Update expected output.
|
||||
* testsuite/binutils-all/objdump.WL: Update expected output.
|
||||
* testsuite/binutils-all/objdump.exp: Add test of -WK and -Wk.
|
||||
* testsuite/binutils-all/readelf.exp: Add test of -wK and -wk.
|
||||
* testsuite/binutils-all/readelf.k: New file.
|
||||
* testsuite/binutils-all/objdump.Wk: New file.
|
||||
* testsuite/binutils-all/objdump.WK2: New file.
|
||||
* testsuite/binutils-all/linkdebug.s: New file.
|
||||
* testsuite/binutils-all/debuglink.s: New file.
|
||||
|
||||
2017-11-10 Jim Wilson <jimw@sifive.com>
|
||||
|
||||
* testsuite/binutils-all/objdump.exp: Expect the debug_ranges test to
|
||||
|
@ -1,5 +1,13 @@
|
||||
-*- text -*-
|
||||
|
||||
* Add --debug-dump=links option to readelf and --dwarf=links option to objdump
|
||||
which displays the contents of any .gnu_debuglink or .gnu_debugaltlink
|
||||
sections.
|
||||
|
||||
Add a --debug-dump=follow-links option to readelf and a --dwarf=follow-links
|
||||
option to objdump which causes indirect links into separate debug info files
|
||||
to be followed when dumping other DWARF sections.
|
||||
|
||||
Changes in 2.29:
|
||||
|
||||
* The MIPS port now supports microMIPS eXtended Physical Addressing (XPA)
|
||||
|
@ -2071,11 +2071,8 @@ objdump [@option{-a}|@option{--archive-headers}]
|
||||
[@option{-r}|@option{--reloc}]
|
||||
[@option{-R}|@option{--dynamic-reloc}]
|
||||
[@option{-s}|@option{--full-contents}]
|
||||
[@option{-W[lLiaprmfFsoRt]}|
|
||||
@option{--dwarf}[=rawline,=decodedline,=info,=abbrev,=pubnames]
|
||||
[=aranges,=macro,=frames,=frames-interp,=str,=loc]
|
||||
[=Ranges,=pubtypes,=trace_info,=trace_abbrev]
|
||||
[=trace_aranges,=gdb_index]
|
||||
[@option{-W[lLiaprmfFsoRtUuTgAckK]}|
|
||||
@option{--dwarf}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]
|
||||
[@option{-G}|@option{--stabs}]
|
||||
[@option{-t}|@option{--syms}]
|
||||
[@option{-T}|@option{--dynamic-syms}]
|
||||
@ -2560,42 +2557,9 @@ This is the default when @option{--prefix-addresses} is used.
|
||||
Display @var{width} bytes on a single line when disassembling
|
||||
instructions.
|
||||
|
||||
@item -W[lLiaprmfFsoRt]
|
||||
@itemx --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames]
|
||||
@itemx --dwarf[=aranges,=macro,=frames,=frames-interp,=str,=loc]
|
||||
@itemx --dwarf[=Ranges,=pubtypes,=trace_info,=trace_abbrev]
|
||||
@itemx --dwarf[=trace_aranges,=gdb_index]
|
||||
@cindex DWARF
|
||||
@cindex debug symbols
|
||||
Displays the contents of the debug sections in the file, if any are
|
||||
present. If one of the optional letters or words follows the switch
|
||||
then only data found in those specific sections will be dumped.
|
||||
|
||||
Note that there is no single letter option to display the content of
|
||||
trace sections or .gdb_index.
|
||||
|
||||
Note: the output from the @option{=info} option can also be affected
|
||||
by the options @option{--dwarf-depth}, the @option{--dwarf-start} and
|
||||
the @option{--dwarf-check}.
|
||||
|
||||
@item --dwarf-depth=@var{n}
|
||||
Limit the dump of the @code{.debug_info} section to @var{n} children.
|
||||
This is only useful with @option{--dwarf=info}. The default is
|
||||
to print all DIEs; the special value 0 for @var{n} will also have this
|
||||
effect.
|
||||
|
||||
With a non-zero value for @var{n}, DIEs at or deeper than @var{n}
|
||||
levels will not be printed. The range for @var{n} is zero-based.
|
||||
|
||||
@item --dwarf-start=@var{n}
|
||||
Print only DIEs beginning with the DIE numbered @var{n}. This is only
|
||||
useful with @option{--dwarf=info}.
|
||||
|
||||
If specified, this option will suppress printing of any header
|
||||
information and all DIEs before the DIE numbered @var{n}. Only
|
||||
siblings and children of the specified DIE will be printed.
|
||||
|
||||
This can be used in conjunction with @option{--dwarf-depth}.
|
||||
@item -W[lLiaprmfFsoRtUuTgAckK]
|
||||
@itemx --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]
|
||||
@include debug.options.texi
|
||||
|
||||
@item --dwarf-check
|
||||
Enable additional checks for consistency of Dwarf information.
|
||||
@ -4627,8 +4591,8 @@ readelf [@option{-a}|@option{--all}]
|
||||
[@option{-R} <number or name>|@option{--relocated-dump=}<number or name>]
|
||||
[@option{-z}|@option{--decompress}]
|
||||
[@option{-c}|@option{--archive-index}]
|
||||
[@option{-w[lLiaprmfFsoRt]}|
|
||||
@option{--debug-dump}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index]]
|
||||
[@option{-w[lLiaprmfFsoRtUuTgAckK]}|
|
||||
@option{--debug-dump}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]]
|
||||
[@option{--dwarf-depth=@var{n}}]
|
||||
[@option{--dwarf-start=@var{n}}]
|
||||
[@option{-I}|@option{--histogram}]
|
||||
@ -4803,44 +4767,9 @@ Displays the file symbol index information contained in the header part
|
||||
of binary archives. Performs the same function as the @option{t}
|
||||
command to @command{ar}, but without using the BFD library. @xref{ar}.
|
||||
|
||||
@item -w[lLiaprmfFsoRt]
|
||||
@itemx --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index]
|
||||
Displays the contents of the debug sections in the file, if any are
|
||||
present. If one of the optional letters or words follows the switch
|
||||
then only data found in those specific sections will be dumped.
|
||||
|
||||
Note that there is no single letter option to display the content of
|
||||
trace sections or .gdb_index.
|
||||
|
||||
Note: the @option{=decodedline} option will display the interpreted
|
||||
contents of a .debug_line section whereas the @option{=rawline} option
|
||||
dumps the contents in a raw format.
|
||||
|
||||
Note: the @option{=frames-interp} option will display the interpreted
|
||||
contents of a .debug_frame section whereas the @option{=frames} option
|
||||
dumps the contents in a raw format.
|
||||
|
||||
Note: the output from the @option{=info} option can also be affected
|
||||
by the options @option{--dwarf-depth} and @option{--dwarf-start}.
|
||||
|
||||
@item --dwarf-depth=@var{n}
|
||||
Limit the dump of the @code{.debug_info} section to @var{n} children.
|
||||
This is only useful with @option{--debug-dump=info}. The default is
|
||||
to print all DIEs; the special value 0 for @var{n} will also have this
|
||||
effect.
|
||||
|
||||
With a non-zero value for @var{n}, DIEs at or deeper than @var{n}
|
||||
levels will not be printed. The range for @var{n} is zero-based.
|
||||
|
||||
@item --dwarf-start=@var{n}
|
||||
Print only DIEs beginning with the DIE numbered @var{n}. This is only
|
||||
useful with @option{--debug-dump=info}.
|
||||
|
||||
If specified, this option will suppress printing of any header
|
||||
information and all DIEs before the DIE numbered @var{n}. Only
|
||||
siblings and children of the specified DIE will be printed.
|
||||
|
||||
This can be used in conjunction with @option{--dwarf-depth}.
|
||||
@item -w[lLiaprmfFsoRtUuTgAckK]
|
||||
@itemx --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]
|
||||
@include debug.options.texi
|
||||
|
||||
@item -I
|
||||
@itemx --histogram
|
||||
|
141
binutils/doc/debug.options.texi
Normal file
141
binutils/doc/debug.options.texi
Normal file
@ -0,0 +1,141 @@
|
||||
@c This file contains the entry for the -w/--debug-dump (readelf) and
|
||||
@c -W/--dwarf (objdump) option that is common to both readelf and objdump.
|
||||
|
||||
Displays the contents of the DWARF debug sections in the file, if any
|
||||
are present. Compressed debug sections are automatically decompressed
|
||||
(temporarily) before they are displayed. If one or more of the
|
||||
optional letters or words follows the switch then only those type(s)
|
||||
of data will be dumped. The letters and words refer to the following
|
||||
information:
|
||||
|
||||
@c Please Keep This Table Alpha Sorted.
|
||||
@table @code
|
||||
@item a
|
||||
@itemx =abbrev
|
||||
Displays the contents of the @samp{.debug_abbrev} section.
|
||||
|
||||
@item A
|
||||
@itemx =addr
|
||||
Displays the contents of the @samp{.debug_addr} section.
|
||||
|
||||
@item c
|
||||
@itemx =cu_index
|
||||
Displays the contents of the @samp{.debug_cu_index} and/or
|
||||
@samp{.debug_tu_index} sections.
|
||||
|
||||
@item f
|
||||
@itemx =frames
|
||||
Display the raw contents of a @samp{.debug_frame} section.
|
||||
|
||||
@item F
|
||||
@item =frame-interp
|
||||
Display the interpreted contents of a @samp{.debug_frame} section.
|
||||
|
||||
@item g
|
||||
@itemx =gdb_index
|
||||
Displays the contents of the @samp{.gdb_index} and/or
|
||||
@samp{.debug_names} sections.
|
||||
|
||||
@item i
|
||||
@itemx =info
|
||||
Displays the contents of the @samp{.debug_info} section. Note: the
|
||||
output from this option can also be restricted by the use of the
|
||||
@option{--dwarf-depth} and @option{--dwarf-start} options.
|
||||
|
||||
@item k
|
||||
@itemx =links
|
||||
Displays the contents of the @samp{.gnu_debuglink} and/or
|
||||
@samp{.gnu_debugaltlink} sections.
|
||||
|
||||
@item K
|
||||
@itemx =follow-links
|
||||
Display the contents of any selected debug sections that are found in
|
||||
a linked, separate debug info file. This can result in multiple
|
||||
versions of the same debug section being displayed if both the main
|
||||
file and the separate debug info file contain sections with the same
|
||||
name.
|
||||
|
||||
When displaying other debug information, if a link is encountered to
|
||||
a separate debug info file, then attempt to follow the link and
|
||||
display the referenced contents.
|
||||
|
||||
@item l
|
||||
@itemx =rawline
|
||||
Displays the contents of the @samp{.debug_line} section in a raw
|
||||
format.
|
||||
|
||||
@item L
|
||||
@item =decodedline
|
||||
Displays the interpreted contents of the @samp{.debug_line} section.
|
||||
|
||||
@item m
|
||||
@itemx =macro
|
||||
Displays the contents of the @samp{.debug_macro} and/or
|
||||
@samp{.debug_macinfo} sections.
|
||||
|
||||
@item o
|
||||
@itemx =loc
|
||||
Displays the contents of the @samp{.debug_loc} and/or
|
||||
@samp{.debug_loclists} sections.
|
||||
|
||||
@item p
|
||||
@itemx =pubnames
|
||||
Displays the contents of the @samp{.debug_pubnames} and/or
|
||||
@samp{.debug_gnu_pubnames} sections.
|
||||
|
||||
@item r
|
||||
@itemx =aranges
|
||||
Displays the contents of the @samp{.debug_aranges} section.
|
||||
|
||||
@item R
|
||||
@itemx =Ranges
|
||||
Displays the contents of the @samp{.debug_ranges} and/or
|
||||
@samp{.debug_rnglists} sections.
|
||||
|
||||
@item s
|
||||
@itemx =str
|
||||
Displays the contents of the @samp{.debug_str}, @samp{.debug_line_str}
|
||||
and/or @samp{.debug_str_offsets} sections.
|
||||
|
||||
@item t
|
||||
@itemx =pubtype
|
||||
Displays the contents of the @samp{.debug_pubtypes} and/or
|
||||
@samp{.debug_gnu_pubtypes} sections.
|
||||
|
||||
@item T
|
||||
@itemx =trace_aranges
|
||||
Displays the contents of the @samp{.trace_aranges} section.
|
||||
|
||||
@item u
|
||||
@itemx =trace_abbrev
|
||||
Displays the contents of the @samp{.trace_abbrev} section.
|
||||
|
||||
@item U
|
||||
@itemx =trace_info
|
||||
Displays the contents of the @samp{.trace_info} section.
|
||||
|
||||
@end table
|
||||
|
||||
Note: displaying the contents of @samp{.debug_static_funcs},
|
||||
@samp{.debug_static_vars} and @samp{debug_weaknames} sections is not
|
||||
currently supported.
|
||||
|
||||
@item --dwarf-depth=@var{n}
|
||||
Limit the dump of the @code{.debug_info} section to @var{n} children.
|
||||
This is only useful with @option{--debug-dump=info}. The default is
|
||||
to print all DIEs; the special value 0 for @var{n} will also have this
|
||||
effect.
|
||||
|
||||
With a non-zero value for @var{n}, DIEs at or deeper than @var{n}
|
||||
levels will not be printed. The range for @var{n} is zero-based.
|
||||
|
||||
@item --dwarf-start=@var{n}
|
||||
Print only DIEs beginning with the DIE numbered @var{n}. This is only
|
||||
useful with @option{--debug-dump=info}.
|
||||
|
||||
If specified, this option will suppress printing of any header
|
||||
information and all DIEs before the DIE numbered @var{n}. Only
|
||||
siblings and children of the specified DIE will be printed.
|
||||
|
||||
This can be used in conjunction with @option{--dwarf-depth}.
|
||||
|
946
binutils/dwarf.c
946
binutils/dwarf.c
File diff suppressed because it is too large
Load Diff
@ -116,6 +116,9 @@ enum dwarf_section_display_enum
|
||||
debug_addr,
|
||||
dwp_cu_index,
|
||||
dwp_tu_index,
|
||||
gnu_debuglink,
|
||||
gnu_debugaltlink,
|
||||
separate_debug_str,
|
||||
max
|
||||
};
|
||||
|
||||
@ -125,30 +128,31 @@ struct dwarf_section
|
||||
or not. COMPRESSED_NAME and UNCOMPRESSED_NAME are the two
|
||||
possibilities. NAME is set to whichever one is used for this
|
||||
input file, as determined by load_debug_section(). */
|
||||
const char *uncompressed_name;
|
||||
const char *compressed_name;
|
||||
const char *name;
|
||||
unsigned char *start;
|
||||
dwarf_vma address;
|
||||
dwarf_size_type size;
|
||||
enum dwarf_section_display_enum abbrev_sec;
|
||||
|
||||
const char * uncompressed_name;
|
||||
const char * compressed_name;
|
||||
const char * name;
|
||||
/* If non-NULL then FILENAME is the name of the separate debug info
|
||||
file containing the section. */
|
||||
const char * filename;
|
||||
unsigned char * start;
|
||||
dwarf_vma address;
|
||||
dwarf_size_type size;
|
||||
enum dwarf_section_display_enum abbrev_sec;
|
||||
/* Used by clients to help them implement the reloc_at callback. */
|
||||
void * reloc_info;
|
||||
unsigned long num_relocs;
|
||||
|
||||
void * reloc_info;
|
||||
unsigned long num_relocs;
|
||||
/* A spare field for random use. */
|
||||
void *user_data;
|
||||
void * user_data;
|
||||
};
|
||||
|
||||
/* A structure containing the name of a debug section
|
||||
and a pointer to a function that can decode it. */
|
||||
struct dwarf_section_display
|
||||
{
|
||||
struct dwarf_section section;
|
||||
int (*display) (struct dwarf_section *, void *);
|
||||
int *enabled;
|
||||
bfd_boolean relocate;
|
||||
struct dwarf_section section;
|
||||
int (* display) (struct dwarf_section *, void *);
|
||||
int * enabled;
|
||||
bfd_boolean relocate;
|
||||
};
|
||||
|
||||
extern struct dwarf_section_display debug_displays [];
|
||||
@ -204,6 +208,7 @@ extern int do_trace_aranges;
|
||||
extern int do_debug_addr;
|
||||
extern int do_debug_cu_index;
|
||||
extern int do_wide;
|
||||
extern int do_debug_links;
|
||||
|
||||
extern int dwarf_cutoff_level;
|
||||
extern unsigned long dwarf_start_die;
|
||||
@ -217,8 +222,11 @@ extern void init_dwarf_regnames_x86_64 (void);
|
||||
extern void init_dwarf_regnames_aarch64 (void);
|
||||
extern void init_dwarf_regnames_s390 (void);
|
||||
|
||||
extern int load_debug_section (enum dwarf_section_display_enum, void *);
|
||||
extern void free_debug_section (enum dwarf_section_display_enum);
|
||||
extern bfd_boolean load_debug_section (enum dwarf_section_display_enum, void *);
|
||||
extern void free_debug_section (enum dwarf_section_display_enum);
|
||||
extern void * load_separate_debug_file (void *, const char *);
|
||||
extern void close_debug_file (void *);
|
||||
extern void * open_debug_file (const char *);
|
||||
|
||||
extern void free_debug_memory (void);
|
||||
|
||||
|
@ -125,10 +125,10 @@ byte_put_big_endian (unsigned char * field, elf_vma value, int size)
|
||||
}
|
||||
}
|
||||
|
||||
elf_vma (*byte_get) (unsigned char *, int);
|
||||
elf_vma (*byte_get) (const unsigned char *, int);
|
||||
|
||||
elf_vma
|
||||
byte_get_little_endian (unsigned char *field, int size)
|
||||
byte_get_little_endian (const unsigned char *field, int size)
|
||||
{
|
||||
switch (size)
|
||||
{
|
||||
@ -231,7 +231,7 @@ byte_get_little_endian (unsigned char *field, int size)
|
||||
}
|
||||
|
||||
elf_vma
|
||||
byte_get_big_endian (unsigned char *field, int size)
|
||||
byte_get_big_endian (const unsigned char *field, int size)
|
||||
{
|
||||
switch (size)
|
||||
{
|
||||
@ -341,7 +341,7 @@ byte_get_big_endian (unsigned char *field, int size)
|
||||
}
|
||||
|
||||
elf_vma
|
||||
byte_get_signed (unsigned char *field, int size)
|
||||
byte_get_signed (const unsigned char *field, int size)
|
||||
{
|
||||
elf_vma x = byte_get (field, size);
|
||||
|
||||
@ -373,7 +373,7 @@ byte_get_signed (unsigned char *field, int size)
|
||||
of an 8-byte value separately. */
|
||||
|
||||
void
|
||||
byte_get_64 (unsigned char *field, elf_vma *high, elf_vma *low)
|
||||
byte_get_64 (const unsigned char *field, elf_vma *high, elf_vma *low)
|
||||
{
|
||||
if (byte_get == byte_get_big_endian)
|
||||
{
|
||||
|
@ -35,11 +35,11 @@ extern void (*byte_put) (unsigned char *, elf_vma, int);
|
||||
extern void byte_put_little_endian (unsigned char *, elf_vma, int);
|
||||
extern void byte_put_big_endian (unsigned char *, elf_vma, int);
|
||||
|
||||
extern elf_vma (*byte_get) (unsigned char *, int);
|
||||
extern elf_vma byte_get_signed (unsigned char *, int);
|
||||
extern elf_vma byte_get_little_endian (unsigned char *, int);
|
||||
extern elf_vma byte_get_big_endian (unsigned char *, int);
|
||||
extern void byte_get_64 (unsigned char *, elf_vma *, elf_vma *);
|
||||
extern elf_vma (*byte_get) (const unsigned char *, int);
|
||||
extern elf_vma byte_get_signed (const unsigned char *, int);
|
||||
extern elf_vma byte_get_little_endian (const unsigned char *, int);
|
||||
extern elf_vma byte_get_big_endian (const unsigned char *, int);
|
||||
extern void byte_get_64 (const unsigned char *, elf_vma *, elf_vma *);
|
||||
|
||||
#define BYTE_PUT(field, val) byte_put (field, val, sizeof (field))
|
||||
#define BYTE_GET(field) byte_get (field, sizeof (field))
|
||||
|
@ -214,11 +214,11 @@ usage (FILE *stream, int status)
|
||||
-g, --debugging Display debug information in object file\n\
|
||||
-e, --debugging-tags Display debug information using ctags style\n\
|
||||
-G, --stabs Display (in raw form) any STABS info in the file\n\
|
||||
-W[lLiaprmfFsoRt] or\n\
|
||||
-W[lLiaprmfFsoRtUuTgAckK] or\n\
|
||||
--dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,\n\
|
||||
=frames-interp,=str,=loc,=Ranges,=pubtypes,\n\
|
||||
=gdb_index,=trace_info,=trace_abbrev,=trace_aranges,\n\
|
||||
=addr,=cu_index]\n\
|
||||
=addr,=cu_index,=links,=follow-links]\n\
|
||||
Display DWARF info in the file\n\
|
||||
-t, --syms Display the contents of the symbol table(s)\n\
|
||||
-T, --dynamic-syms Display the contents of the dynamic symbol table\n\
|
||||
@ -348,10 +348,10 @@ static struct option long_options[]=
|
||||
{"prefix", required_argument, NULL, OPTION_PREFIX},
|
||||
{"prefix-strip", required_argument, NULL, OPTION_PREFIX_STRIP},
|
||||
{"insn-width", required_argument, NULL, OPTION_INSN_WIDTH},
|
||||
{"dwarf-depth", required_argument, 0, OPTION_DWARF_DEPTH},
|
||||
{"dwarf-start", required_argument, 0, OPTION_DWARF_START},
|
||||
{"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK},
|
||||
{"inlines", no_argument, 0, OPTION_INLINES},
|
||||
{"dwarf-depth", required_argument, 0, OPTION_DWARF_DEPTH},
|
||||
{"dwarf-start", required_argument, 0, OPTION_DWARF_START},
|
||||
{"dwarf-check", no_argument, 0, OPTION_DWARF_CHECK},
|
||||
{"inlines", no_argument, 0, OPTION_INLINES},
|
||||
{0, no_argument, 0, 0}
|
||||
};
|
||||
|
||||
@ -2459,19 +2459,23 @@ disassemble_data (bfd *abfd)
|
||||
free (sorted_syms);
|
||||
}
|
||||
|
||||
static int
|
||||
static bfd_boolean
|
||||
load_specific_debug_section (enum dwarf_section_display_enum debug,
|
||||
asection *sec, void *file)
|
||||
{
|
||||
struct dwarf_section *section = &debug_displays [debug].section;
|
||||
bfd *abfd = (bfd *) file;
|
||||
bfd_byte *contents;
|
||||
bfd_boolean ret;
|
||||
|
||||
/* If it is already loaded, do nothing. */
|
||||
if (section->start != NULL)
|
||||
return 1;
|
||||
{
|
||||
/* If it is already loaded, do nothing. */
|
||||
if (streq (section->filename, bfd_get_filename (abfd)))
|
||||
return TRUE;
|
||||
free (section->start);
|
||||
}
|
||||
|
||||
section->filename = bfd_get_filename (abfd);
|
||||
section->reloc_info = NULL;
|
||||
section->num_relocs = 0;
|
||||
section->address = bfd_get_section_vma (abfd, sec);
|
||||
@ -2484,13 +2488,16 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
|
||||
free_debug_section (debug);
|
||||
printf (_("\nCan't get contents for section '%s'.\n"),
|
||||
section->name);
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
/* Ensure any string section has a terminating NUL. */
|
||||
section->start[section->size] = 0;
|
||||
|
||||
if (is_relocatable && debug_displays [debug].relocate)
|
||||
{
|
||||
long reloc_size;
|
||||
bfd_boolean ret;
|
||||
|
||||
bfd_cache_section_contents (sec, section->start);
|
||||
|
||||
ret = bfd_simple_get_relocated_section_contents (abfd,
|
||||
@ -2503,11 +2510,9 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
|
||||
free_debug_section (debug);
|
||||
printf (_("\nCan't get contents for section '%s'.\n"),
|
||||
section->name);
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
long reloc_size;
|
||||
|
||||
reloc_size = bfd_get_reloc_upper_bound (abfd, sec);
|
||||
if (reloc_size > 0)
|
||||
{
|
||||
@ -2527,7 +2532,7 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bfd_boolean
|
||||
@ -2548,7 +2553,7 @@ reloc_at (struct dwarf_section * dsec, dwarf_vma offset)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
bfd_boolean
|
||||
load_debug_section (enum dwarf_section_display_enum debug, void *file)
|
||||
{
|
||||
struct dwarf_section *section = &debug_displays [debug].section;
|
||||
@ -2557,7 +2562,10 @@ load_debug_section (enum dwarf_section_display_enum debug, void *file)
|
||||
|
||||
/* If it is already loaded, do nothing. */
|
||||
if (section->start != NULL)
|
||||
return 1;
|
||||
{
|
||||
if (streq (section->filename, bfd_get_filename (abfd)))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Locate the debug section. */
|
||||
sec = bfd_get_section_by_name (abfd, section->uncompressed_name);
|
||||
@ -2570,7 +2578,7 @@ load_debug_section (enum dwarf_section_display_enum debug, void *file)
|
||||
section->name = section->compressed_name;
|
||||
}
|
||||
if (sec == NULL)
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
return load_specific_debug_section (debug, sec, file);
|
||||
}
|
||||
@ -2606,6 +2614,29 @@ free_debug_section (enum dwarf_section_display_enum debug)
|
||||
section->size = 0;
|
||||
}
|
||||
|
||||
void
|
||||
close_debug_file (void * file)
|
||||
{
|
||||
bfd * abfd = (bfd *) file;
|
||||
|
||||
bfd_close (abfd);
|
||||
}
|
||||
|
||||
void *
|
||||
open_debug_file (const char * pathname)
|
||||
{
|
||||
bfd * data;
|
||||
|
||||
data = bfd_openr (pathname, NULL);
|
||||
if (data == NULL)
|
||||
return NULL;
|
||||
|
||||
if (! bfd_check_format (data, bfd_object))
|
||||
return NULL;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static void
|
||||
dump_dwarf_section (bfd *abfd, asection *section,
|
||||
void *arg ATTRIBUTE_UNUSED)
|
||||
@ -2648,6 +2679,8 @@ dump_dwarf_section (bfd *abfd, asection *section,
|
||||
static void
|
||||
dump_dwarf (bfd *abfd)
|
||||
{
|
||||
bfd * separates;
|
||||
|
||||
is_relocatable = (abfd->flags & (EXEC_P | DYNAMIC)) == 0;
|
||||
|
||||
eh_addr_size = bfd_arch_bits_per_address (abfd) / 8;
|
||||
@ -2700,8 +2733,13 @@ dump_dwarf (bfd *abfd)
|
||||
break;
|
||||
}
|
||||
|
||||
separates = load_separate_debug_file (abfd, bfd_get_filename (abfd));
|
||||
|
||||
bfd_map_over_sections (abfd, dump_dwarf_section, NULL);
|
||||
|
||||
if (separates)
|
||||
bfd_map_over_sections (separates, dump_dwarf_section, NULL);
|
||||
|
||||
free_debug_memory ();
|
||||
}
|
||||
|
||||
|
2432
binutils/readelf.c
2432
binutils/readelf.c
File diff suppressed because it is too large
Load Diff
67
binutils/testsuite/binutils-all/debuglink.s
Normal file
67
binutils/testsuite/binutils-all/debuglink.s
Normal file
@ -0,0 +1,67 @@
|
||||
/* Assembler source used to create an object file for testing readelf's
|
||||
and objdump's ability to process separate debug information 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 fake .gnu_debuglink section. */
|
||||
|
||||
.section .gnu_debuglink,"",%progbits
|
||||
.asciz "this_is_a_debuglink.debug"
|
||||
.balign 4
|
||||
.4byte 0x12345678
|
||||
|
||||
/* Create a fake .gnu_debugaltlink section. */
|
||||
|
||||
.section .gnu_debugaltlink,"",%progbits
|
||||
.asciz "linkdebug.debug"
|
||||
.dc.b 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
|
||||
.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. */
|
||||
|
||||
.section .debug_str,"MS",%progbits,1
|
||||
string1:
|
||||
.asciz "string-1"
|
||||
.asciz "string-2"
|
||||
.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... */
|
||||
|
||||
.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 a string from the local string table.
|
||||
.4byte string1
|
||||
|
||||
.uleb128 0x2 ;# Use abbrev #2. This needs a string from the separate string table.
|
||||
.4byte 0x0 ;# Avoid complicated expression resolution and hard code the offset...
|
||||
|
||||
;# Minimal section alignment on alpha-* is 2, so ensure no new invalid CU
|
||||
;# will be started.
|
||||
.balign 2, 0
|
||||
debugE:
|
||||
|
@ -342,7 +342,7 @@ Raw dump of debug contents of section .debug_line:
|
||||
\[0x00000091\] Extended opcode 1: End of Sequence
|
||||
|
||||
|
||||
Decoded dump of debug contents of section .debug_line:
|
||||
Contents of the .debug_line section:
|
||||
|
||||
CU: ./main.c:
|
||||
File name Line number Starting address View
|
||||
|
54
binutils/testsuite/binutils-all/linkdebug.s
Normal file
54
binutils/testsuite/binutils-all/linkdebug.s
Normal file
@ -0,0 +1,54 @@
|
||||
/* Assembler source used to create an object file for testing readelf's
|
||||
and objdump's ability to process separate debug information 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/>. */
|
||||
|
||||
/* This is the separate debug info file. */
|
||||
|
||||
/* Create a .debug_abbrev section for use by the .debug_info section
|
||||
in the main object file. */
|
||||
|
||||
.section .debug_abbrev,"",%progbits
|
||||
abbrevs:
|
||||
.uleb128 0x01 ;# Abbrev code.
|
||||
.uleb128 0x11 ;# DW_TAG_compile_unit
|
||||
.byte 0x00 ;# DW_children_no
|
||||
.uleb128 0x03 ;# DW_AT_name
|
||||
.uleb128 0x0e ;# DW_FORM_strp
|
||||
.byte 0x00 ;# End of abbrev
|
||||
.byte 0x00
|
||||
|
||||
.uleb128 0x02 ;# Abbrev code.
|
||||
.uleb128 0x2e ;# DW_TAG_subprogram
|
||||
.byte 0x00 ;# DW_children_no
|
||||
.uleb128 0x03 ;# DW_AT_name
|
||||
.uleb128 0x1f21 ;# DW_FORM_GNU_strp_alt
|
||||
.byte 0x0 ;# End of abbrev
|
||||
.byte 0x0
|
||||
|
||||
.byte 0x0 ;# Abbrevs terminator
|
||||
|
||||
/* Create a .debug_str section for remote 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
|
||||
string3:
|
||||
.asciz "string-3"
|
||||
.asciz "string-4"
|
||||
.balign 2
|
||||
string_end:
|
||||
|
25
binutils/testsuite/binutils-all/objdump.WK2
Normal file
25
binutils/testsuite/binutils-all/objdump.WK2
Normal file
@ -0,0 +1,25 @@
|
||||
#...
|
||||
.*debuglink.o: Found separate debug info file:.*linkdebug.debug
|
||||
|
||||
Contents of the .debug_str section \(loaded from .*debuglink.o\):
|
||||
|
||||
0x00000000 73747269 6e672d31 00737472 696e672d string-1.string-
|
||||
0x00000010 3200 2.
|
||||
|
||||
Contents of the .debug_info section \(loaded from .*debuglink.o\):
|
||||
|
||||
Compilation Unit @ offset 0x0:
|
||||
Length: 0x12 \(32-bit\)
|
||||
Version: 4
|
||||
Abbrev Offset: 0x0
|
||||
Pointer Size: 4
|
||||
<0><b>: Abbrev Number: 1 \(DW_TAG_compile_unit\)
|
||||
<c> DW_AT_name : \(indirect string, offset: 0x0\): string-1
|
||||
<0><10>: Abbrev Number: 2 \(DW_TAG_subprogram\)
|
||||
<11> DW_AT_name : \(alt indirect string, offset: 0x0\) string-3
|
||||
|
||||
Contents of the .debug_str section \(loaded from .*linkdebug.debug\):
|
||||
|
||||
0x00000000 73747269 6e672d33 00737472 696e672d string-3.string-
|
||||
0x00000010 3400 4.
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
.*dw2-decodedline.o: file format .*
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: \./dw2-decodedline\.c:
|
||||
File name Line number Starting address View
|
||||
|
8
binutils/testsuite/binutils-all/objdump.Wk
Normal file
8
binutils/testsuite/binutils-all/objdump.Wk
Normal file
@ -0,0 +1,8 @@
|
||||
tmpdir/debuglink\.o: file format .*
|
||||
Contents of the \.gnu_debuglink section:
|
||||
Separate debug info file: this_is_a_debuglink\.debug
|
||||
CRC value: 0x12345678
|
||||
Contents of the \.gnu_debugaltlink section:
|
||||
Separate debug info file: linkdebug\.debug
|
||||
Build-ID \(0x18 bytes\):
|
||||
00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 01 23 45 67 89 ab cd ef
|
@ -424,6 +424,89 @@ if {[isnative] && [is_elf_format]} then {
|
||||
test_build_id_debuglink
|
||||
}
|
||||
|
||||
# Test objdump -Wk on a file containing debug links.
|
||||
|
||||
if { [is_elf_format] } then {
|
||||
set testsrc $srcdir/$subdir/debuglink.s
|
||||
|
||||
if { ![binutils_assemble $testsrc tmpdir/debuglink.o] } then {
|
||||
fail "objdump -Wk (reason: could not assemble source)"
|
||||
}
|
||||
|
||||
if [is_remote host] {
|
||||
set testfile [remote_download host tmpdir/debuglink.o]
|
||||
} else {
|
||||
set testfile tmpdir/debuglink.o
|
||||
}
|
||||
|
||||
set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -Wk $testfile" "" "/dev/null" "objdump.out"]
|
||||
|
||||
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
||||
fail "objdump -Wk (reason: unexpected output)"
|
||||
send_log $got
|
||||
send_log "\n"
|
||||
}
|
||||
|
||||
if { [regexp_diff objdump.out $srcdir/$subdir/objdump.Wk] } then {
|
||||
fail "objdump -Wk"
|
||||
} else {
|
||||
pass "objdump -Wk"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Very similar to proc test_build_id_debuglink except this time we
|
||||
# display some of the contents of the separate debug info file.
|
||||
|
||||
proc test_follow_debuglink {} {
|
||||
global srcdir
|
||||
global subdir
|
||||
global OBJDUMP
|
||||
|
||||
set test "follow-debuglink"
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/debuglink.s tmpdir/debuglink.o]} then {
|
||||
fail "$test (reason: assemble first source file)"
|
||||
return
|
||||
}
|
||||
|
||||
if {![binutils_assemble $srcdir/$subdir/linkdebug.s tmpdir/linkdebug.debug]} then {
|
||||
fail "$test (reason: assemble second source file)"
|
||||
return
|
||||
}
|
||||
|
||||
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]
|
||||
}
|
||||
|
||||
set got [remote_exec host "$OBJDUMP --dwarf=follow-links --dwarf=info --dwarf=str $tempfile" "" "/dev/null" "tmpdir/objdump.out"]
|
||||
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
||||
fail "$test (reason: unexpected error output from objdump)"
|
||||
return
|
||||
}
|
||||
|
||||
if { [regexp_diff tmpdir/objdump.out $srcdir/$subdir/objdump.WK2] } then {
|
||||
fail $test
|
||||
verbose "output is \n[file_contents objdump.out]" 2
|
||||
return
|
||||
}
|
||||
|
||||
pass $test
|
||||
|
||||
# Tidy up
|
||||
set got [remote_exec host "rm tmpdir/objdump.out"]
|
||||
set got [remote_exec host "rm $tempfile"]
|
||||
set got [remote_exec host "rm tmpdir/linkdebug.debug"]
|
||||
}
|
||||
|
||||
if {[isnative] && [is_elf_format]} then {
|
||||
test_follow_debuglink
|
||||
}
|
||||
|
||||
|
||||
# Options which are not tested: -a -d -D -R -T -x -l --stabs
|
||||
# I don't see any generic way to test any of these other than -a.
|
||||
# Tests could be written for specific targets, and that should be done
|
||||
|
@ -466,3 +466,35 @@ if {![binutils_assemble_flags $srcdir/$subdir/dwarf-attributes.S tmpdir/dwarf-at
|
||||
# Make sure that readelf can decode the contents.
|
||||
readelf_test -wi $tempfile dwarf-attributes.W {}
|
||||
}
|
||||
|
||||
# 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)"
|
||||
} else {
|
||||
if ![is_remote host] {
|
||||
set tempfile tmpdir/debuglink.o
|
||||
} else {
|
||||
set tempfile [remote_download host tmpdir/debuglink.o]
|
||||
}
|
||||
|
||||
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 {
|
||||
if {![binutils_assemble $srcdir/$subdir/linkdebug.s tmpdir/linkdebug.debug]} then {
|
||||
unresolved "readelf --debug-dump=follow-links (failed to assemble2)"
|
||||
} 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]
|
||||
}
|
||||
|
||||
readelf_test {-wKis} $tempfile objdump.WK2 {}
|
||||
}
|
||||
}
|
||||
|
||||
|
7
binutils/testsuite/binutils-all/readelf.k
Normal file
7
binutils/testsuite/binutils-all/readelf.k
Normal file
@ -0,0 +1,7 @@
|
||||
Contents of the \.gnu_debuglink section:
|
||||
Separate debug info file: this_is_a_debuglink\.debug
|
||||
CRC value: 0x12345678
|
||||
Contents of the \.gnu_debugaltlink section:
|
||||
Separate debug info file: linkdebug\.debug
|
||||
Build-ID \(0x18 bytes\):
|
||||
00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 01 23 45 67 89 ab cd ef
|
@ -1,3 +1,20 @@
|
||||
2017-11-15 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
PR 15152
|
||||
* testsuite/gas/avr/large-debug-line-table.d: Update expected
|
||||
output.
|
||||
* testsuite/gas/elf/dwarf2-11.d: Likewise.
|
||||
* testsuite/gas/elf/dwarf2-12.d: Likewise.
|
||||
* testsuite/gas/elf/dwarf2-13.d: Likewise.
|
||||
* testsuite/gas/elf/dwarf2-14.d: Likewise.
|
||||
* testsuite/gas/elf/dwarf2-15.d: Likewise.
|
||||
* testsuite/gas/elf/dwarf2-16.d: Likewise.
|
||||
* testsuite/gas/elf/dwarf2-17.d: Likewise.
|
||||
* testsuite/gas/elf/dwarf2-18.d: Likewise.
|
||||
* testsuite/gas/elf/dwarf2-5.d: Likewise.
|
||||
* testsuite/gas/elf/dwarf2-6.d: Likewise.
|
||||
* testsuite/gas/elf/dwarf2-7.d: Likewise.
|
||||
|
||||
2017-11-15 Jan Beulich <jbeulich@suse.com>
|
||||
|
||||
* testsuite/gas/i386/noextreg.s: Add tests for VEX-encoded GPR
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
.*: file format elf32-avr
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: large-debug-line-table\.c:
|
||||
File name Line number Starting address.*
|
||||
|
@ -6,7 +6,7 @@
|
||||
# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions.
|
||||
#not-target: am3*-* avr-* cr16-* crx-* ft32*-* m32c-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* tile*-* xtensa-*
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: dwarf2-11\.c:
|
||||
File name *Line number *Starting address *View
|
||||
|
@ -10,7 +10,7 @@
|
||||
Hex dump of section '\.rodata':
|
||||
0x00000000 01 *.*
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: dwarf2-12\.c:
|
||||
File name *Line number *Starting address *View
|
||||
|
@ -9,7 +9,7 @@
|
||||
Hex dump of section '\.rodata':
|
||||
0x00000000 01 *.*
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: dwarf2-13\.c:
|
||||
File name *Line number *Starting address *View
|
||||
|
@ -9,7 +9,7 @@
|
||||
Hex dump of section '\.rodata':
|
||||
0x00000000 01 *.*
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: dwarf2-14\.c:
|
||||
File name *Line number *Starting address *View
|
||||
|
@ -9,7 +9,7 @@
|
||||
Hex dump of section '\.rodata':
|
||||
0x00000000 01 *.*
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: dwarf2-15\.c:
|
||||
File name *Line number *Starting address *View
|
||||
|
@ -10,7 +10,7 @@
|
||||
Hex dump of section '\.rodata':
|
||||
0x00000000 01 *.*
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: dwarf2-16\.c:
|
||||
File name *Line number *Starting address *View
|
||||
|
@ -10,7 +10,7 @@
|
||||
Hex dump of section '\.rodata':
|
||||
0x00000000 00 *.*
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: dwarf2-17\.c:
|
||||
File name *Line number *Starting address *View
|
||||
|
@ -9,7 +9,7 @@
|
||||
Hex dump of section '\.rodata':
|
||||
0x00000000 0100 *.*
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: dwarf2-18\.c:
|
||||
File name *Line number *Starting address *View
|
||||
|
@ -60,7 +60,7 @@ Raw dump of debug contents of section \.debug_line:
|
||||
\[0x.*\] Extended opcode 1: End of Sequence
|
||||
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: dwarf2-5\.c:
|
||||
File name *Line number *Starting address *View
|
||||
|
@ -61,7 +61,7 @@ Raw dump of debug contents of section .debug_line:
|
||||
\[0x.*\] Extended opcode 1: End of Sequence
|
||||
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: dwarf2-6\.c:
|
||||
File name *Line number *Starting address *View
|
||||
|
@ -9,7 +9,7 @@
|
||||
Hex dump of section '\.rodata':
|
||||
0x00000000 01 *.*
|
||||
|
||||
Decoded dump of debug contents of section \.debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
CU: dwarf2-7\.c:
|
||||
File name *Line number *Starting address *View
|
||||
|
@ -1,3 +1,9 @@
|
||||
2017-11-15 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
PR 15152
|
||||
* testsuite/ld-avr/gc-section-debugline.d: Update expected
|
||||
output.
|
||||
|
||||
2017-11-15 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* ldmisc.c (vfinfo): Support up to 9 positional args.
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
.*: file format elf32-avr
|
||||
|
||||
Decoded dump of debug contents of section .debug_line:
|
||||
Contents of the \.debug_line section:
|
||||
|
||||
.*:
|
||||
File name Line number Starting address View
|
||||
|
Loading…
Reference in New Issue
Block a user