Commit Graph

297 Commits

Author SHA1 Message Date
Alan Modra 279edac53d C++ comments
binutils isn't c99 (yet).  This replaces or removes some C++ style
comments.

bfd/
	* arc-got.h: Use C style comments.
	* coff-z80.c: Likewise.
	* elf32-csky.c: Likewise.
	* peXXigen.c: Likewise.
	* elf32-m32c.c (m32c_elf_relax_delete_bytes): Remove commented out
	code.
binutils/
	* dwarf.c: Use C style comments.
	* resrc.c: Likewise.
gas/
	* config/tc-s12z.c: Use C style comments.
	* config/tc-z80.c: Likewise.
	* config/tc-xtensa.c (emit_ld_r_n): Remove commented out code.
include/
	* coff/internal.h: Use C style comments.
	* coff/pe.h: Likewise.
	* elf/ppc64.h: Likewise.
opcodes/
	* arm-dis.c: Use C style comments.
	* cr16-opc.c: Likewise.
	* ft32-dis.c: Likewise.
	* moxie-opc.c: Likewise.
	* tic54x-dis.c: Likewise.
	* s12z-opc.c: Remove useless comment.
	* xgate-dis.c: Likewise.
2020-06-29 10:07:56 +09:30
Nick Clifton 39f381cb80 Fix decoding of indexed DWARF strings using pre-DWARF-5 string offset sections. Fix display of .debug_str_offsets.dwo sections.
PR 26160
	* dwarf.c (fetch_indexed_string): Detect and handle old style
	.debug_str_offset tables.
	(display_debug_str_offsets): Likewise.  Also add support for
	.debug_str_offsets.dwo sections.
2020-06-23 16:06:38 +01:00
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 c4b2f181c3 Fix an illegal memory access when parsing corrupt DWARF debug information.
PR 26086
	* dwarf.c (process_debug_info): Check that there is space in the
	debug_information array before filling in an entry.
2020-06-08 11:24:06 +01:00
Nelson Chu 8f595e9b4f [PATCH v2 0/9] RISC-V: Support version controling for ISA standard extensions and CSR
1. Remove the -mriscv-isa-version and --with-riscv-isa-version options.
We can still use -march to choose the version for each extensions, so there is
no need to add these.

2. Change the arguments of options from [1p9|1p9p1|...] to [1.9|1.9.1|...].
Unlike the architecture string has specified by spec, ther is no need to do
the same thing for options.

3. Spilt the patches to reduce the burdens of review.

[PATCH 3/7] RISC-V: Support new GAS options and configure options to set ISA versions
to
[PATCH v2 3/9] RISC-V: Support GAS option -misa-spec to set ISA versions
[PATCH v2 4/9] RISC-V: Support configure options to set ISA versions by default.

[PATCH 4/7] RISC-V: Support version checking for CSR according to privilege version.
to
[PATCH v2 5/9] RISC-V: Support version checking for CSR according to privilege spec version.
[PATCH v2 6/9] RISC-V: Support configure option to choose the privilege spec version.

4. Use enum class rather than string to compare the choosen ISA spec in opcodes/riscv-opc.c.
The behavior is same as comparing the choosen privilege spec.

include	* opcode/riscv.h: Include "bfd.h" to support bfd_boolean.
	(enum riscv_isa_spec_class): New enum class.  All supported ISA spec
	belong to one of the class
	(struct riscv_ext_version): New structure holds version information
	for the specific ISA.
	* opcode/riscv-opc.h (DECLARE_CSR): There are two version information,
	define_version and abort_version.  The define_version means which
	privilege spec is started to define the CSR, and the abort_version
	means which privilege spec is started to abort the CSR.  If the CSR is
	valid for the newest spec, then the abort_version should be
	PRIV_SPEC_CLASS_DRAFT.
	(DECLARE_CSR_ALIAS): Same as DECLARE_CSR, but only for the obselete CSR.
	* opcode/riscv.h (enum riscv_priv_spec_class): New enum class.  Define
	the current supported privilege spec versions.
	(struct riscv_csr_extra): Add new fields to store more information
	about the CSR.  We use these information to find the suitable CSR
	address when user choosing a specific privilege spec.

binutils * dwarf.c: Updated since DECLARE_CSR is changed.

