binutils-gdb/binutils/testsuite/binutils-all
Nick Clifton dda8d76d0d 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.
2017-11-15 11:34:03 +00:00
..
aarch64 Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
arc [ARC] Force the disassam to use the hexadecimal number for printing 2017-11-03 15:36:54 +01:00
arm Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
bfin Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
hppa Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
i386 readelf ngettext fixes 2017-11-07 17:01:16 +10:30
m68k Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
mips MIPS: Fix XPA base and Virtualization ASE instruction handling 2017-06-30 07:21:55 +01:00
vax Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
wasm32 Fix minor problems with previous wasm32 binutils commit. 2017-03-31 13:07:01 +01:00
windres Stop the (optional) dialong control data from being aligned when parsing/writing windows resource files. 2017-01-18 11:40:06 +00:00
x86-64 readelf ngettext fixes 2017-11-07 17:01:16 +10:30
add-empty-section.d
add-section.d
add-symbol.d Run add-symbol test on mips 2015-10-22 12:49:17 +10:30
alias-2.def
alias.def
ar.exp Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
bintest.s
common-1.s Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-1a.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-1b.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-1c.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-1d.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-1e.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-1f.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-2.s Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-2a.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-2b.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-2c.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-2d.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-2e.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
common-2f.d Properly implement STT_COMMON 2016-02-26 05:01:34 -08:00
compress.exp Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
copy-1.d
copy-1.s
copy-2.d
copy-3.d Fix various binutils testsuite failures. 2016-06-22 14:42:26 +01:00
copy-4.d Fix various binutils testsuite failures. 2016-06-22 14:42:26 +01:00
copytest.s
data-sections.s objcopy/strip: Allow section patterns starting with '!'. 2016-07-14 11:32:48 +01:00
debug_str.d Fixes a problem with the BFD library running out of memory because it mistakenly 2014-04-30 17:04:04 +01:00
debug_str.s Fixes a problem with the BFD library running out of memory because it mistakenly 2014-04-30 17:04:04 +01:00
debuglink.s Add support to readelf and objdump for following links to separate debug information files. 2017-11-15 11:34:03 +00:00
dlltool.exp Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
dumptest.s
dw2-1.S Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
dw2-1.W readelf ngettext fixes 2017-11-07 17:01:16 +10:30
dw2-2.S Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
dw2-3.rS Add SHF_COMPRESSED support to gas and objcopy 2015-04-08 07:54:09 -07:00
dw2-3.rt Add SHF_COMPRESSED support to gas and objcopy 2015-04-08 07:54:09 -07:00
dw2-3.S Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
dw2-3.W readelf ngettext fixes 2017-11-07 17:01:16 +10:30
dw2-3gabi.W readelf ngettext fixes 2017-11-07 17:01:16 +10:30
dw2-compressed.S Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
dw2-decodedline-1.S Remove support for the (deprecated) openrisc and or32 configurations and replace 2014-04-22 15:57:47 +01:00
dw2-decodedline.S * binutils-all/dw2-decodedline.S: Always have whitespace before 2012-02-14 01:00:50 +00:00
dw2-empty.S Don't compress empty debug section 2012-07-03 16:06:34 +00:00
dw2-ranges.S Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
dw2-ranges.W objdump: Handle 32-bit base address in debug_ranges / debug_loc. 2015-11-30 13:28:26 +00:00
dw5.S readelf ngettext fixes 2017-11-07 17:01:16 +10:30
dw5.W Add support to readelf and objdump for following links to separate debug information files. 2017-11-15 11:34:03 +00:00
dwarf-attributes.S Display more information when decoding DW_AT_endianity, DW_AT_decimal_sign, DW_AT_defaulted and DW_AT_discr_list DWARF attributes. 2017-10-11 12:02:51 +01:00
dwarf-attributes.W Display more information when decoding DW_AT_endianity, DW_AT_decimal_sign, DW_AT_defaulted and DW_AT_discr_list DWARF attributes. 2017-10-11 12:02:51 +01:00
elfedit-1.d Also skip x86_64-*-nacl* 2015-05-12 12:47:27 -07:00
elfedit-2.d
elfedit-3.d
elfedit-4.d bfd/ 2012-04-03 16:01:38 +00:00
elfedit-5.d Add EM_386/EM_IAMCU support to elfedit.c 2015-05-11 09:57:21 -07:00
elfedit.exp Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
empty Allow zero length archive elements. 2016-03-07 17:29:25 +00:00
empty-file
empty.s
exclude-1.s
exclude-1a.d
exclude-1b.d
fastcall.def
group-2.s
group-3.s
group-4.s
group-5.d
group-5.s
group-6.d
group-6.s
group.s
libdw2-compressed.out Add a dw2-3.S test 2015-04-04 07:34:25 -07:00
libdw2-compressedgabi.out readelf ngettext fixes 2017-11-07 17:01:16 +10:30
libdw2.out Add a dw2-3.S test 2015-04-04 07:34:25 -07:00
link-order.s
linkdebug.s Add support to readelf and objdump for following links to separate debug information files. 2017-11-15 11:34:03 +00:00
localize-hidden-1.d Fix the evaluation of RL78 complex relocs, by making immediate values be computed relative to a new absolute symbol. 2015-07-24 16:44:27 +01:00
localize-hidden-1.s
localize-hidden-2.d
localize-hidden-2.s
locview-1.s LVU: dump loclists with locviews 2017-09-22 17:05:51 -03:00
locview-2.s LVU: dump loclists with locviews 2017-09-22 17:05:51 -03:00
mbind1.s Support ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX 2017-04-04 09:06:04 -07:00
needed-by-reloc.s
nm-1.s * binutils-all/nm.exp: --size-sort test: Add more ELF-like 2013-08-22 11:29:43 +00:00
nm-elf-1.s binutils/ 2013-08-19 15:08:52 +00:00
nm-ver.s Add the ability for nm to display symbol version information. 2016-11-11 11:49:45 +00:00
nm.exp Add support for the WebAssembly file format and the wasm32 ELF conversion to gas and the binutils. 2017-03-30 10:57:21 +01:00
note-1.d
note-2-32.d Try harder to find the correct symbol to associate with OPEN GNU BUILD notes. 2017-03-14 12:57:09 +00:00
note-2-32.s Improve decoding of corrupt/unrecognised gnu build attribute notes. 2017-04-26 14:23:26 +01:00
note-2-64.d Try harder to find the correct symbol to associate with OPEN GNU BUILD notes. 2017-03-14 12:57:09 +00:00
note-2-64.s Improve decoding of corrupt/unrecognised gnu build attribute notes. 2017-04-26 14:23:26 +01:00
note-3-32.d Add test of V2 GNU build attribute notes. 2017-08-17 14:51:31 +01:00
note-3-32.s Add test of V2 GNU build attribute notes. 2017-08-17 14:51:31 +01:00
note-3-64.d Add test of V2 GNU build attribute notes. 2017-08-17 14:51:31 +01:00
note-3-64.s Add test of V2 GNU build attribute notes. 2017-08-17 14:51:31 +01:00
note-3.32.s Add test of V2 GNU build attribute notes. 2017-08-17 14:51:31 +01:00
objcopy.exp Add test of V2 GNU build attribute notes. 2017-08-17 14:51:31 +01:00
objdump.exp Add support to readelf and objdump for following links to separate debug information files. 2017-11-15 11:34:03 +00:00
objdump.s
objdump.W readelf ngettext fixes 2017-11-07 17:01:16 +10:30
objdump.Wk Add support to readelf and objdump for following links to separate debug information files. 2017-11-15 11:34:03 +00:00
objdump.WK2 Add support to readelf and objdump for following links to separate debug information files. 2017-11-15 11:34:03 +00:00
objdump.WL Add support to readelf and objdump for following links to separate debug information files. 2017-11-15 11:34:03 +00:00
only-section-01.d objcopy/strip: Allow section patterns starting with '!'. 2016-07-14 11:32:48 +01:00
pr18374.s Fix PR18374 by making readelf and objdump ignore end-of-list markers in the .debug_loc section if there are relocations against them. 2015-05-15 11:24:33 +01:00
pr19020.in Don't use the output section size to copy input section 2015-09-29 13:31:57 -07:00
pr19020a.d Don't use the output section size to copy input section 2015-09-29 13:31:57 -07:00
pr19020b.d Don't use the output section size to copy input section 2015-09-29 13:31:57 -07:00
pr19547.c Clear HAS_RELOC if there are no relocations 2016-02-02 03:30:48 -08:00
readelf.exp Add support to readelf and objdump for following links to separate debug information files. 2017-11-15 11:34:03 +00:00
readelf.h
readelf.k Add support to readelf and objdump for following links to separate debug information files. 2017-11-15 11:34:03 +00:00
readelf.locview-1 LVU: dump loclists with locviews 2017-09-22 17:05:51 -03:00
readelf.locview-2 LVU: dump loclists with locviews 2017-09-22 17:05:51 -03:00
readelf.n Display unknown notes. Decode NT_GNU_HWCAP notes. 2016-10-17 15:29:43 +01:00
readelf.pr18374 Fix PR18374 by making readelf and objdump ignore end-of-list markers in the .debug_loc section if there are relocations against them. 2015-05-15 11:24:33 +01:00
readelf.r readelf ngettext fixes 2017-11-07 17:01:16 +10:30
readelf.r-64 readelf ngettext fixes 2017-11-07 17:01:16 +10:30
readelf.s Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
readelf.s-64 Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
readelf.ss readelf -s test: Skip extra symbols produced by MSP430 assembler. 2014-03-17 11:00:32 +00:00
readelf.ss-64 Fix the binutils readelf.ss test for the AArch64 target. 2015-04-02 15:28:02 +01:00
readelf.ss-mips MIPS testsuite cleanup - part 1 2014-09-06 17:58:37 +01:00
readelf.ss-tmips [MIPS] Implement O32 FPXX, FP64 and FP64A ABI extensions 2014-07-29 11:27:59 +01:00
readelf.wa Display null bytes in DWARF debug info 2012-08-02 13:42:59 +00:00
readelf.z Add --decompress option to readelf to decompress sections before they are dumped. 2015-05-15 17:16:31 +01:00
remove-relocs-01.d objcopy/strip: Add option --remove-relocations=SECTIONPATTERN 2016-07-14 11:34:10 +01:00
remove-relocs-01.s Use address sized relocs in remove-relocs-01.s 2016-07-15 17:02:20 +09:30
remove-relocs-02.d objcopy/strip: Add option --remove-relocations=SECTIONPATTERN 2016-07-14 11:34:10 +01:00
remove-relocs-03.d objcopy/strip: Add option --remove-relocations=SECTIONPATTERN 2016-07-14 11:34:10 +01:00
remove-relocs-04.d objcopy/strip: Add option --remove-relocations=SECTIONPATTERN 2016-07-14 11:34:10 +01:00
remove-relocs-05.d objcopy/strip: Add option --remove-relocations=SECTIONPATTERN 2016-07-14 11:34:10 +01:00
remove-relocs-06.d objcopy/strip: Add option --remove-relocations=SECTIONPATTERN 2016-07-14 11:34:10 +01:00
remove-section-01.d objcopy/strip: Allow section patterns starting with '!'. 2016-07-14 11:32:48 +01:00
size.exp Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
strip-1.d
strip-2.d
strip-3.d [ARC] Object attributes. 2017-05-10 14:42:22 +02:00
strip-4.d
strip-5.d
strip-6.d
strip-7.d
strip-8.d
strip-9.d
strip-10.d My patch to the binutils strip-10.d test was wrong. The osabi field should always be set to 2014-01-29 14:01:54 +00:00
strip-11.d Fix the evaluation of RL78 complex relocs, by making immediate values be computed relative to a new absolute symbol. 2015-07-24 16:44:27 +01:00
strip-12.d Tweak binutils testsuite 2015-08-11 23:29:36 +09:30
strip-12.s Tweak binutils testsuite 2015-08-11 23:29:36 +09:30
symbols-1.d Tweak binutils testsuite 2015-08-11 23:29:36 +09:30
symbols-2.d Tweak binutils testsuite 2015-08-11 23:29:36 +09:30
symbols-3.d Tweak binutils testsuite 2015-08-11 23:29:36 +09:30
symbols-4.d Tweak binutils testsuite 2015-08-11 23:29:36 +09:30
symbols.s objcopy: Improve wildcard matching for symbols with '!' prefix. 2015-08-07 11:41:40 +02:00
testprog.c Fix copying Solaris binaries with objcopy. 2016-04-14 12:04:09 +01:00
testranges-ia64.d
testranges-ia64.s
testranges.d
testranges.s
unique.s
unknown.s
update-1.s objcopy: Add --update-section option. 2015-02-28 21:25:51 +00:00
update-2.s objcopy: Add --update-section option. 2015-02-28 21:25:51 +00:00
update-3.s objcopy: Add --update-section option. 2015-02-28 21:25:51 +00:00
update-4.s objcopy: Add --update-section option. 2015-02-28 21:25:51 +00:00
update-section.exp Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
version.def ChangeLog binutils 2012-02-11 20:02:03 +00:00
version.s * binutils-all/dw2-decodedline.S: Always have whitespace before 2012-02-14 01:00:50 +00:00
z.s Add --decompress option to readelf to decompress sections before they are dumped. 2015-05-15 17:16:31 +01:00