Commit Graph

62 Commits

Author SHA1 Message Date
Nick Clifton e4b7104b1e Add support for decoding the DW_MACRO_define_strx and DW_MACRO_undef_strx operands found in DWARF-5 .debug_macro sections.
PR 26112
	* dwarf.c (display_debug_str_offsets): Add code to display the
	contents of the .debug_str_offsets section.
	(display_debug_macro): Add support for DW_MACRO_define_strx and
	DW_MACRO_undef_strx.
2020-06-22 17:44:56 +01:00
Nick Clifton 546cb2d85e Restore readelf's warnings that describe real problems with the file being examined. Fix bug displaying empty file name tables.
binutils* dwarf.c (do_checks): New global variable.
	(display_formatted_table): Warn about an unexpected number of
	columns in the table, if checks are enabled.  Do not complain
	about the lack of data following the number of entries in the
	table if the table is empty.
	(display_debug_lines_decoded): Only warn about an unexpected
	number of columns in a table if checks are enabled.
	* dwarf.h (do_checks): Add a prototype.
	* elfcomm.c (error): Remove weak attribute.
	(warn): Likewise.
	* readelf.c (do_checks): Delete.
	(warn): Delete.
	(process_section_headers): Only warn about empty sections if
	checks are enabled.

gas	* dwarf2dbg.c (out_dir_and_file_list): Add comments describing the
	construction of a DWARF-5 directory name table.
	* testsuite/gas/elf/pr25917.d: Update expected output.
2020-05-05 16:16:03 +01:00
Nick Clifton 1b51340159 Add a warning if an emtpty SHT_REL, SHT_RELA or SHT_PROGBITS section is detected. Disable all warnings unless the (new) lint mode is enabled.
* readelf.c (warn): New function - like elfcomm.c version but only
	produces output if warnings are enabled.
	(struct options): Add --lint and --enable-checks.
	(usage): Add entry for --lint.
	(parse_args): Handle -L.  If checks are enabled but no dumps have
	been selected then enable all dumps.
	(process_section_headers): Replace long if-then-else sequence with
	a switch.  Add warning messages for empty SHT_REL, SHT_RELA and
	SHT_PROGBITS sections.
	(process_file): Do not complain if the file is an archive and lint
	mode has been enabled.
	* elfcomm.c (error): Make the function weak.
	(warn): Likewise.
	* NEWS: Mention the new feature.
	* doc/binutils.texi: Document the new feature.
	* dwarf.h (report_leb_status): Add file name and line number
	parameters.  Include them in the diagnostic output.
	(READ_ULEB): Pass file and line number to report_leb_status.
	(READ_SLEB): Likewise.
	* dwarf.c (read_and_print_leb128): Pass file and line number to
	report_leb_status.
	* testsuite/binutils-all/readelf.exp: Add test of new feature.
	* testsuite/binutils-all/zero-sec.s: New test source file.
	* testsuite/binutils-all/zero-sec.r: Expected output from new
	test.
2020-04-29 16:01:40 +01:00
Nick Clifton 5496f3c635 Add support for generating DWARF-5 format directory and file name tables from the assembler.
PR 25611
	PR 25614
	* dwarf.h (DWARF2_Internal_LineInfo): Add li_address_size and
	li_segment_size fields.
	* dwarf.c (read_debug_line_header): Record the address size and
	segment selector size values (if present) in the lineinfo
	structure.
	(display_formatted_table): Warn if the format count is empty but
	the table itself is not empty.
	Display the format count and entry count at the start of the table
	dump.
	(display_debug_lines_raw): Display the address size and segement
	selector size fields, if present.
	* testsuite/binutils-all/dw5.W: Update expected output.

gas	* dwarf2dbg.c (DWARF2_FILE_TIME_NAME): Default to -1.
	(DWARF2_FILE_SIZE_NAME): Default to -1.
	(DWARF2_LINE_VERSION): Default to the current dwarf level or 3,
	whichever is higher.
	(DWARF2_LINE_MAX_OPS_PER_INSN): Provide a default value of 1.
	(NUM_MD5_BYTES): Define.
	(struct file entry): Add md5 field.
	(get_filenum): Delete and replace with...
	(get_basename): New function.
	(get_directory_table_entry): New function.
	(allocate_filenum): New function.
	(allocate_filename_to_slot): New function.
	(dwarf2_where): Use new functions.
	(dwarf2_directive_filename): Add support for extended .file
	pseudo-op.
	(dwarf2_directive_loc): Allow the use of file number zero with
	DWARF 5 or higher.
	(out_file_list): Rename to...
	(out_dir_and_file_list): Add DWARF 5 support.
	(out_debug_line): Emit extra values into the section header for
	DWARF 5.
	(out_debug_str): Allow for file 0 to be used with DWARF 5.
	* doc/as.texi (.file): Update the description of this pseudo-op.
	* testsuite/gas/elf-dwarf-5-file0.s: Add more lines.
	* testsuite/gas/elf-dwarf-5-file0.d: Update expected dump output.
	* testsuite/gas/lns/lns-diag-1.l: Update expected error message.
	* NEWS: Mention the new feature.
2020-03-11 10:17:14 +00:00
Aaron Merey 301a9420d9 Add support for debuginfod to the binutils (disable by default, enabled via a configure time option).
debuginfod is a lightweight web service that indexes ELF/DWARF
debugging resources by build-id and serves them over HTTP. This patch
enables objdump and readelf to query debuginfod servers when they are
otherwise not able to find separate debug files. Binutils can be built
with debuginfod using the --with-debuginfod configure option. This
requires that libdebuginfod be installed and found at configure time.
debuginfod is packaged with elfutils, starting with version 0.178. For
more information see https://sourceware.org/elfutils/.

toplevel* config/debuginfod.m4: New file. Add macro AC_DEBUGINFOD. Adds
        new configure option --with-debuginfod.
        * configure: Regenerate.
        * configure.ac: Call AC_DEBUGINFOD.