opcodes	* riscv-opc.c (riscv_ext_version_table): The table used to store
	all information about the supported spec and the corresponding ISA
	versions.  Currently, only Zicsr is supported to verify the
	correctness of Z sub extension settings.  Others will be supported
	in the future patches.
	(struct isa_spec_t, isa_specs): List for all supported ISA spec
	classes and the corresponding strings.
	(riscv_get_isa_spec_class): New function.  Get the corresponding ISA
	spec class by giving a ISA spec string.
	* riscv-opc.c (struct priv_spec_t): New structure.
	(struct priv_spec_t priv_specs): List for all supported privilege spec
	classes and the corresponding strings.
	(riscv_get_priv_spec_class): New function.  Get the corresponding
	privilege spec class by giving a spec string.
	(riscv_get_priv_spec_name): New function.  Get the corresponding
	privilege spec string by giving a CSR version class.
	* riscv-dis.c: Updated since DECLARE_CSR is changed.
	* riscv-dis.c: Add new disassembler option -Mpriv-spec to dump the CSR
	according to the chosen version.  Build a hash table riscv_csr_hash to
	store the valid CSR for the chosen pirv verison.  Dump the direct
	CSR address rather than it's name if it is invalid.
	(parse_riscv_dis_option_without_args): New function.  Parse the options
	without arguments.
	(parse_riscv_dis_option): Call parse_riscv_dis_option_without_args to
	parse the options without arguments first, and then handle the options
	with arguments.  Add the new option -Mpriv-spec, which has argument.
	* riscv-dis.c (print_riscv_disassembler_options): Add description
	about the new OBJDUMP option.

ld	* testsuite/ld-riscv-elf/attr-merge-arch-01.d: Updated
        priv attributes according to the -mpriv-spec option.
	* testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-01.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-02.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-04.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-05.d: Likewise.

bfd 	* elfxx-riscv.h (riscv_parse_subset_t): Add new callback function
	get_default_version.  It is used to find the default version for
	the specific extension.
	* elfxx-riscv.c (riscv_parsing_subset_version): Remove the parameters
	default_major_version and default_minor_version.  Add new bfd_boolean
	parameter *use_default_version.  Set it to TRUE if we need to call
	the callback rps->get_default_version to find the default version.
	(riscv_parse_std_ext): Call rps->get_default_version if we fail to find
	the default version in riscv_parsing_subset_version, and then call
	riscv_add_subset to add the subset into subset list.
	(riscv_parse_prefixed_ext): Likewise.
	(riscv_std_z_ext_strtab): Support Zicsr extensions.
	* elfnn-riscv.c (riscv_merge_std_ext): Use strcasecmp to compare the
	strings rather than characters.
	riscv_merge_arch_attr_info): The callback function get_default_version
	is only needed for assembler, so set it to NULL int the linker.
	* elfxx-riscv.c (riscv_estimate_digit): Remove the static.
	* elfxx-riscv.h: Updated.

gas	* testsuite/gas/riscv/priv-reg-fail-read-only-01.s: Updated.
	* config/tc-riscv.c (default_arch_with_ext, default_isa_spec):
	Static variables which are used to set the ISA extensions. You can
	use -march (or ELF build attributes) and -misa-spec to set them,
	respectively.
	(ext_version_hash): The hash table used to handle the extensions
	with versions.
	(init_ext_version_hash): Initialize the ext_version_hash according
	to riscv_ext_version_table.
	(riscv_get_default_ext_version): The callback function of
	riscv_parse_subset_t.  According to the choosed ISA spec,
	get the default version for the specific extension.
	(riscv_set_arch): Set the callback function.
	(enum options, struct option md_longopts): Add new option -misa-spec.
	(md_parse_option): Do not call riscv_set_arch for -march.  We will
	call it later in riscv_after_parse_args.  Call riscv_get_isa_spec_class
	to set default_isa_spec class.
	(riscv_after_parse_args): Call init_ext_version_hash to initialize the
	ext_version_hash, and then call riscv_set_arch to set the architecture
	with versions according to default_arch_with_ext.
	* testsuite/gas/riscv/attribute-02.d: Set 0p0 as default version for
	x extensions.
	* testsuite/gas/riscv/attribute-03.d: Likewise.
	* testsuite/gas/riscv/attribute-09.d: New testcase.  For i-ext, we
	already set it's version to 2p1 by march, so no need to use the default
	2p2 version.  For m-ext, we do not set the version by -march and ELF arch
	attribute, so set the default 2p0 to it.  For zicsr, it is not defined in
	ISA spec 2p2, so set 0p0 to it.
	* testsuite/gas/riscv/attribute-10.d: New testcase.  The version of
	zicsr is 2p0 according to ISA spec 20191213.
	* config/tc-riscv.c (DEFAULT_RISCV_ARCH_WITH_EXT)
	(DEFAULT_RISCV_ISA_SPEC): Default configure option settings.
	You can set them by configure options --with-arch and
	--with-isa-spec, respectively.
	(riscv_set_default_isa_spec): New function used to set the
	default ISA spec.
	(md_parse_option): Call riscv_set_default_isa_spec rather than
	call riscv_get_isa_spec_class directly.
	(riscv_after_parse_args): If the -isa-spec is not set, then we
	set the default ISA spec according to DEFAULT_RISCV_ISA_SPEC by
	calling riscv_set_default_isa_spec.
	* testsuite/gas/riscv/attribute-01.d: Add -misa-spec=2.2, since
	the --with-isa-spec may be set to different ISA spec.
	* testsuite/gas/riscv/attribute-02.d: Likewise.
	* testsuite/gas/riscv/attribute-03.d: Likewise.
	* testsuite/gas/riscv/attribute-04.d: Likewise.
	* testsuite/gas/riscv/attribute-05.d: Likewise.
	* testsuite/gas/riscv/attribute-06.d: Likewise.
	* testsuite/gas/riscv/attribute-07.d: Likewise.
	* configure.ac: Add configure options, --with-arch and
	--with-isa-spec.
	* configure: Regenerated.
	* config.in: Regenerated.
	* config/tc-riscv.c (default_priv_spec): Static variable which is
	used to check if the CSR is valid for the chosen privilege spec. You
	can use -mpriv-spec to set it.
	(enum reg_class): We now get the CSR address from csr_extra_hash rather
	than reg_names_hash.  Therefore, move RCLASS_CSR behind RCLASS_MAX.
	(riscv_init_csr_hashes): Only need to initialize one hash table
	csr_extra_hash.
	(riscv_csr_class_check): Change the return type to void.  Don't check
	the ISA dependency if -mcsr-check isn't set.
	(riscv_csr_version_check): New function.  Check and find the CSR address
	from csr_extra_hash, according to default_priv_spec.  Report warning
	for the invalid CSR if -mcsr-check is set.
	(reg_csr_lookup_internal): Updated.
	(reg_lookup_internal): Likewise.
	(md_begin): Updated since DECLARE_CSR and DECLARE_CSR_ALIAS are changed.
	(enum options, struct option md_longopts): Add new GAS option -mpriv-spec.
	(md_parse_option): Call riscv_set_default_priv_version to set
	default_priv_spec.
	(riscv_after_parse_args): If -mpriv-spec isn't set, then set the default
	privilege spec to the newest one.
	(enum riscv_csr_class, struct riscv_csr_extra): Move them to
	include/opcode/riscv.h.
	* testsuite/gas/riscv/priv-reg-fail-fext.d: This test case just want
	to check the ISA dependency for CSR, so fix the spec version by adding
	-mpriv-spec=1.11.
	* testsuite/gas/riscv/priv-reg-fail-fext.l: Likewise.  There are some
	version warnings for the test case.
	* gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.d: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-read-only-02.d: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d: New test case.
	Check whether the CSR is valid when privilege version 1.9 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: New test case.
	Check whether the CSR is valid when privilege version 1.9.1 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d: New test case.
	Check whether the CSR is valid when privilege version 1.10 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d: New test case.
	Check whether the CSR is valid when privilege version 1.11 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise.
	* config/tc-riscv.c (DEFAULT_RISCV_ISA_SPEC): Default configure option
	setting.  You can set it by configure option --with-priv-spec.
	(riscv_set_default_priv_spec): New function used to set the default
	privilege spec.
	(md_parse_option): Call riscv_set_default_priv_spec rather than
	call riscv_get_priv_spec_class directly.
	(riscv_after_parse_args): If -mpriv-spec isn't set, then we set the
	default privilege spec according to DEFAULT_RISCV_PRIV_SPEC by
	calling riscv_set_default_priv_spec.
	* testsuite/gas/riscv/csr-dw-regnums.d: Add -mpriv-spec=1.11, since
	the --with-priv-spec may be set to different privilege spec.
	* testsuite/gas/riscv/priv-reg.d: Likewise.
	* configure.ac: Add configure option --with-priv-spec.
	* configure: Regenerated.
	* config.in: Regenerated.
	* config/tc-riscv.c (explicit_attr): Rename explicit_arch_attr to
	explicit_attr.  Set it to TRUE if any ELF attribute is found.
	(riscv_set_default_priv_spec): Try to set the default_priv_spec if
	the priv attributes are set.
	(md_assemble): Set the default_priv_spec according to the priv
	attributes when we start to assemble instruction.
	(riscv_write_out_attrs): Rename riscv_write_out_arch_attr to
	riscv_write_out_attrs.  Update the arch and priv attributes.  If we
	don't set the corresponding ELF attributes, then try to output the
	default ones.
	(riscv_set_public_attributes): If any ELF attribute or -march-attr
	options is set (explicit_attr is TRUE), then call riscv_write_out_attrs
	to update the arch and priv attributes.
	(s_riscv_attribute): Make sure all arch and priv attributes are set
	before any instruction.
	* testsuite/gas/riscv/attribute-01.d: Update the priv attributes if any
	ELF attribute or -march-attr is set.  If the priv attributes are not
	set, then try to update them by the default setting (-mpriv-spec or
	--with-priv-spec).
	* testsuite/gas/riscv/attribute-02.d: Likewise.
	* testsuite/gas/riscv/attribute-03.d: Likewise.
	* testsuite/gas/riscv/attribute-04.d: Likewise.
	* testsuite/gas/riscv/attribute-06.d: Likewise.
	* testsuite/gas/riscv/attribute-07.d: Likewise.
	* testsuite/gas/riscv/attribute-08.d: Likewise.
	* testsuite/gas/riscv/attribute-09.d: Likewise.
	* testsuite/gas/riscv/attribute-10.d: Likewise.
	* testsuite/gas/riscv/attribute-unknown.d: Likewise.
	* testsuite/gas/riscv/attribute-05.d: Likewise.  Also, the priv spec
	set by priv attributes must be supported.
	* testsuite/gas/riscv/attribute-05.s: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p9.d: Likewise.  Updated
	priv attributes according to the -mpriv-spec option.
	* testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p10.d: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p11.d: Likewise.
	* testsuite/gas/riscv/priv-reg.d: Removed.
	* testsuite/gas/riscv/priv-reg-version-1p9.d: New test case.  Dump the
	CSR according to the priv spec 1.9.
	* testsuite/gas/riscv/priv-reg-version-1p9p1.d: New test case.  Dump the
	CSR according to the priv spec 1.9.1.
	* testsuite/gas/riscv/priv-reg-version-1p10.d: New test case.  Dump the
	CSR according to the priv spec 1.10.
	* testsuite/gas/riscv/priv-reg-version-1p11.d: New test case.  Dump the
	CSR according to the priv spec 1.11.
	* config/tc-riscv.c (md_show_usage): Add descriptions about
	the new GAS options.
	* doc/c-riscv.texi: Likewise.