binutils* Makefile.am (readelf_LDADD, objdump_LDADD): Add libdebuginfod.
        * Makefile.in: Regenerate.
        * NEWS: Update.
        * config.in: Regenerate.
        * configure: Regenerate.
        * configure.ac: Call AC_DEBUGINFOD.
        * doc/Makefile.in: Regenerate.
        * doc/binutils.texi: Add section on using binutils
        with debuginfod.
        * dwarf.c (debuginfod_fetch_separate_debug_info): New function.
        Query debuginfod servers for the target debug file.
        (load_separate_debug_info): Call
        debuginfod_fetch_separate_debug_info if configured with
        debuginfod.
        (load_separate_debug_files): Add file argument to
        load_separate_debug_info calls.
        * dwarf.h (get_build_id): Add declaration.
        * objdump.c (get_build_id): New function. Get build-id of file.
        * readelf.c (get_build_id): Likewise.
        * testsuite/binutils-all/debuginfod.exp: New tests.
        * testsuite/binutils-all/linkdebug.s: Add .note.gnu.build-id
        section.
2020-01-09 13:19:20 +00:00
Alan Modra b3adc24a07 Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
Alan Modra cd30bcef4a Revise sleb128 and uleb128 reader
This patch catches and reports errors when reading leb128 values,
addressing a FIXME in read_leb128.

	* dwarf.h (read_leb128): Update prototype.
	(report_leb_status): New inline function.
	(SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Define.
	* dwarf.c: Use above macros throughout file.  Formatting.
	(read_leb128): Reorder params.  Add status return param.
	Don't stop reading until finding terminator or end of data.
	Detect loss of significant bits.  Sign extend only on
	terminating byte.
	(read_sleb128, read_uleb128): Delete functions.
	(SKIP_ULEB, SKIP_SLEB, READ_ULEB, READ_SLEB): Delete macros.
	(read_and_print_leb128): Rewrite.
	(process_extended_line_op): Return a size_t.  Use size_t vars.
	Adjust to suit new macros.  Add proper name size to "data" when
	processing DW_LNE_define_file.
	(process_abbrev_section): Adjust to suit new macros.
	(decode_location_expression, skip_attr_bytes): Likewise.
	(get_type_signedness): Likewise.
	(read_and_display_attr_value): Likewise.  Consolidate block code.
	(process_debug_info): Adjust to suit new macros.
	(display_formatted_table, display_debug_lines_raw): Likewise.
	(display_debug_lines_decoded): Likewise.  Properly check for end
	of DW_LNS_extended_op.
	(display_debug_macinfo): Adjust to suit new macros.
	(get_line_filename_and_dirname, display_debug_macro): Likewise.
	(display_view_pair_list): Likewise.  Don't back off when hitting
	end of data.
	(display_loc_list): Adjust to suit new macros.
	(display_loclists_list, display_loc_list_dwo): Likewise.
	(display_debug_rnglists_list, read_cie): Likewise.
	(display_debug_frames): Likewise.
	* readelf.c: Use new ULEB macros throughout file.
	(read_uleb128): Delete.
	(decode_arm_unwind_bytecode): Use read_leb128.
	(decode_tic6x_unwind_bytecode): Likewise.
	(display_tag_value): Adjust to suit new macros.
	(display_arc_attribute, display_arm_attribute): Likewise.
	(display_gnu_attribute, display_power_gnu_attribute): Likewise.
	(display_s390_gnu_attribute, display_sparc_gnu_attribute): Likewise.
	(display_mips_gnu_attribute, display_tic6x_attribute): Likewise.
	(display_msp430x_attribute, display_msp430_gnu_attribute): Likewise.
	(display_riscv_attribute, process_attributes): Likewise.
2019-12-23 18:01:34 +10:30
Andrew Burgess 99f6fdd9eb binutils: Make some functions static in dwarf.c
The architecture specific register name initialisation routines no
longer need to be externally visible, so make them static.

binutils/ChangeLog:

	* dwarf.c (init_dwarf_regnames_i386): Make static.
	(init_dwarf_regnames_iamcu): Make static.
	(init_dwarf_regnames_x86_64): Make static.
	(init_dwarf_regnames_aarch64): Make static.
	(init_dwarf_regnames_s390): Make static.
	(init_dwarf_regnames_riscv): Make static.
	* dwarf.h (init_dwarf_regnames_i386): Delete declaration.
	(init_dwarf_regnames_iamcu): Delete declaration.
	(init_dwarf_regnames_x86_64): Delete declaration.
	(init_dwarf_regnames_aarch64): Delete declaration.
	(init_dwarf_regnames_s390): Delete declaration.
	(init_dwarf_regnames_riscv): Delete declaration.

Change-Id: I9e350f76f98f46e9e3dd88d502f2a2a83e44cb36
2019-11-28 00:03:04 +00:00
Andrew Burgess 229a22cfd2 binutils: Add a new function to initialise DWARF register name state
Adds a new API function init_dwarf_regnames_by_bfd_arch_and_mach to
initialise the register name state from a BFD architecture and machine
type.

There should be no user visible changes after this commit.

binutils/ChangeLog:

	* dwarf.c (init_dwarf_regnames_by_bfd_arch_and_mach): New
	function.
	* dwarf.h (init_dwarf_regnames_by_bfd_arch_and_mach): Declare.
	* objdump.c (dump_dwarf): Call new function instead of calling
	specific initialization routines.  Restrucure so that eh_addr_size
	is still calculated correctly.

Change-Id: I346d665d2079a18ec4d04bd41893d0e9dc05e4b3
2019-11-28 00:03:03 +00:00
Andrew Burgess 955ff7fcf8 binutils: Rename init_dwarf_regnames
As part of a process to change how dwarf.c figures out the correct
name for a register I wanted to clean up how we initialise the
register name tracking state.

As part of this I rename init_dwarf_regnames to
init_dwarf_regnames_by_elf_machine_code, later commits will add a
different entry point to initialise the register name state.

There should be no user visible changes after this commit.

binutils/ChangeLog:

	* dwarf.c (init_dwarf_regnames): Renamed to...
	(init_dwarf_regnames_by_elf_machine_code): ...this.
	* dwarf.h (init_dwarf_regnames): Renamed to...
	(init_dwarf_regnames_by_elf_machine_code): ...this.
	* readelf.c (process_file_header): Update call to use new name.

Change-Id: Ic8d2ef5fb62a8590ecd8cbb7e6258e11c6263594
2019-11-28 00:03:03 +00:00
Nick Clifton 39f0547e55 Extend objdump's --dwarf=follow-links option so that separate debug info files will also be affected by other dump function, and symbol tables from separate debug info files will be used when disassembling the main file.
* objdump.c (sym_ok): New function.
	(find_symbol_for_address): Use new function.
	(disassemble_section): Compare sections by name, not pointer.
	(dump_dwarf): Move code to initialise byte_get pointer and iterate
	over separate debug files from here to ...
	(dump_bfd): ... here.  Add parameter indicating that a separate
	debug info file is being dumped.  For main file, pull in the
	symbol tables from all separate debug info files.
	(display_object): Update call to dump_bfd.
	* doc/binutils.texi: Document extened behaviour of the
	--dwarf=follow-links option.
	* NEWS: Mention this new feature.
	* testsuite/binutils-all/objdump.WK2: Update expected output.
	* testsuite/binutils-all/objdump.exp (test_follow_debuglink): Add
	options and dump file parameters.
	Add extra test.
	* testsuite/binutils-all/objdump.WK3: New file.
	* testsuite/binutils-all/readelf.exp: Change expected output for
	readelf -wKis test.
	* testsuite/binutils-all/readelf.wKis: New file.
2019-02-25 12:15:41 +00:00
Nick Clifton 24841daa74 Extend readelf and objdump so that they will display and follow multiple links to separate debug information files.
PR 23843
	* dwarf.h (struct separate_info): New structure for containing
	information on separate debug info files.
	* dwarf.c (struct dwo_info): New structure for containing dwo
	links.
	(first_dwo_info): Chain of dwo_info structures.
	(first_separate_file): Chain of separate_info structures.
	(separate_debug_file, separate_debug_filename): Delete.
	(fetch_alt_indirect_string): Scan all separate debug info files
	for the requested string.
	(add_dwo_info): New function.
	(add_dwo_name): New function.
	(add_dwo_dir): New function.
	(add_dwo_id: New function.
	(free_dwo_info): New function.
	(read_and_display_attr_value): Store DWO data using the new
	functions.
	(load_debug_section_with_follow): If necessary, scan the list of
	separate debug info files for the requested section.
	(add_separate_debug_file): New function.
	(load_separate_debug_info): Call add_separate_debug_file to store
	the information on the newly loaded file.
	(load_dwo_file): Likewise.
	(load_separate_debif_file): Rename to load_separate_debug_files.
	Change return type to boolean.  If following links then attempt to
	load all separate debug info files, not just the first one.
	(free_debug_memory): Release memory in dwo_info and separate_info
	chains.
	* objdump.c (dump_dwarf): Iterate over all loaded debg info files.
	* readelf.c (process_object): Likewise.
	* doc/debug.options.texi: Update descriptions of links and
	follow-links options.
	* testsuite/binutils-all/objdump.WK2: Update expected output.
	* testsuite/binutils-all/readelf.k2: Likewise.
	* NEWS: Announce the new feature.
2019-02-22 10:36:24 +00:00
Alan Modra 827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
Andrew Burgess 5bb0830d10 binutils/riscv: Register names in DWARF output
Adds a register name table for RiscV so that objdump and readelf can
both use better register names.

binutils/ChangeLog:

	* dwarf.c (dwarf_regnames_riscv): New register name table.
	(init_dwarf_regnames_riscv): New function.
	(init_dwarf_regnames): Add call to initialise RiscV register
	names.
	* dwarf.h (init_dwarf_regnames_riscv): Declare.
	* objdump.c (dump_dwarf): Add call to initialise RiscV register
	names.
2018-02-02 18:50:40 +00:00
Alan Modra 219d1afa89 Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
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
Alexandre Oliva 9f27220911 LVU: dump loclists with locviews
When dumping location lists, also dump locview lists that may be
interspersed with them, and bring view pairs next to the corresponding
location list entries.

This patch supports DW_AT_GNU_locviews as a separate attribute for
DWARF4- loc_lists and split (dwo) loclists, as well as DWARF5
loclists.

It also supports, in DWARF5 loclists, the proposed
DW_LLE_GNU_view_pair loclist entry type proposed for DWARF6.


The tests use 32-bit DWARF, even on 64-bit targets, resolving offsets
to constants so as to reduce the risk that relocations be created for
them, or that the offsets be rejected as nonconstants.


The patch also adds an xfail to an unrelated test, namely dw5, so that
no unexpected fails remain on nds32*-elf, one of the tested targets.


Reviewed-by: Alan Modra <amodra@gmail.com>


for  include/ChangeLog

	* dwarf2.def (DW_AT_GNU_locviews): New.
	* dwarf2.h (enum dwarf_location_list_entry_type): Add
	DW_LLE_GNU_view_pair.
	(DW_LLE_view_pair): Define.

for  binutils/ChangeLog

	* dwarf.h (debug_info): Add loc_views and num_loc_views.
	* dwarf.c (vm1): New constant.
	(print_dwarf_view): New function.
	(read_and_display_attr_value): Support DW_AT_GNU_locviews.
	(process_debug_info): Keep num_loc_offsets and num_loc_views
	in sync.
	(display_view_pair_list): New function.
	(display_loc_list_dwo): Take vstart_ptr; update it.  Dump
	location view pairs before the range they apply to, when a
	viewlist augments the loc list.
	(display_loc_list): Likewise.  Check view numbers in range
	tests.
	(display_loclists_list): Likewise.  Handle view pair entries,
	and warn on trailing ones.
	(loc_views): New variable.
	(loc_offsets_compar): Compare loc_views if loc_offsets are the
	same.
	(display_debug_loc): Check and sort loc_views too.  Accept
	loc_view as expected_start.  Skip if lists and views are the
	same.  Dump locview list separately in order, and pass the
	locview list base to each list dump function.  Warn and skip
	overlap and hole checking if we find loclists and locviews to
	not be adjacent.
	* testsuite/binutils-all/locview-1.s: New.
	* testsuite/binutils-all/readelf.locview-1: New.
	* testsuite/binutils-all/locview-2.s: New.
	* testsuite/binutils-all/readelf.locview-2: New.
	* testsuite/binutils-all/readelf.exp: Run new tests.  Fix
	option spelling in pr18374 fail message.  XFAIL dw5 test on
	nds32*-elf.
2017-09-22 17:05:51 -03:00
Jan Kratochvil 613643582c DWARF-5: readelf: .debug_names
Display DWARF-5 .debug_names (standardized .gdb_index).

binutils/ChangeLog
2017-07-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c: Include assert.h.
	(MAX, MIN, get_IDX_name, display_debug_names): New.
	(debug_displays): Add .debug_names.
	* dwarf.h: (enum dwarf_section_display_enum): Add debug_names.
	* readelf.c (process_section_headers): Add ".debug_names".
2017-07-02 22:15:05 +02:00
Jan Kratochvil d4620bee57 Fix dwarf_section_display_enum regression by DWARF-5
binutils/
2017-03-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.h (enum dwarf_section_display_enum): Add loclists and rnglists.
2017-03-02 10:06:00 +01:00
Jan Kratochvil 77145576fa DWARF-5 basic functionality
binutils/
2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (fetch_indirect_line_string): New function.
	(abbrev_attr): New field implicit_const.
	(add_abbrev_attr): New parameter implicit_const.
	(process_abbrev_section): Support DW_FORM_implicit_const.
	(decode_location_expression): Support DW_OP_entry_value.
	(read_and_display_attr_value): Add parameter implicit_const.  Support
	DW_FORM_line_strp and DW_FORM_implicit_const.
	(read_and_display_attr): Add parameter implicit_const.
	(process_debug_info): Support line_str and DWARF-5.
	(read_debug_line_header): Support DWARF-5.
	(display_formatted_table): New function.
	(display_debug_lines_raw): New parameter file.  Support DWARF-5.
	(display_debug_lines_decoded): New parameter fileptr.  Support DWARF-5.
	(display_debug_lines): Pass file parameter.
	(display_debug_macro): Update read_and_display_attr_value caller.
	(display_debug_abbrev): Support DW_FORM_implicit_const.
	(display_loclists_list): New function.
	(display_loc_list): Support .debug_loclists.
	(display_debug_ranges_list): New function from display_debug_ranges.
	(display_debug_rnglists_list): New function.
	(display_debug_ranges): Support .debug_rnglists.
	(debug_displays): Add .debug_line_str, .debug_loclists and
	.debug_rnglists.
	* dwarf.h: Include dwarf2.h
	(DWARF2_Internal_LineInfo): Add li_offset_size.
	(DWARF2_Internal_CompUnit): Add cu_unit_type.
	(enum dwarf_section_display_enum): Add line_str.
	* readelf.c (process_section_headers): Add rnglists and loclists.
2017-02-23 22:56:47 +01:00
Alan Modra 2571583aed Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
Ambrogino Modigliani 222c2bf0a2 Fix spelling in comments in C source files (binutils)
* dwarf.c: Fix spelling in comments.
	* dwarf.h: Fix spelling in comments.
	* objcopy.c: Fix spelling in comments.
	* od-macho.c: Fix spelling in comments.
	* rclex.c: Fix spelling in comments.
	* readelf.c: Fix spelling in comments.
	* stabs.c: Fix spelling in comments.
2016-11-27 15:00:23 +10:30
Andreas Arnez d6bb17b079 Add init_dwarf_regnames_s390
Define and use DWARF register names for s390.

binutils/ChangeLog:

	* dwarf.h (init_dwarf_regnames_s390): Declare.
	* dwarf.c (dwarf_regnames_s390): New.
	(init_dwarf_regnames_s390): New.
	(init_dwarf_regnames): Call it.
	* objdump.c (dump_dwarf): Likewise.
2016-04-13 10:56:30 +02:00
Alan Modra 6f2750feaf Copyright update for binutils 2016-01-01 23:00:01 +10:30
Nick Clifton d1c4b12b9d Fix PR18374 by making readelf and objdump ignore end-of-list markers in the .debug_loc section if there are relocations against them.
PR binutils/18374
bin	* dwarf.h (struct dwarf_section): Add reloc_info and num_relocs
	fields.
	(struct dwarf_section_display): Change bitfield to boolean.
	(reloc_at): Add prototype.
	* dwarf.c (display_loc_list): Ignore list terminators if there are
	relocs against them.
	(display_debug_loc): Issue a warning if there are relocs against
	the .debug_loc section.
	(display_displays): Initialise reloc_info and num_relocs fields.
	* objdump.c (load_specific_debug_section): Initialise reloc_info
	and num_relocs fields.
	(reloc_at): New function.
	* readelf.c (is_32bit_abs_reloc): Add IA64's R_IA64_DIS32LSB
	reloc.
	(reloc_at): New function.
	(apply_relocations): Add relocs_return and num_relocs_return
	parameters.  Fill them in with the loaded relocs if non-NULL.
	(dump_section_as_bytes): Update call to apply_relocations.
	(load_specific_debug_section): Initialise reloc_info and
	num_relocs fields.

tests	* binutils-all/pr18374.s: New test file.
	* binutils-all/readelf.exp: Assemble and run the new test.
	* binutils-all/readelf.pr18374: Expected output from readelf.
2015-05-15 11:24:33 +01:00
H.J. Lu 3d875af575 Add init_dwarf_regnames_iamcu
* dwarf.c (dwarf_regnames_iamcu): New.
	(init_dwarf_regnames_iamcu): Likewise.
	(init_dwarf_regnames): Call init_dwarf_regnames_iamcu for EM_IAMCU.
	* dwarf.h (init_dwarf_regnames_iamcu): New.
	* objdump.c (dump_dwarf): Call init_dwarf_regnames_iamcu for
	bfd_arch_iamcu.
2015-05-11 10:41:44 -07:00
Nick Clifton 77ef865475 Fix memory access violations triggered by running objdump compiled with out-of-bounds sanitization checking.
PR binutils/17512
	* dwarf.c (eh_addr_size): Use an unsigned type.
	(size_of_encoded_value): Return an unsigned type.
	(read_leb128): Break if the shift becomes too big.
	(process_extended_line_op): Do not read the address if the length
	is too long.
	(read_cie): Warn and fail if the pointer size or segment size are
	too big.
	* dwarf.h (DWARF2_External_LineInfo): Delete unused and incorrect
	structure definition.
	(DWARF2_External_PubNames): Likewise.
	(DWARF2_External_CompUnit): Likewise.
	(DWARF2_External_ARange): Likewise.
	(DWARF2_Internal_LineInfo): Use dwarf_vma type for
	li_prologue_length.
	(eh_addr_size): Update prototype.

	* coffcode.h (styp_to_sec_flags): Use an unsigned long type to
	hold the flag bits.
	* peXXigen.c (pe_print_reloc): Use unsigned types to hold the
	size and number of relocs.
	(pe_print_debugdata): Use a 32-bit aligned buffer to store the
	codeview record.
	* versados.c (process_otr): Check the esdid value before using it
	to access the EDATA.
2015-02-10 14:11:00 +00:00
Nick Clifton 72c61a0d1e More fixes for memory access errors when running readelf on fuzzed binaries.
PR binutils/17531
	* dwarf.c (process_debug_info): Check for abbrev_base being larger
	than the section size.
	(process_cu_tu_index): Use xcalloc2 to allocate the CU and TU
	arrays.
	(xcalloc2): New function.  Like xcalloc, but checks for overflow.
	* dwarf.h (xcalloc2): Prototype.
2015-01-12 16:08:41 +00:00
Nick Clifton 82b1b41bcd More fixes for invalid memory accesses triggered by fuzzed binaries.
PR binutils/17531
	* dwarf.c (alloc_num_debug_info_entries): New variable.
	(process_debug_info): Set it.  Use it to avoid displaying
	attributes for which there is no info.
	(display_debug_abbrev): Check that the debug_info_entry index is
	valid before using it.
	(display_loc_list_dwo): Likewise.
	(process_cu_tu_index): Add range check for an overlarge dw_sect
	value.
	(free_debug_memory): Reset alloc_num_debug_info_entries.
	* readelf.c (slurp_ia64_unwind_table): Warn if the reloc could not
	be indentified.
	(dynamic_section_mips_val): Warn if the timestamp is invalid.
	(print_mips_got_entry): Add a data_end parameter.  Warn if a read
	would go beyond the end of the data, and return an error value.
	(process_mips_specific): Do not read options from beyond the end
	of the section.
	Correct code to display optional data at the end of an option.
	Warn if there are too many GOT symbols.
	Update calls to print_mips_got_entry, and handle error returns.
2015-01-05 13:54:22 +00:00
Alan Modra b90efa5b79 ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
Nick Clifton 06614111d1 More fixes for memory access violations exposed by fuzzed binaries.
PR binutils/17512
	* dwarf.h (struct dwarf_section): Add user_data field.
	* dwarf.c (frame_need_space): Check for an over large register
	number.
	(display_debug_frames): Check the return value from
	frame_need_space.  Check for a CFA expression that is so long the
	start address wraps around.
	(debug_displays): Initialise the user_data field.
	* objdump.c (load_specific_debug_section): Save the BFD section
	pointer in the user_data field of the dwarf_section structure.
	(free_debug_section): Update BFD section data when freeing section
	contents.
	* readelf.c (load_specific_debug_section): Initialise the
	user_data field.

	* archive.c (do_slurp_coff_armap): Add range checks to prevent
	running off the end of the string table.
	* compress.c (bfd_get_full_section_contents): Return a NULL
	pointer for zero sized sections.  Do not attempt to copy a buffer
	onto itself.
	* elf-attrs.c (_bfd_elf_parse_attributes): Check for an empty
	header.  Add range checks to avoid running off the end of the
	section.
	* elf.c (bfd_elf_get_str_section): Seek before allocating so that
	if the seek fails, no memory is allocated.
	(bfd_elf_string_from_elf_section): Do not allocate a string from a
	non string section.  It only leads to trouble later on.
	(_bfd_elf_print_private_bfd_data): Check for there being too
	little external dynamic data.
	(bfd_section_from_shdr): Replace assertion with a failure mode.
	(bfd_section_from_shdr): When walking a loaded group section use
	the internal structure size, not the external size.  Check for the
	group section being empty.
	* elf32-i386.c (elf_i386_rtype_to_howto): Replace assertion with a
	failure mode.
	* elfcode.h (elf_slurp_reloc_table): Likewise.
	* reloc.c (bfd_perform_relocation): Avoid seg-fault if the howto
	parameter is NULL.
2014-12-01 16:43:46 +00:00
Richard Henderson 4ee220358d aarch64: Decode dwarf2 register numbers
* dwarf.h (init_dwarf_regnames_aarch64): Declare.
	* dwarf.c (dwarf_regnames_aarch64): New.
	(init_dwarf_regnames_aarch64): New.
	(init_dwarf_regnames): Call it.
	* objdump.c (dump_dwarf): Likewise.
2014-08-22 14:40:10 -07:00
Alan Modra 4b95cf5c0c Update copyright years 2014-03-05 22:16:15 +10:30
Doug Evans 459d52c84a Add pretty-printing of .debug_gnu_pubnames, .debug_gnu_pubtypes.
* dwarf.c (get_gdb_index_symbol_kind_name): New function.
	(display_debug_pubnames_worker): Renamed from display_debug_pubnames.
	Add support for .debug_gnu_pubnames, .debug_gnu_pubtypes.
	(display_debug_pubnames, display_debug_pubnames_gnu): New functions.
	(display_gdb_index): Redo printing of symbol kind.
	(debug_displays): Add .debug_gnu_pubnames, .debug_gnu_pubtypes.
	* dwarf.h (dwarf_section_display_enum): Add gnu_pubnames, gnu_pubtypes.
	* readelf.c (process_section_headers): Add gnu_pubnames, gnu_pubtypes.
2013-11-07 15:37:44 -08:00
Nick Clifton f6f0e17bc3 PR binutils/15202
* dwarf.c (read_leb128): Add END parameter.  Do not read at or
	beyond end.
	(read_sleb128): Add END parameter.
	(read_uleb128): New function.
	(process_extended_line_op): Pass END to leb128 functions.
	(process_abbrev_section): Likewise.
	(decode_location_expression): Likewise.
	(read_and_display_attr_value): Likewise.
	(read_and_display_attr): Likewise.
	(process_debug_info): Likewise.
	(display_debug_lines_raw): Likewise.
	(display_debug_lines_decoded): Likewise.
	(display_debug_macinfo): Likewise.
	(get_line_filename_and_dirname): Likewise.
	(display_debug_macro): Likewise.
	(display_loc_list_dwo): Likewise.
	(display_debug_ranges): Likewise.
	* dwarf.h (read_leb128): Update prototype.
	* readelf.c (read_uleb128): Add END parameter.
	(decode_arm_unwind_bytecode): Pass END to read_uleb128.
	(decode_tic6x_unwind_bytecode): Likewise.
	(display_tag_value): New function.
	(display_arm_attribute): Add END parameter. Pass END to
	read_uleb128.  Use display_tag_value.
	(display_gnu_attribute): Likewise.
	(display_power_gnu_attribute): Likewise.
	(display_sparc_gnu_attribute): Likewise.
	(display_mips_gnu_attribute): Likewise.
	(display_tic6x_attribute): Likewise.
	(process_attributes): Likewise.
	(display_raw_attribute): New function.
2013-03-25 13:16:41 +00:00
Cary Coutant 657d0d47ba binutils/
* dwarf.c (do_debug_addr, do_debug_cu_index): New global flags.
	(load_debug_info): Fix typo.
	(cu_tu_indexes_read, shndx_pool, shndx_pool_size, shndx_pool_used):
	New global variables.
	(prealloc_cu_tu_list, add_shndx_to_cu_tu_entry, end_cu_tu_entry)
	(process_cu_tu_index, load_cu_tu_indexes, find_cu_tu_set)
	(display_cu_index): New functions.
	(dwarf_select_sections_by_names): Add "debug_addr", "cu_index".
	Sort entries alphabetically.
	(dwarf_select_sections_all): Set do_debug_addr, do_debug_cu_index.
	(debug_displays): Add .debug_cu_index, .debug_tu_index.
	Clean up formatting.
	* dwarf.h (dwarf_section_display_enum): Add dwp_cu_index,
	dwp_tu_index.
	(do_debug_addr, do_debug_cu_index): New global flags.
	(find_cu_tu_set): New function declaration.
	* objdump.c (usage): Add --dwarf=addr, --dwarf=cu_index.
	* readelf.c (find_section_in_set): New function.
	(usage): Add --debug-dump=addr, --debug_dump=cu_index.
	(process_section_headers): Check do_debug_addr and do_debug_cu_index.
	(section_subset): New global variable.
	(load_debug_section): Restrict search to section subset.
	(display_debug_section): Add section index as paramter.  Select subset
	of sections when dumping a .dwp file.  Update caller.
2012-10-24 01:59:39 +00:00
Cary Coutant 4723351a02 * doc/binutils.texi: Add --dwarf-check option.
* dwarf.c (dwarf_check): New global flag.
	(fetch_indexed_string): New function.
	(fetch_indexed_value): New function.
	(get_FORM_name): Add DW_FORM_GNU_str_index and DW_FORM_GNU_addr_index.
	(decode_location_expression): Add DW_OP_GNU_addr_index.
	(read_and_display_attr_value): Add DW_FORM_GNU_str_index,
	DW_FORM_GNU_addr_index, DW_AT_GNU_addr_base, and DW_AT_GNU_ranges_base.
	(get_AT_name): Add new attributes for Fission.
	(process_debug_info): Load new debug sections for Fission.
	(load_debug_info): Check for .debug_info.dwo section.
	(display_loc_list, display_loc_list_dwo): New functions.
	(display_debug_loc): Move logic to above two functions.
	(display_debug_info): Choose abbrev section based on info section.
	(display_debug_types): Likewise.
	(display_trace_info): Likewise.
	(comp_addr_base): New function.
	(display_debug_addr): New function.
	(display_debug_str_offsets): New function.
	(display_debug_ranges): Allow missing range lists.  Suppress
	diagnostics if dwarf_check not set.
	(debug_displays): Add column to select abbrev section.
	* dwarf.h (enum dwarf_section_display_enum): Add new debug sections
	for Fission.
	(struct dwarf_section): Add abbrev_sec field.
	(struct dwarf_section_display): New type.
	(debug_info): Add addr_base, ranges_base fields.
	(dwarf_check): New global variable.
	* objdump.c (usage): Add --dwarf-check option.
	(enum option_values): Add OPTION_DWARF_CHECK.
	(long_options): Add --dwarf-check.
	(main): Likewise.
	* readelf.c (OPTION_DWARF_CHECK): New macro.
	(options): Add --dwarf-check.
	(parse_args): Likewise.
	(process_section_headers): Use const_strneq instead of
	streq.
2012-05-11 18:18:34 +00:00
Cary Coutant 48049d1ee9 * binutils/dwarf.h (dwarf_section_display_enum): Add missing enum
constant.
2011-09-30 21:06:00 +00:00
Jakub Jelinek 4ccf1e317a * dwarf2.c (dwarf_debug_sections): Add .debug_macro
and .zdebug_macro entry.
	(dwarf_debug_section_enum): Add debug_macro.

	* NEWS: Mention .debug_macro support.
	* dwarf.c (read_and_display_attr_value): Don't print a tab
	if attribute is 0.
	(get_AT_name): Handle DW_AT_GNU_macros.
	(get_line_filename_and_dirname, display_debug_macro): New
	functions.
	(debug_displays): Add an entry for .debug_macro and .zdebug_macro.
	* readelf.c (process_section_headers): With do_debug_macinfo
	handle also .debug_macro sections.
	* dwarf.h (dwarf_section_display_enum): Add macro.
2011-07-26 21:31:37 +00:00
Tom Tromey fd2f003344 * NEWS: Add note about --dwarf-depth, --dwarf-start, and
dwarf-mode.el.
	* objdump.c (suppress_bfd_header): New global.
	(usage): Update.
	(OPTION_DWARF_DEPTH, OPTION_DWARF_START): New constants.
	(options): Add dwarf-depth and dwarf-start entries.
	(dump_bfd): Use suppress_bfd_header.
	(main): Handle OPTION_DWARF_START, OPTION_DWARF_DEPTH.
	* doc/binutils.texi (objcopy): Document --dwarf-depth and
	--dwarf-start.
	(readelf): Likewise.
	* dwarf-mode.el: New file.
	* dwarf.c (dwarf_cutoff_level, dwarf_start_die): New globals.
	(read_and_display_attr_value): Also check debug_info_p.
	(process_debug_info): Handle dwarf_start_die and
	dwarf_cutoff_level.
	* dwarf.h (dwarf_cutoff_level, dwarf_start_die): Declare.
	* readelf.c (usage): Update.
	(OPTION_DWARF_DEPTH): New macro.
	(OPTION_DWARF_START): Likewise.
	(options): Add dwarf-depth and dwarf-start entries.
	(parse_args): Handle OPTION_DWARF_START and OPTION_DWARF_DEPTH.
testsuite
	* binutils-all/objdump.W: Correct output.
2011-04-28 17:23:17 +00:00
Nick Clifton 467c65bce2 Replace bfd_vma type and analog types by dwarf_vma and analogs.
Use dwarf specific print functions to display these type values.
	* dwarf.h (dwarf_signed_vma): New type;
	(DWARF2_External_LineInfo): Replace bfd_vma by dwarf_vma.
	(DWARF2_External_PubNames): Likewise.
	(DWARF2_External_CompUnit): Likewise.
	(DWARF2_External_ARange): Likewise.
	(read_leb128): Change return type to dwarf_vma.
	* dwarf.c (print_dwarf_vma): Use __MINGW32__ conditional and
	check byte_size values.
	(dwarf_vmatoa): Change parameter type to dwarf_vma.
	(dwarf_svmatoa): New static function.
	(read_leb128): Change return type to dwarf_vma.
	(read_sleb128): New static function.
	(struct State_Machine_Registers): Change address field type to
	dwarf_vma.
	(process_extended_line_op): Adapt to type changes.
	(fetch_indirect_string): Likewise.
	(idisplay_block): Likewise.
	(decode_location_expression): Likewise.
	(read_and_display_attr_value): Likewise.
	(process_debug_info): Likewise.
	(display_debug_lines_raw): Likewise.
	(display_debug_lines_decoded): Likewise.
	(SLEB macro): Use new read_sleb128 function.
2011-03-25 15:15:52 +00:00
Kai Tietz 47704ddfbe ChangeLog include/
2011-02-23  Kai Tietz  <kai.tietz@onevision.com>

	* dwarf2.h (_ELF_DWARF2_H): Renamed to
	_DWARF2_H.
	(DWARF2_External_LineInfo, DWARF2_Internal_LineInfo,
	DWARF2_External_PubNames, DWARF2_Internal_PubNames,
	DWARF2_External_CompUnit, DWARF2_Internal_CompUnit,
	DWARF2_External_ARange, DWARF2_Internal_ARange): Removed.


ChangeLog binutils/

2011-02-23  Kai Tietz  <kai.tietz@onevision.com>

	* dwarf.c (read_leb128): Use bfd_vma instead of
	long type.
	(dwarf_vmatoa): New helper routine.
	(process_extended_line_op): Use for adr bfd_vma
	type and print those typed values via BFD_VMA_FMT
	or via dwarf_vmatoa for localized prints.
	(fetch_indirect_string): Adjust offset's type.
	(decode_location_expression): Adjust argument types
	and uvalue type.
	(read_and_display_attr_value): Likewise.
	(read_and_display_attr): Likewise.
	(decode_location_expression): Adjust printf format.
	(process_debug_info): Likewise.
	(display_debug_lines_raw): Likewise.
	(display_debug_lines_decoded): Likewise.
	(display_debug_pubnames): Likewise.
	(display_debug_loc): Likewise.
	(display_debug_aranges): Likewise.
	* dwarf.h (DWARF2_External_LineInfo,
	DWARF2_Internal_LineInfo, DWARF2_External_PubNames,
	DWARF2_Internal_PubNames, DWARF2_External_CompUnit,
	DWARF2_Internal_CompUnit, DWARF2_External_ARange,
	DWARF2_Internal_ARange): Added..
	(read_leb128): Adjust return type.
2011-02-23 08:52:34 +00:00
Doug Evans 5bbdf3d565 * dwarf.c: #include "bfd_stdint.h".
(do_gdb_index): New global.
	(display_gdb_index): New function.
	(dwarf_select_sections_by_names) Add "gdb_index".
	(dwarf_select_sections_all): Set do_gdb_index.
	(debug_displays): Add .gdb_index.
	* dwarf.h (do_gdb_index): Declare.
	* objdump.c (usage): Add gdb_index.
	* readelf.c (usage): Add gdb_index.
	(process_section_headers): Process ".gdb_index".
	* doc/binutils.texi (readelf): Document gdb_index dump.
	(objdump): Ditto.
2010-12-03 17:07:20 +00:00
H.J. Lu 3284fe0c5e Add and use elfcomm.c/elfcomm.h.
2010-11-21  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/12235
	* elfcomm.c: New.
	* elfcomm.h: Likewise.

	* Makefile.am (HFILES): Add elfcomm.h.
	(CFILES): Add elfcomm.c.
	(ELFLIBS): New.
	(readelf_SOURCES): Add $(ELFLIBS).
	(elfedit_SOURCES): Likewise.
	(objdump_SOURCES): Likewise.
	* Makefile.in: Regenerated.

	* dwarf.c: Include "elfcomm.h".
	(byte_get): Removed.
	(byte_get_little_endian): Likewise.
	(byte_get_big_endian): Likewise.
	(byte_get_signed): Likewise.
	(error): Likewise.
	(warn): Likewise.

	* dwarf.h (dwarf_vma): Defined with HOST_WIDEST_INT.
	(dwarf_size_type): Likewise.
	(byte_get): Removed.
	(byte_get_signed): Likewise.
	(byte_get_little_endian): Likewise.
	(byte_get_big_endian): Likewise.
	(error): Likewise.
	(warn): Likewise.

	* elfedit.c: Include "elfcomm.h".  Don't include "aout/ar.h".
	Call error () instead of non_fatal ().
	(streq): Removed.
	(strneq): Likewise.
	(const_strneq): Likewise.
	(non_fatal): Likewise.
	(BYTE_GET): Likewise.
	(BYTE_PUT): Likewise.
	(byte_get): Likewise.
	(byte_put): Likewise.
	(byte_get_little_endian): Likewise.
	(byte_get_big_endian): Likewise.
	(byte_put_little_endian): Likewise.
	(byte_put_big_endian): Likewise.
	(adjust_relative_path): Likewise.
	(archive_info): Likewise.
	(setup_archive): Likewise.
	(release_archive): Likewise.
	(setup_nested_archive): Likewise.
	(get_archive_member_name): Likewise.
	(get_archive_member_name_at): Likewise.
	(make_qualified_name): Likewise.

	* objdump.c: Include "elfcomm.h".

	* readelf.c: Include "elfcomm.h".  Don't include "aout/ar.h".
	(BYTE_GET): Removed.
	(BYTE_GET_SIGNED): Removed.
	(streq): Likewise.
	(strneq): Likewise.
	(const_strneq): Likewise.
	(byte_put): Likewise.
	(byte_put_little_endian): Likewise.
	(byte_put_big_endian): Likewise.
	(adjust_relative_path): Likewise.
	(archive_info): Likewise.
	(setup_archive): Likewise.
	(release_archive): Likewise.
	(setup_nested_archive): Likewise.
	(get_archive_member_name): Likewise.
	(get_archive_member_name_at): Likewise.
	(make_qualified_name): Likewise.
2010-11-21 21:27:15 +00:00
H.J. Lu 598aaa7684 Use BYTE_GET_SIGNED on r_addend.
2010-10-08  H.J. Lu  <hongjiu.lu@intel.com>

	* dwarf.c (byte_get_signed): Make it extern.

	* dwarf.h (byte_get_signed): New.

	* readelf.c (BYTE_GET_SIGNED): New.
	(slurp_rela_relocs): Use BYTE_GET_SIGNED on r_addend.
	(dump_relocations): Properly dump r_addend.
2010-10-09 05:52:29 +00:00
Jakub Jelinek b7807392f0 * dwarf.h (debug_info): Add offset_info and dwarf_version fields.
* dwarf.c (decode_location_expression): Add offset_size and
	dwarf_version arguments.  Prefix DIE offset with 0x for
	DW_OP_call{2,4,_ref}.  Fix up DW_OP_call_ref operand size,
	complain if in frame info section.  Handle
	DW_OP_GNU_implicit_pointer.
	(read_and_display_attr_value, display_debug_loc,
	display_debug_frames): Adjust decode_location_expression callers.
	(process_debug_info): Save offset_size and dwarf_version values
	into debug_information array.

	* dwarf2.h (DW_OP_GNU_implicit_pointer): New.
2010-09-09 10:18:12 +00:00
Richard Henderson b129eb0e56 * dwarf.c (init_dwarf_regnames_i386, init_dwarf_regnames_x86_64): New.
(init_dwarf_regnames): Use them.
	* dwarf.h: Declare them.
	* objdump.c (dump_dwarf): Use bfd_get_arch + bfd_get_mach to set up
	the regnames, rather than using elf_machine_code.
2010-09-02 22:35:18 +00:00
Tristan Gingold 6f875884e0 2010-05-24 Tristan Gingold <gingold@adacore.com>
* readelf.c (usage): Add new trace sections for --debug-dump.
	(process_section_headers): Handle dump of trace sections.
	* objdump.c (usage): Add new trace sections for --dwarf.
	* dwarf.h (do_trace_info, do_trace_abbrevs): New variables.
	(do_trace_aranges): Ditto.
	(enum dwarf_section_display_enum): Add trace_info, trace_abbrev
	and trace_aranges literals.
	* dwarf.c (do_trace_info, do_trace_abbrevs): New variables.
	(do_trace_aranges): Ditto.
	(process_debug_info): Add abbrev_sec argument and replace
	abbrev with abbrev_sec.
	(load_debug_info): Adjust call of process_debug_info.
	(display_debug_info): Ditto.
	(display_trace_info): New function.
	(dwarf_select_sections_by_names): Add trace_info, trace_abbrevs
	and trace_aranges sections name.
	(dwarf_select_sections_all): Also select trace sections.
	(debug_displays): Reindent.  Add entries for the trace sections.
	* doc/binutils.texi (readelf): Document new --dwarf parameters.
	(objdump): Ditto.
2010-05-24 13:21:26 +00:00
Daniel Jacobowitz 0b6ae52290 * NEWS: Document .ARM.exidx / .ARM.extab support.
* dwarf.c (read_leb128): Make non-static.
	* dwarf.h (read_leb128): Declare.
	* readelf.c (REMOVE_ARCH_BITS): Define.
	(find_section_by_address): New.
	(read_uleb128): Move higher.  Use read_leb128 from dwarf.c.
	(find_symbol_for_address): Handle the Thumb bit for ARM, by
	using REMOVE_ARCH_BITS.
	(struct arm_section, struct arm_unw_aux_info, arm_print_vma_and_name)
	(arm_free_section, arm_section_get_word, decode_arm_unwind)
	(dump_arm_unwind, arm_process_unwind): New.
	(process_unwind): Handle ARM.
2010-03-02 16:44:34 +00:00
Nick Clifton f9f0e73285 PR binutils/11045
* dwarf.c (do_debug_pubtypes): New variable.
        (dwarf_select_sections_by_names): Handle .debug_pubtypes.
        (dwarf_select_sections_by_letters): Add 't' for .debug_pubtype.
        (dwarf_select_sections_all): Set do_debug_pubtypes.
        (debug_displays): Add support for .debug_pubtypes.
        * dwarf.h (do_debug_pubtypes): Export.
        * objdump.c (usage): Add -wt or --dwarf=pubtypes.
        * readelf.c (usage): Likewise.
        (process_section_headers): Enable debug display if
        do_debug_pubtypes is set.
        * doc/binutils.texi: Document -wt/--dwarf=pubtypes option.
2009-12-03 12:28:37 +00:00