2020-05-20 17:22:48 +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 070b775f03 GAS: Do not create an entry for the default directory if the directory table is empty. Improve readelf's decoding of empty directory and file name tables.
PR 25917
	* dwarf.c (display_debug_lines_decoded): Warn if encountering a
	supicious number of entries for DWARF-5 format directory and file
	name tables.  Do not display file name table header if the table
	is empty.  Do not allocate space for empty tables.
2020-05-04 13:50:05 +01:00
Andrew Burgess cb4c35cfbe When displaying ranges, ignore duplicate offsets.
* dwarf.c (display_debug_ranges): Ignore duplicate entries in
	range_entries for the same offset.
2020-04-29 17:21:10 +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
Nelson Chu bd0cf5a6ba RISC-V: Support the ISA-dependent CSR checking.
According to the riscv privilege spec, some CSR are only valid when rv32 or
the specific extension is set.  We extend the DECLARE_CSR and DECLARE_CSR_ALIAS
to record more informaton we need, and then check whether the CSR is valid
according to these information.  We report warning message when the CSR is
invalid, so we have a choice between error and warning by --fatal-warnings
option.  Also, a --no-warn/-W option is used to turn the warnings off, if
people don't want the warnings.

	gas/
	* config/tc-riscv.c (enum riscv_csr_class): New enum.  Used to decide
	whether or not this CSR is legal in the current ISA string.
	(struct riscv_csr_extra): New structure to hold all extra information
	of CSR.
	(riscv_init_csr_hash): New function.  According to the DECLARE_CSR and
	DECLARE_CSR_ALIAS, insert CSR extra information into csr_extra_hash.
	Call hash_reg_name to insert CSR address into reg_names_hash.
	(md_begin): Call riscv_init_csr_hashes for each DECLARE_CSR.
	(reg_csr_lookup_internal, riscv_csr_class_check): New functions.
	Decide whether the CSR is valid according to the csr_extra_hash.
	(init_opcode_hash): Update 'if (hash_error != NULL)' as hash_error is
	not a boolean.  This is same as riscv_init_csr_hash, so keep the
	consistent usage.

	* testsuite/gas/riscv/csr-dw-regnums.d: Add -march=rv32if option.
	* testsuite/gas/riscv/priv-reg.d: Add f-ext by -march option.
	* testsuite/gas/riscv/priv-reg-fail-fext.d: New testcase.  The source
	file is `priv-reg.s`, and the ISA is rv32i without f-ext, so the
	f-ext CSR are not allowed.
	* testsuite/gas/riscv/priv-reg-fail-fext.l: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-rv32-only.d: New testcase.  The
	source file is `priv-reg.s`, and the ISA is rv64if, so the
	rv32-only CSR are not allowed.
	* testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise.

	include/
	* opcode/riscv-opc.h: Extend DECLARE_CSR and DECLARE_CSR_ALIAS to
	record riscv_csr_class.

	opcodes/
	* riscv-dis.c (print_insn_args): Updated since the DECLARE_CSR is changed.

	gdb/
	* riscv-tdep.c: Updated since the DECLARE_CSR is changed.
	* riscv-tdep.h: Likewise.
	* features/riscv/rebuild-csr-xml.sh: Generate the 64bit-csr.xml without
	rv32-only CSR.
	* features/riscv/64bit-csr.xml: Regernated.

	binutils/
	* dwarf.c: Updated since the DECLARE_CSR is changed.
2020-02-20 16:49:09 -08:00
Nick Clifton e1104d08fe Silcence a compile time warning message building the binutils with gcc-10 on an s390 host.
* dwarf.c (display_debug_lines_decoded): Force a NUL termination
	of the truncated file name.
2020-02-07 12:49:42 +00:00
Alan Modra a788aedd86 PR23560, PR23561, readelf memory leaks
PR 23560
	PR 23561
	* dwarf.c (display_debug_frames): Move fde_fc earlier.  Free
	fde_fc col_type and col_offset.
	* readelf.c (apply_relocations): Move symsec check earlier.
	(free_debug_section): Free reloc_info.
	(process_notes_at): Free pnotes on error path.
	(process_object): Free dump_sects here..
	(process_archive): ..not here.
2020-01-13 22:45:36 +10:30
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
Hans-Peter Nilsson 27653fba5e Fix build 32-bit-host build error last for last binutils/dwarf2.c change.
* dwarf.c (display_debug_lines_decoded): Cast printf parameter to
	format type to correct last change.
2019-12-23 13:19:59 +01:00
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 4762fe621e binutils/gas/riscv: Add DWARF register numbers for CSRs
This commit gives DWARF register numbers to the RISC-V CSRs inline
with the RISC-V ELF specification here:

  https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md

The CSRs are defined being numbered from 4096 to 8191.

This adds support to the assembler, required in order to reference
CSRs in, for example .cfi directives.

I have then extended dwarf.c in order to support printing CSR names in
the dumped DWARF output.  As the CSR name space is quite large and
only sparsely populated, I have provided a new function to perform
RISC-V DWARF register name lookup which uses a switch statement rather
than the table base approach that other architectures use.

Any CSR that does not have a known name will return a name based on
'csr%d' with the %d being replaced by the offset of the CSR from 4096.

gas/ChangeLog:

	* config/tc-riscv.c (tc_riscv_regname_to_dw2regnum): Lookup CSR
	names too.
	* testsuite/gas/riscv/csr-dw-regnums.d: New file.
	* testsuite/gas/riscv/csr-dw-regnums.s: New file.

binutils/ChangeLog:

	* dwarf.c (regname_internal_riscv): New function.
	(init_dwarf_regnames_riscv): Use new function.

Change-Id: I3f70bc24fa8b3c75744e6775eeeb87db70c7ecfb
2019-11-28 00:03:05 +00:00
Andrew Burgess 1296bc99b1 binutils: Make DWARF register name lookup be via a function pointer
Add a layer of indirection for DWARF register name lookup by
introducing a function pointer.  Right now all targets use the same
table based implementation that they always have, however, this will
change in a later commit.

binutils/ChangeLog:

	* dwarf.c (typedef dwarf_regname_lookup_ftype): New typedef.
	(dwarf_regnames_lookup_func): New static global.
	(init_dwarf_regnames_i386): Set dwarf_regnames_lookup_func.
	(init_dwarf_regnames_iamcu): Likewise.
	(init_dwarf_regnames_x86_64): Likewise.
	(init_dwarf_regnames_aarch64): Likewise.
	(init_dwarf_regnames_s390): Likewise.
	(init_dwarf_regnames_riscv): Likewise.
	(init_dwarf_regnames_by_elf_machine_code): Reset
	dwarf_regnames_lookup_func to NULL.
	(init_dwarf_regnames_by_bfd_arch_and_mach): Likewise.
	(regname_internal_by_table_only): New function.
	(regname): Make use of dwarf_regnames_lookup_func.

Change-Id: Ibbff61c0abea32927f35c9e478793039ab8bb57d
2019-11-28 00:03:04 +00:00
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
Andrew Burgess d9acf70759 binutils: Be more forgiving of targets with large numbers of registers
Currently if a target has a large ( > 1024 ) number of registers then
we get a warning when dumping the DWARF whenever a register over the
1024 limit is referenced, this occurs in dwarf.c:frame_need_space.

This check was initially introduced to guard against corrupted DWARF
referencing stupidly large numbers of registers.

The frame_need_space function already has a check in place so that, if
a target specifies a set of known DWARF register names then we must
only reference a register within this set, it is only after this check
that we check for the 1024 limit.

What this means is that if a target DOES NOT define a set of known
register names and if we reference more than 1024 registers
frame_need_space will give a warning.

If a target DOES define a set of known registers and there are more
than 1024 defined registers, and we try to reference a register beyond
1024 we will again get an error.

This second case feels wrong to me.  My thinking is that if a target
defines a set of registers then it is not unreasonable to assume the
tools can cope with that number of registers.  And so, if the target
defines 2000 named DWARF registers, frame_need_space should allow
access to all of these registers.

If a target does not define a set of named registers then the 1024
limit should remain.  This is pretty arbitrary, but we do need to have
some limit in place I think, so for now that seems as good as any.

This is an entirely theoretical fix - there are no targets that define
such large numbers of registers, but while experimenting with adding
support for RISC-V CSRs I ran into this issue and felt like it was a
good improvement.

binutils/ChangeLog:

	* dwarf.c (frame_need_space): Compare dwarf_regnames_count against
	0, and only warn about large numbers of registers if the number is
	more than the dwarf_regnames_count.

Change-Id: Ifac1a999ff0677676e81ee373c4c044b6a700827
2019-11-28 00:03:02 +00:00
Alan Modra b3fe587ed2 PR25018, readelf crash on 32bits
Pointer comparisons after adding an offset just don't work to catch
overflow when the offset is a larger type than the pointer.

	PR 25018
	* dwarf.c (get_type_signedness): Delete ineffective pointer
	comparison check.  Properly range check uvalue offset on
	recursive call.
	(read_and_display_attr_value): Range check uvalue offset before
	calling get_type_signedness.
2019-09-23 09:04:54 +09:30
Alan Modra a85eba51f6 Tidy check_uvalue
I don't see a need to calculate "ptr = start + uvalue" then compare
"ptr" with "start" and "end".  Given "start <= end" on entry, the
"uvalue" comparison with "max_uvalue" ought to be sufficient to ensure
"start + uvalue" is bounded by "start" and "end" regardless of the
size of pointers and the unsigned dwarf_vma integer type.

	* dwarf.c (check_uvalue): Remove unnecessary pointer checks.
2019-08-29 09:04:35 +09:30
Nick Clifton ec1b0fbb8d Improve the DWARF decoder's ability to describe the DW_AT_discr_list attribute.
PR 24510
	* dwarf.c (MAX_CU_NESTING): New constant.
	(level_type_signed): New static array.
	(skip_attr_bytes): New function.
	(get_type_signedness): New function.
	(read_and_print_leb128): New function.
	(display_discr_list): New function.
	(read_and_display_attr_value): Add start parameter.
	Use new functions when handling DW_AT_type and DW_AT_discr_list.
	(read_and_display_attr): Add start parameter.  Pass to
	read_and_display_attr_value.
	(process_debug_info): Update call to read_and_display_attr.
	(display_formatted_table): Likewise.
	(display_debug_lines_decoded): Likewise.  Also add start
	parameter.
	(display_debug_lines): Likewise.
	* testsuite/binutils-all/dwarf-attributes.S: Update discrimination
	lists.
	* testsuite/binutils-all/dwarf-attributes.W: Update expected
	output.
2019-08-27 16:28:55 +01:00
Nick Clifton afc72f154d Prevent a potential illegal memory access in the DWARF parser when processing a corrupt file.
PR 24829
	* dwarf.c (check_uvalue): New function.  Ensures that a block's
	size is valid.
	(read_and_display_attr_value): Use check_value when processsing
	DW_FORM_block<n> attributes.
2019-08-23 10:37:51 +01:00
Nick Clifton 4ac948a044 Prevent a floating point exception in the dwarf parser when a CU or TU table does not have any columns.
PR 24921
	* dwarf.c (process_cu_tu_index): Handle the case where a table
	does not have any columns.
2019-08-22 13:11:18 +01:00
Alan Modra d292364e95 PR24898, An out-of-bounds read occured in display_data
Given 32-bit pointers and a 64-bit bfd_size_type, it is relatively
easy to construct a value of augmentation_data_len (eg. 0x100000000)
that won't fail pointer checks but will print without bounds.

	PR 24898
	* dwarf.c (display_debug_frames): Use the read_cie check and error
	for augmentation data length.
2019-08-19 20:38:59 +09:30
Alan Modra d367307b93 PR24911, Heap overflow issue in qsort_r, dwarf.c
The actual args to this function are "pointers to pointers to
debug_info".

	PR 24911
	* dwarf.c (comp_addr_base): Dereference args.
2019-08-17 18:06:31 +09:30
Alan Modra 8e2e3c6c34 PR24798, buffer overflow in process_cu_tu_index
PR 24798
	* dwarf.c (process_cu_tu_index): Avoid integer overflow on 64-bit
	systems by casting ncols and nslots expressions to size_t.  Display
	number of columns and slots before giving up due to buffer overflow.
	Use %u to display unsigned ints.  Perform more pointer wrap tests.
2019-07-26 13:05:16 +09:30
Tom de Vries 48467cb99b Have readelf and objdump display the contents of the DWARF augmentation data as a string, if it is printable.
PR 24809
	* dwarf.c (display_debug_names): Display the contents of the
	augmentation string, if it is printable.
2019-07-25 17:24:22 +01:00
Nick Clifton 2e8136f945 Fix objdump's display of indirect strings in object files, which was broken by the link following code.
PR 24818
	* objdump.c (is_relocateable): Delete.
	(load_specific_debug_section): Test the abfd for relocations
	directly, rather than relying upon is_relocateable.
	(dump_dwarf): Delete initlialization of is_relocateable.
2019-07-23 17:54:32 +01:00
Tamar Christina fab7c86ea4 AArch64: Add SVE DWARF registers
The SVE DRAWF register names are missing from binutils, this may cause objdump
and readelf to ignore certain DRAWF output as the registers are unknown (most
notably CIEs).

This patch adds the registers in accordance to the "DWARF for ARM(r) 64-bit
Architecture (AARch64) with SVE support" documentation [1].

[1] https://developer.arm.com/docs/100985/latest/dwarf-for-the-arm-64-bit-architecture-aarch64-with-sve-support

binutils/ChangeLog:

	* dwarf.c (dwarf_regnames_aarch64): Add SVE registers.
	* testsuite/binutils-all/aarch64/sve-dwarf-registers.d: New test.
	* testsuite/binutils-all/aarch64/sve-dwarf-registers.s: New test.
2019-05-21 11:05:22 +01: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
Sam Tebbs 0903806253 Move aarch64 CIE code to aarch64 backend
This commit moves all aarch64-specific code to deal with CIE structure
introduced in 3a67e1a6b4 from
target-independent files to the aarch64 backend.

2018-12-13  Sam Tebbs  <sam.tebbs@arm.com>

binutils/
	* dwarf.c (read_cie):  Add check for 'B'.

gas/
	* config/tc-aarch64.h (enum pointer_auth_key,
	tc_fde_entry_extras, tc_cie_entry_extras, tc_fde_entry_init_extra,
	tc_output_cie_extra, tc_cie_fde_equivalent_extra,
	tc_cie_entry_init_extra): Define.
	* dw2gencfi.c (struct cie_entry): Add tc_cie_entry_extras invocation.
	(alloc_fde_entry, select_cie_for_fde): Add tc_fde_entry_init_extra
	invocation.
	(output_cie): Add tc_output_cie_extra invocation.
	(select_cie_for_fde): Add tc_cie_fde_equivalent_extra invocation.
	* dw2gencfi.h (enum pointer_auth_key): Move to config/tc-aarch64.h.
	(struct fde_entry): Add tc_fde_entry_extras invocation
2018-12-13 16:37:40 +00:00
John Darrington 17f6ade235 binutils --dwarf=decodedline: Add display of is_stmt flag
binutils/
    * dwarf.c (display_debug_lines_decoded): Add display of is_stmt.
    * testsuite/binutils-all/dw5.W: Deal with the consequences.
    * testsuite/binutils-all/objdump.WL: Deal with the consequences.
2018-09-20 19:02:50 +02:00
Kevin Buettner f384a1f025 Add support for DW_OP_GNU_variable_value to readelf
As indicated by the subject, this patch adds support for the DWARF
expression opcode DW_OP_GNU_variable_value to readelf.

It's pretty much a copy/paste of DW_OP_call_ref with the obvious name
changes for the printf statements.  The FIXME comment comes from that
copy/paste.

binutils/ChangeLog:

	* dwarf.c (decode_location_expresion): Add case for
	DW_OP_GNU_variable_value.
2018-08-08 08:10:36 -07:00
Alan Modra 7b8d9e8cec PR23431, Messages composed from pieces can't be properly translated
PR 23431
	* dwarf.c (display_formatted_table): Replace "what" parameter
	with "is_dir".  Expand messages.  Fix capitalisation.
	* testsuite/binutils-all/dw5.W: Update expected output.
2018-07-24 19:59:11 +09:30
Nick Clifton 3391569f21 Close memory and resource leaks detected by coverity in the binutils directory.
* objcopy.c (add_specific_symbols): Free buffer on exit.
	(add_redefine_syms_file): Close file handle on exit.
	(copy_object): Close file handle on early exit.
	Free buffer on early exit.
	Free gaps buffers once they are no longer needed.
	* dwarf.c (display_debug_frames): Free allocated memory on exit.
	(load_separate_debug_info): Free allocate memory on early exit.
2018-07-20 15:05:34 +01:00
Nick Clifton 442a6ce858 Stop potential memory leaks in dwarf CIE reader.
* dwarf.c (read_cie): Free allocated memory before returning with
	a failure result.
2018-07-19 14:23:31 +01:00
Nick Clifton a7504f87d4 Prevent an assertion failure in readelf & objdump when parsing corrupt DWARF information.
PR 23062
	* dwarf.c (read_and_display_attr_value): Replace assertions with
	test and warning message.
2018-04-18 12:03:03 +01:00
Nick Clifton 6aea08d9f3 Fix illegal memory access when parsing corrupt DWARF information.
PR 23064
	* dwarf.c (process_cu_tu_index): Test for a potential buffer
	overrun before copying signature pointer.
2018-04-17 12:35:55 +01:00
Tom Tromey 2008a0dbe3 Display all DWARF 5 language names
I happened to notice that objdump was not printing "Rust" when showing
the DW_AT_language for a CU:

    <10>   DW_AT_language    : 28	(Unknown: 1c)

This patch adds all the new language constants from DWARF 5 to
binutils/dwarf.c.

2018-04-06  Tom Tromey  <tom@tromey.com>

	* dwarf.c (read_and_display_attr_value): Add missing DW_LANG
	constants from DWARF 5.
2018-04-06 10:58:34 -06:00
Nick Clifton d11ae95ea3 Prevent illegal memory accesses triggerd by intger overflow when parsing corrupt DWARF information on a 32-bit host.
PR 22905
	* dwarf.c (display_debug_ranges): Check that the offset loaded
	from the range_entry structure is valid.
2018-03-01 16:14:08 +00:00
Nick Clifton 8de3a6e2af Speed up readelf and objdump by not looking for DWO links unless the user has requested that they be displayed/followed.
PR 22802
	* dwarf.c (load_separate_debug_file): Return early if the user is
	not interested in debug links.
2018-02-08 12:29:07 +00:00
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