Commit Graph

3721 Commits

Author SHA1 Message Date
Alan Modra 645ba68105 setup_archive parameter mismatch
* elfcomm.c (setup_archive): Make file_size an off_t.  Comment.
	* elfcomm.h (setup_archive): Update prototype.
2020-03-19 11:55:04 +10:30
Alan Modra 28d1356774 asan: readelf leak in hppa_process_unwind
This extracts code reading symbol tables into a common function that
tidies up after errors.  I've also changed an error reporting multiple
string tables to an error on multiple symbol tables.

	* readelf.c (get_symbols): New function.
	(process_relocs, ia64_process_unwind, hppa_process_unwind),
	(arm_process_unwind, get_symbol_for_build_attribute): Use it.
2020-03-16 13:05:17 +10:30
Alan Modra 60e63c3e97 ubsan: shift exponent 70 is too large
* unwind-ia64.c (unw_decode_uleb128): Prevent overlarge shifts.
	Detect shift overflows and check that terminating byte is found.
	Print an error on a bad uleb128.
2020-03-16 13:04:49 +10:30
Alan Modra 1bd6175ae7 Re: asan: more readelf leaks
In git commit fd486f32d1 I put some static variables used by
get_symbol_for_build_attribute in a file scope ba_cache struct.  This
was to prevent leaks in get_symbol_for_build_attribute, and to tidy up
before readelf exited.  The patch wasn't quite right though.  When
readelf processes more than one file it was possible to double free
arrays allocated in get_symbol_for_build_attribute.

	* readelf.c (process_file): Clean ba_cache.
2020-03-14 20:23:52 +10:30
Alan Modra 780f96aed2 readelf large memory allocation
* elfcomm.h (setup_archive): Update prototype.
	* elfcomm.c (setup_archive): Add file_size parameter and sanity
	check longnames_size.
	(setup_nested_archive): Get file size and pass to setup_archive.
	* elfedit.c (process_archive): Likewise.
	* readelf.c (process_archive): Pass filedata->file_size to
	setup_archive.
2020-03-14 17:24:19 +10:30
Alan Modra f761cb13a9 asan: readelf: memory leaks
* readelf.c (dump_section_as_strings): Free memory on error exit.
	(dump_section_as_bytes, process_notes_at): Likewise.
	(get_build_id): Free enote.
2020-03-14 17:24:19 +10:30
Kamil Rytarowski 06d949ec31 Implement NT_NETBSDCORE_LWPSTATUS (NetBSD-Core)
bfd/ChangeLog:

	* elf.c (elfcore_grok_netbsd_note): Add support for
	NT_NETBSDCORE_LWPSTATUS notes.

binutils/ChangeLog:

	* readelf.c (get_netbsd_elfcore_note_type): Add support for
	NT_NETBSDCORE_LWPSTATUS notes.

include/ChangeLog:

	* elf/common.h (NT_NETBSDCORE_LWPSTATUS): New define.
2020-03-14 00:31:16 +01:00
Alan Modra fd486f32d1 asan: more readelf leaks
* elfcomm.c (get_archive_member_name): Always return malloc'd
	string or NULL.
	* elfedit.c (process_archive): Tidy memory on all return paths.
	* readelf.c (process_archive): Likewise.
	(process_symbol_table): Likewise.
	(ba_cache): New, replacing ..
	(get_symbol_for_build_attribute): ..static vars here.  Free
	strtab and symtab before loading new ones.  Reject symtab without
	valid strtab in loop, breaking out of loop on valid symtab.
	(process_file): Free ba_cache symtab and strtab here, resetting
	ba_cache.
2020-03-13 14:26:24 +10:30
Alan Modra 8fb879cd16 asan: readelf leaks
* readelf.c (process_section_headers): Don't just set
	filedata->section_headers NULL, free it first.  Similarly for
	dynamic_symbols, dynamic_strings, dynamic_syminfo and
	symtab_shndx_list.  Zero associated counts too.
	(process_object): Free symtab_shndx_list.
	(process_file): Free various allocated filedata tables.
2020-03-12 17:00:40 +10:30
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
Alan Modra 9cc89dc0ac PR25651, objcopy SIGSEGV in copy_object
With the right set of options, the second block of code dealing with
padding can see a different section count.  So don't use the new count.
Since I was editing those lines, I've also changed the code allocating
arrays a little.
    array = malloc (n * sizeof (*array));
for an array of ints is just better than
    array = malloc (n * sizeof (int));
It's easier to write correctly in the first place and more robust
against code changes that might modify the array element type.

	PR 25651
	* objcopy.c (copy_object): Test "gaps" not gap_fill_set or
	pad_to_set on second block of code dealing with padding.
	Replace "c" with "num_sec" and don't recalculate number of
	sections on second block.  Size arrays using sizeof (element)
	rather than sizeof (element type).
2020-03-11 15:01:15 +10:30
Alan Modra 41da082238 objdump disassembly of files without symbols
ubsan complains about memcpy with a NULL src even when size is zero.

	* objdump.c (disassemble_section): Don't call qsort unless
	sym count is at least two.
	(disassemble_data): Don't call memcpy with NULL src.
2020-03-10 13:54:01 +10:30
Alan Modra 9509988993 PR25645, readelf segfault reading fuzzed alpha-vms binary
PR 25645
	* readelf.c (dump_ia64_vms_dynamic_fixups): Pass size and nmemb
	to get_data rather than multiplying.
	(dump_ia64_vms_dynamic_relocs): Likewise.
	(process_version_sections): Correct order of size and nmemb args
	in get_data call.
	(process_mips_specific): Likewise.
2020-03-09 21:38:48 +10:30
H.J. Lu a15de1f599 readelf.c: Fix a typo in comments
* readelf.c (get_dynamic_data): Replace "memory chekers" with
	"memory checkers" in comments.
2020-03-08 18:43:42 -07:00
Simon Marchi 9979ab6663 binutils: doc: move artifacts back to MAINTAINERCLEANFILES
In commit 2b44a6a237 (" binutils: doc: make `make clean` clean more
things"), I moved the doc build artifacts to MOSTLYCLEANFILES, which
made them get removed by "make clean".

Because generating binutils.info requires makeinfo, and we do not want
to require makeinfo when building from the tarball, binutils.info should
not get removed by "make clean" (otherwise, it won't be included in the
tarball).

And to be consistent with other projects (e.g. ld and gas), we also want
to ship the built man pages in the tarball.

This patch puts back all these in MAINTAINERCLEANFILES, so that they are
bundled in the tarball, and only cleaned if you use "make
maintainer-clean".

Tested by building a source release and confirming they are present.

binutils/ChangeLog:

	PR 25491
	* doc/Makefile.am: Rename MOSTLYCLEANFILES to MAINTAINERCLEANFILES.
	* doc/Makefile.in: Re-generate.
2020-03-06 22:06:34 -05:00
Nick Clifton a0dcf29705 Fix an abort triggered when objcopy is used to set the "share" section flag on an ELF section.
binutils* objcopy.c (check_new_section_flags): New function.  Reject the
	SEC_COFF_SHARED flag if the target is not a COFF binary.
	(copy_object): Call check_new_section_flags.
	(setup_section): Likewise.
	* doc/binutils.texi (objcopy): Add a note that the 'share' section
	flag cannot be applied to ELF binaries.

bfd	* elf.c (_bfd_elf_set_section_contents): Replace call to abort
	with error messages and failure return values.
2020-03-06 10:09:22 +00:00
Alan Modra a9b90127e8 PR25637, objcopy : SIGSEGV in copy_object
PR 25637
	* objcopy.c (filter_symbols): Correct rem_leading_char logic.
2020-03-06 10:34:19 +10:30
Alan Modra d1faf7ca0a PR25629, objcopy : SIGSEGV in filter_symbols
PR 25629
	* objcopy.c (filter_symbols): Don't segfault on NULL
	prefix_symbols_string.
2020-03-05 15:23:22 +10:30
Christian Eggers eef64366e1 objcopy: Fix for pr19005 on machines with more than one octet per byte.
On machines with more than one octet per byte, objcopy fills only a part
of the gap between sections.

	* objcopy.c (copy_object): Convert from bytes to octets for
	--gap-fill and --pad-to.
2020-03-04 10:59:30 +10:30
Nick Clifton 5be2b2f549 Remove a call to abort which can be triggered by running objdump on a corrupt input file.
PR 25625
	* prdbg.c (pr_tag_type): Remove call to abort.
2020-03-03 16:11:12 +00:00
Aaron Merey b312fea191 The procedure to find an unused port for the debuginfod tests is susceptible to a TOCTOU failure. Change port finding in order to avoid this. Also use 'expect' to interact with the server process since we now use the server's output to determine whether a port is in use.
* binutils/testsuite/binutils-all/debuginfod.exp: Improve port
	selection.
2020-03-02 12:46:47 +00:00
Nick Clifton ba3265d04c Restore readelf's string dump to previous behaviour where newlines were caused line breaks.
PR 25543
	* readelf.c (dump_section_as_strings): Display new-line characters
	as \n and then insert a line break.
	* testsuite/binutils-all/pr25543.s: New test.
	* testsuite/binutils-all/pr25543.d: Test driver.
	* testsuite/binutils-all/readelf.exp: Run the new test.
2020-03-02 10:02:02 +00:00
Nick Clifton 736990c442 Fix an illegal memory access by readelf when displaying the contents of a corrupt IA64 binary.
PR 25526
	* readelf.c (process_ia64_vms_dynamic_relocs): Check to see if
	get_data is unable to load the string table.
2020-02-27 16:28:25 +00:00
Alan Modra dc1e8a474f Indent labels
Labels don't go in the first column according to standard emacs C
indent rules, and I got annoyed enough at seeing diff -p show a label
rather than the function name to fix this.

bfd/
	* aoutx.h: Indent labels correctly.  Format error strings.
	* archive.c: Likewise.
	* archive64.c: Likewise.
	* coff-arm.c: Likewise.
	* coff-rs6000.c: Likewise.
	* coff-stgo32.c: Likewise.
	* cpu-arm.c: Likewise.
	* dwarf2.c: Likewise.
	* elf-ifunc.c: Likewise.
	* elf-properties.c: Likewise.
	* elf-s390-common.c: Likewise.
	* elf-strtab.c: Likewise.
	* elf.c: Likewise.
	* elf32-arm.c: Likewise.
	* elf32-bfin.c: Likewise.
	* elf32-cr16.c: Likewise.
	* elf32-csky.c: Likewise.
	* elf32-i386.c: Likewise.
	* elf32-m68k.c: Likewise.
	* elf32-msp430.c: Likewise.
	* elf32-nds32.c: Likewise.
	* elf32-nios2.c: Likewise.
	* elf32-pru.c: Likewise.
	* elf32-xtensa.c: Likewise.
	* elf64-ia64-vms.c: Likewise.
	* elf64-x86-64.c: Likewise.
	* elfcode.h: Likewise.
	* elfcore.h: Likewise.
	* elflink.c: Likewise.
	* elfnn-aarch64.c: Likewise.
	* elfnn-ia64.c: Likewise.
	* elfnn-riscv.c: Likewise.
	* elfxx-mips.c: Likewise.
	* elfxx-sparc.c: Likewise.
	* elfxx-x86.c: Likewise.
	* i386lynx.c: Likewise.
	* merge.c: Likewise.
	* pdp11.c: Likewise.
	* plugin.c: Likewise.
	* reloc.c: Likewise.
binutils/
	* elfedit.c: Indent labels correctly.
	* readelf.c: Likewise.
	* resres.c: Likewise.
gas/
	* config/obj-elf.c: Indent labels correctly.
	* config/obj-macho.c: Likewise.
	* config/tc-aarch64.c: Likewise.
	* config/tc-alpha.c: Likewise.
	* config/tc-arm.c: Likewise.
	* config/tc-cr16.c: Likewise.
	* config/tc-crx.c: Likewise.
	* config/tc-frv.c: Likewise.
	* config/tc-i386-intel.c: Likewise.
	* config/tc-i386.c: Likewise.
	* config/tc-ia64.c: Likewise.
	* config/tc-mn10200.c: Likewise.
	* config/tc-mn10300.c: Likewise.
	* config/tc-nds32.c: Likewise.
	* config/tc-riscv.c: Likewise.
	* config/tc-s12z.c: Likewise.
	* config/tc-xtensa.c: Likewise.
	* config/tc-z80.c: Likewise.
	* read.c: Likewise.
	* symbols.c: Likewise.
	* write.c: Likewise.
ld/
	* emultempl/cskyelf.em: Indent labels correctly.
	* ldfile.c: Likewise.
	* ldlang.c: Likewise.
	* plugin.c: Likewise.
opcodes/
	* aarch64-asm.c: Indent labels correctly.
	* aarch64-dis.c: Likewise.
	* aarch64-gen.c: Likewise.
	* aarch64-opc.c: Likewise.
	* alpha-dis.c: Likewise.
	* i386-dis.c: Likewise.
	* nds32-asm.c: Likewise.
	* nfp-dis.c: Likewise.
	* visium-dis.c: Likewise.
2020-02-26 10:37:25 +10:30
H.J. Lu ecda90163e Don't call lto-wrapper for ar and ranlib
Since ar and ranlib don't need to know symbol types to work properly,
we should avoid calling lto-wrapper for them to speed them up.

bfd/

	PR binutils/25584
	* plugin.c (need_lto_wrapper_p): New.
	(bfd_plugin_set_program_name): Add an int argument to set
	need_lto_wrapper_p.
	(get_lto_wrapper): Return FALSE if need_lto_wrapper_p isn't
	set.
	* plugin.h (bfd_plugin_set_program_name): Add an int argument.

binutils/

	PR binutils/25584
	* ar.c (main): Pass 0 to bfd_plugin_set_program_name.
	* nm.c (main): Pass 1 to bfd_plugin_set_program_name.
2020-02-25 03:31:40 -08:00
Nick Clifton 83d4d556e2 Fix a spelling mistake in the binutils documentation.
PR 25499
	* doc/binutils.texi (objdump): Fix typo in description of
	objdump's -g option.
2020-02-24 14:39:34 +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
Eric Christopher 741cb83912 2020-02-19 Jordan Rupprecht <rupprecht@google.com>
* objdump.c (show_line): call bfd_demangle when using do_demangle.
2020-02-19 13:57:26 -08:00
Andrew Burgess 9f1528a1bd Merge changes from GCC for the config/ directory
GCC's config/ChangeLog since the last time this merge was done
(in the binutils-gdb commit 0b4d000cc4) is included at the
end of this commit message.

It is worth noting that the binutils-gdb commit 301a9420d9
added the file config/debuginfod.m4 which is not present in GCC's
config/ directory.  This file is preserved, unmodified, after this
commit.

In order to regenerate all of the configure files, I configured with
--enable-maintainer-mode, and built the 'all' target.  I then did the
same thing on a source tree without this patch, and only committed
those files that changed when this patch was added.

GCC's config/ChangeLog entries:

  2020-02-12  Sandra Loosemore  <sandra@codesourcery.com>

  	PR libstdc++/79193
  	PR libstdc++/88999

  	* no-executables.m4: Use a non-empty program to test for linker
  	support.

  2020-02-01  Andrew Burgess  <andrew.burgess@embecosm.com>

  	* lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Update shell syntax.

  2020-01-27  Andrew Burgess  <andrew.burgess@embecosm.com>

  	* lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Add new
  	--with-libXXX-type=... option.  Use this to guide the selection of
  	either a shared library or a static library.

  2020-01-24  Maciej W. Rozycki  <macro@wdc.com>

  	* toolexeclibdir.m4: New file.

  2019-09-10  Christophe Lyon  <christophe.lyon@st.com>

  	* futex.m4: Handle *-uclinux*.
  	* tls.m4 (GCC_CHECK_TLS): Likewise.

  2019-09-06  Florian Weimer  <fweimer@redhat.com>

  	* futex.m4 (GCC_LINUX_FUTEX): Include <unistd.h> for the syscall
  	function.

  2019-07-08  Richard Sandiford  <richard.sandiford@arm.com>

  	* bootstrap-Og.mk: New file.

  2019-06-25  Kwok Cheung Yeung  <kcy@codesourcery.com>
              Andrew Stubbs  <ams@codesourcery.com>

  	* gthr.m4 (GCC_AC_THREAD_HEADER): Add case for gcn.

  2019-05-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

  	* ax_count_cpus.m4: New file.

  2019-05-02  Richard Biener  <rguenther@suse.de>

  	PR bootstrap/85574
  	* bootstrap-lto.mk (extra-compare): Set to gcc/lto1$(exeext).

  2019-04-16  Martin Liska  <mliska@suse.cz>

  	* bootstrap-lto-lean.mk: Filter out -flto in STAGEtrain_CFLAGS.

  2019-04-09  Martin Liska  <mliska@suse.cz>

  	* bootstrap-lto-lean.mk: New file.

  2019-03-02  Johannes Pfau  <johannespfau@gmail.com>

  	* mh-mingw: Also set __USE_MINGW_ACCESS flag for C++ code.

  2018-10-31  Joseph Myers  <joseph@codesourcery.com>

  	PR bootstrap/82856
  	* math.m4, tls.m4: Use AC_LANG_SOURCE.

  	Merge from binutils-gdb:
  	2018-06-19  Simon Marchi  <simon.marchi@ericsson.com>

  	* override.m4 (_GCC_AUTOCONF_VERSION): Bump from 2.64 to 2.69.

config/ChangeLog:

	* ax_count_cpus.m4: New file, backported from GCC.
	* bootstrap-Og.mk: New file, backported from GCC.
	* bootstrap-lto-lean.mk: New file, backported from GCC.
	* bootstrap-lto.mk: Changes backported from GCC.
	* futex.m4: Changes backported from GCC.
	* gthr.m4: Changes backported from GCC.
	* lib-link.m4: Changes backported from GCC.
	* mh-mingw: Changes backported from GCC.
	* no-executables.m4: Changes backported from GCC.
	* tls.m4: Changes backported from GCC.
	* toolexeclibdir.m4: New file, backported from GCC.

binutils/ChangeLog:

	* configure: Regenerate.

gdb/ChangeLog:

	* configure: Regenerate.

gdbserver/ChangeLog:

	* configure: Regenerate.

gdbsupport/ChangeLog:

	* configure: Regenerate.

intl/ChangeLog:

	* configure: Regenerate.

libiberty/ChangeLog:

	* configure: Regenerate.

zlib/ChangeLog.bin-gdb:

	* configure: Regenerate.
2020-02-19 17:51:24 +00:00
Fangrui Song 3a5d12fbb4 Allow objcopy's --set-section-flags options to add or remove the SHF_EXCLUDE flag of ELF sections.
* objcopy.c (parse_flags): Handle "exclude".
	* doc/binutils.texi: Document the support.
2020-02-10 16:22:00 +00:00
Aaron Merey 46471187e4 More debuginfod tests fixes.
Start server before setting environment variable.
	Specify tmpdir as the location of the server's
	database.
	Check additional server metrics at start-up.
2020-02-10 15:24:57 +00:00
Aaron Merey 678d457fb7 Fix potential problem with binutils debuginfod tests.
* binutils/testsuite/binutils-all/debuginfod.exp:
	Replace set ::env with setenv.
2020-02-10 15:20:41 +00:00
Nick Clifton e8319fde71 Update release making notes.
* README-how-to-make-a-release: Add note about updating the
  GAS/NEWS URL in the next release.
2020-02-07 15:33:45 +00:00
Sergey Belyashov 9fc0b501af Add support for the GBZ80 and Z80N variants of the Z80 architecture, and add DWARF debug info support to the Z80 assembler.
PR 25469
bfd	* archures.c: Add GBZ80 and Z80N machine values.
	* reloc.c: Add BFD_RELOC_Z80_16_BE.
	* coff-z80.c: Add support for new reloc.
	* coffcode.h: Add support for new machine values.
	* cpu-z80.c: Add support for new machine names.
	* elf32-z80.c: Add support for new reloc.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.

binutils* readelf.c (get_machine_flags): Add support for Z80N machine
	number.

gas	* config/tc-z80.c: Add -gbz80 command line option to generate code
	for the GameBoy Z80.  Add support for generating DWARF.
	* config/tc-z80.h: Add support for DWARF debug information
	generation.
	* doc/c-z80.texi: Document new command line option.
	* testsuite/gas/z80/gbz80_all.d: New file.
	* testsuite/gas/z80/gbz80_all.s: New file.
	* testsuite/gas/z80/z80.exp: Run the new tests.
	* testsuite/gas/z80/z80n_all.d: New file.
	* testsuite/gas/z80/z80n_all.s: New file.
	* testsuite/gas/z80/z80n_reloc.d: New file.

include	* coff/internal.h (R_IMM16BE): Define.
	* elf/z80.h (EF_Z80_MACH_Z80N): Define.
	(R_Z80_16_BE): New reloc.

ld	* emulparams/elf32z80.sh: Use z80 emulation.
	* emultempl/z80.em: Make generic to both COFF and ELF Z80 emulations.
	* emultempl/z80elf.em: Delete.
	* testsuite/ld-elf/pr22450.d: Expect to fail for the Z80.
	* testsuite/ld-elf/sec64k.exp: Fix Z80 assembly.
	* testsuite/ld-unique/pr21529.s: Avoid register name conflict.
	* testsuite/ld-unique/unique.s: Likewise.
	* testsuite/ld-unique/unique_empty.s: Likewise.
	* testsuite/ld-unique/unique_shared.s: Likewise.
	* testsuite/ld-unique/unique.d: Updated expected output.
	* testsuite/ld-z80/arch_z80n.d: New file.
	* testsuite/ld-z80/comb_arch_z80_z80n.d: New file.
	* testsuite/ld-z80/labels.s: Add more labels.
	* testsuite/ld-z80/relocs.s: Add more reloc tests.
	* testsuite/ld-z80/relocs_f_z80n.d: New file

opcodes	* z80-dis.c: Add support for GBZ80 opcodes.
2020-02-07 14:53:46 +00: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
Nick Clifton c2e6f74465 Fix attributation of previous delta 2020-02-06 13:34:00 +00:00
Thomas Troeger ece128295e Jump visualization: Handle the case where the disassembled bytes occupy two lines.
* objdump.c (print_jump_visualisation): New function.
	(disassemble_bytes): Call new function.
2020-02-06 13:17:19 +00:00
Alan Modra 02e0be6901 mbind gas tests and supports_gnu_osabi testsuite infrastructure
With the addition of section16 tests we have multiple tests
advertising themselves as "mbind sections" and "mbind section
contents".  This patch fixes that, and fails on quite a few targets
that force an OSABI value.  It's a pain specifying all the relevant
arm targets on an xfail line, so I wrote supports_gnu_osabi.

binutils/
	* testsuite/lib/binutils-common.exp (match_target): Accept '!' before
	TCL procedure.
	(supports_gnu_osabi): New procedure.
	(is_generic): New, from ld-lib.exp.
	(supports_gnu_unique): Use the above.
gas/
	* testsuite/gas/elf/section12a.d: Use supports_gnu_osabi in
	xfail, and rename test.
	* testsuite/gas/elf/section12b.d: Likewise.
	* testsuite/gas/elf/section16a.d: Likewise.
	* testsuite/gas/elf/section16b.d: Likewise.
ld/
	* testsuite/lib/ld-lib.exp (is_generic): Delete.
	* testsuite/ld-unique/unique.exp: Exclude tic6x.
2020-02-06 13:57:37 +10:30
Alan Modra e8b791227f Missing objdump dependency od-elf32_avr
* Makefile.am (CFILES): Add od-elf32_avr.c.
	* Makefile.in: Regenerate.
	* po/POTFILES.in: Regenerate.
2020-02-04 21:56:29 +10:30
Andreas Schwab 27a45f4276 readelf: add missing newlines to error messages
* readelf.c (dump_relocations, dump_relocations)
	(decode_arm_unwind_bytecode, process_dynamic_section)
	(get_symbol_visibility, get_alpha_symbol_other): Add newline to
	error message.
2020-02-03 19:06:41 +01:00
Sergei Trofimovich 0b398d69ac binutils: drop redundant 'program_name' definition (-fno-common)
* coffdump.c (program_name): Drop redundant definition.
	* srconv.c (program_name): Likewise
	* sysdump.c (program_name): Likewise

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
2020-02-03 15:59:14 +10:30
H.J. Lu a8c4d40b57 ELF: Add support for unique section ID to assembler
Clang's integrated assembler supports multiple section with the same
name:

	.section .text,"ax",@progbits,unique,1
	nop
	.section .text,"ax",@progbits,unique,2
	nop

"unique,N" assigns the number, N, as the section ID, to a section.  The
valid values of the section ID are between 0 and 4294967295.  It can be
used to distinguish different sections with the same section name.

This is useful with -fno-unique-section-names -ffunction-sections.
-ffunction-sections by default generates .text.foo, .text.bar, etc.
Using the same string can save lots of space in .strtab.

This patch adds section_id to bfd_section and reuses the linker
internal bit in BFD section flags, SEC_LINKER_CREATED, for assmebler
internal use to mark valid section_id.  It also updates objdump to
compare section pointers if 2 sections comes from the same file since
2 different sections can have the same section name.

bfd/

	PR gas/25380
	* bfd-in2.h: Regenerated.
	* ecoff.c (bfd_debug_section): Add section_id.
	* section.c (bfd_section): Add section_id.
	(SEC_ASSEMBLER_SECTION_ID): New.
	(BFD_FAKE_SECTION): Add section_id.

binutils/

	PR gas/25380
	* objdump.c (sym_ok): Return FALSE if 2 sections are in the
	same file with different section pointers.

gas/

	PR gas/25380
	* config/obj-elf.c (section_match): Removed.
	(get_section): Also match SEC_ASSEMBLER_SECTION_ID and
	section_id.
	(obj_elf_change_section): Replace info and group_name arguments
	with match_p.  Also update the section ID and flags from match_p.
	(obj_elf_section): Handle "unique,N".  Update call to
	obj_elf_change_section.
	* config/obj-elf.h (elf_section_match): New.
	(obj_elf_change_section): Updated.
	* config/tc-arm.c (start_unwind_section): Update call to
	obj_elf_change_section.
	* config/tc-ia64.c (obj_elf_vms_common): Likewise.
	* config/tc-microblaze.c (microblaze_s_data): Likewise.
	(microblaze_s_sdata): Likewise.
	(microblaze_s_rdata): Likewise.
	(microblaze_s_bss): Likewise.
	* config/tc-mips.c (s_change_section): Likewise.
	* config/tc-msp430.c (msp430_profiler): Likewise.
	* config/tc-rx.c (parse_rx_section): Likewise.
	* config/tc-tic6x.c (tic6x_start_unwind_section): Likewise.
	* doc/as.texi: Document "unique,N" in .section directive.
	* testsuite/gas/elf/elf.exp: Run "unique,N" tests.
	* testsuite/gas/elf/section15.d: New file.
	* testsuite/gas/elf/section15.s: Likewise.
	* testsuite/gas/elf/section16.s: Likewise.
	* testsuite/gas/elf/section16a.d: Likewise.
	* testsuite/gas/elf/section16b.d: Likewise.
	* testsuite/gas/elf/section17.d: Likewise.
	* testsuite/gas/elf/section17.l: Likewise.
	* testsuite/gas/elf/section17.s: Likewise.
	* testsuite/gas/i386/unique.d: Likewise.
	* testsuite/gas/i386/unique.s: Likewise.
	* testsuite/gas/i386/x86-64-unique.d: Likewise.
	* testsuite/gas/i386/i386.exp: Run unique and x86-64-unique.

ld/

	PR gas/25380
	* testsuite/ld-i386/pr22001-1c.S: Use "unique,N" in .section
	directives.
	* testsuite/ld-i386/tls-gd1.S: Likewise.
	* testsuite/ld-x86-64/pr21481b.S: Likewise.
2020-02-02 17:08:01 -08:00
Nick Clifton cb6ad9bb59 Update release making documentation 2020-02-01 13:14:16 +00:00
Nick Clifton 53943f32cc Updated translations for some of the binutils sub-directories 2020-01-31 14:45:51 +00:00
Nick Clifton 55be8fd0d2 Improve warning message from debuginfod support in readelf.
* readelf.c (get_build_id): Simplify warning message about corrupt
	notes encountered whilst scanning for the build-id.
2020-01-28 11:30:55 +00:00
Roland McGrath 82ef9cad78 Fix objcopy --merge-notes dependency on qsort implementation behavior.
binutils/
	* objcopy.c (compare_gnu_build_notes): Fix comparison results
	for overlapping ranges so that (A == B) == (B == A) holds.
2020-01-27 11:14:33 -08:00
Alan Modra e3696f67ab Replace deprecated tcl case statements with switch statements
binutils/
	* testsuite/lib/binutils-common.exp (big_or_little_endian): Replace
	case statement with switch statement.
gas/
	* testsuite/gas/all/gas.exp: Replace case statements with switch
	statements.
	* testsuite/gas/elf/elf.exp: Likewise.
	* testsuite/gas/macros/macros.exp: Likewise.
	* testsuite/lib/gas-defs.exp: Likewise.
ld/
	* testsuite/ld-elfvers/vers.exp: Replace case statements with
	switch statements.
	* testsuite/ld-ifunc/ifunc.exp: Likewise.
	* testsuite/ld-unique/unique.exp: Likewise.
2020-01-27 22:52:15 +10:30
Nick Clifton 2f796de6da Fix issue with warning messages about corrupt debuginfod notes.
* readelf.c (get_build_id): Fix warning messages about corrupt
	notes.
2020-01-24 11:55:12 +00:00
Nick Clifton 24e648d4b8 Updated translations for various binutils sub-directories. 2020-01-23 14:33:36 +00:00
Yuri Chornoivan c48acf6f26 PR25417, Fix minor typos
PR 25417
binutils/
	* readelf.c (get_alpha_symbol_other): Fix error message typo.
ld/
	* ldlang.c (ldlang_open_ctf): Fix error message typo.
	* emultempl/z80elf.em (z80_elf_after_open): Likewise.
2020-01-22 17:14:08 +10:30
Nick Clifton 26916852e1 Updated translations for various binutils sub-directories 2020-01-20 15:10:23 +00:00
Nick Clifton b248e9ce9a Update the notes on how to create a branch prior to a new release. 2020-01-18 14:37:55 +00:00
Nick Clifton 1b1bb2c67b Update version to 2.34.50. Regenerate configure and .pot files. 2020-01-18 14:12:07 +00:00
Nick Clifton ae77468624 Add markers for 2.34 branch to the NEWS files and ChangeLogs. 2020-01-18 13:50:25 +00:00
Thomas Troeger 82a9ed2050 Improve the performance of the ascii art jump visualizer.
* objdump.c (jump_info_visualize_address): Discard jumps that are
	no longer needed.
	(disassemble_bytes): Only compute the maximum level if jumps were
	detected.
2020-01-17 15:27:31 +00:00
Nick Clifton c87c17c1c2 Moev declaration of loop variable outside of the loop.
* objdump.c (disassemble_bytes): Remove C99-ism.
2020-01-13 17:28:41 +00:00
Nick Clifton 6a1939f577 Add test driver for the debuginfod support in the binutils sub-directory.
* testsuite/binutils-all/debuginfod.exp: New tests.
2020-01-13 15:18:57 +00:00
Thomas Troeger 1d67fe3b6e Add an option to objdump's disassembler to generate ascii art diagrams showing the destinations of flow control instructions.
binutils* objdump.c (visualize_jumps, color_output, extended_color_output)
	(detected_jumps): New variables.
	(usage): Add the new jump visualization options.
	(option_values): Add new option value.
	(long_options): Add the new option.
	(jump_info_new, jump_info_free): New functions.
	(jump_info_min_address, jump_info_max_address): Likewise.
	(jump_info_end_address, jump_info_is_start_address): Likewise.
	(jump_info_is_end_address, jump_info_size): Likewise.
	(jump_info_unlink, jump_info_insert): Likewise.
	(jump_info_add_front, jump_info_move_linked): Likewise.
	(jump_info_intersect, jump_info_merge): Likewise.
	(jump_info_sort, jump_info_visualize_address): Likewise.
	(disassemble_jumps): New function - used to locate jumps.
	(disassemble_bytes): Add ascii art generation.
	(disassemble_section): Add scan to locate jumps.
	(main): Parse the new visualization option.
	* doc/binutils.texi: Document the new feature.
	* NEWS: Mention the new feature.

opcodes	* arm-dis.c (print_insn_arm): Fill in insn info fields for control
	flow instructions.
	(print_insn_thumb16, print_insn_thumb32): Likewise.
	(print_insn): Initialize the insn info.
	* i386-dis.c (print_insn): Initialize the insn info fields, and
	detect jumps.
2020-01-13 12:36:55 +00:00
Alan Modra a4f2b7c5d9 Re: PR23560, PR23561, readelf memory leaks
PR 25360
	PR 25361
	Dyslexia strikes again.

Fix git commit a788aedd86 ChangeLog.
2020-01-13 22:56:16 +10:30
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
Alan Modra 805f38bc55 PR25362, memory leak in nm
PR 25362
	* nm.c (display_rel_file): Free dyn_syms.
2020-01-13 22:36:07 +10:30
Nick Clifton ffebb0bbde Fix an attempt to free a static pointer when using objcopy's symbol addition feature.
PR 25220
	* objcopy.c (empty_name): New variable.
	(need_sym_before): Prevent an attempt to free a static variable.
	(filter_symbols): Avoid strcmp test by checking for pointer
	equality.
2020-01-09 16:51:04 +00:00
Nick Clifton ade4fd9ba4 Update Traditional Chinese translation for the binutils sub-directory.
* po/zh_TW.po: Updated Traditional Chinese translation.
2020-01-09 13:36:22 +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
Jan Beulich 4bb7a87e74 Mach-O: misc build adjustments
Oldish gcc warns about local variables shadowing outer scope ones.
Additionally %lx is not (always) suitable to print the result of
bfd_get_32().
2020-01-03 10:11:50 +01:00
Sergey Belyashov 6655dba246 Add support for the GBZ80, Z180, and eZ80 variants of the Z80 architecure. Add an ELF based target for these as well.
PR 25224
bfd	* Makefile.am: Add z80-elf target support.
	* configure.ac: Likewise.
	* targets.c: Likewise.
	* config.bfd: Add z80-elf target support and new arches: ez80 and z180.
	* elf32-z80.c: New file.
	* archures.c: Add new z80 architectures: eZ80 and Z180.
	* coffcode.h: Likewise.
	* cpu-z80.c: Likewise.
	* bfd-in2.h: Likewise plus additional Z80 relocations.
	* coff-z80.c: Add new relocations for Z80 target and local label check.

gas	* config/tc-z80.c: Add new architectures: Z180 and eZ80. Add support
	for assembler code generated by SDCC. Add new relocation types. Add
	z80-elf target support.
	* config/tc-z80.h: Add z80-elf target support. Enable dollar local
	labels. Local labels starts from ".L".
	* testsuite/gas/all/fwdexp.d: Fix failure due to symbol conflict.
	* testsuite/gas/all/fwdexp.s: Likewise.
	* testsuite/gas/z80/suffix.d: Fix failure on ELF target.
	* testsuite/gas/z80/z80.exp: Add new tests
	* testsuite/gas/z80/dollar.d: New file.
	* testsuite/gas/z80/dollar.s: New file.
	* testsuite/gas/z80/ez80_adl_all.d: New file.
	* testsuite/gas/z80/ez80_adl_all.s: New file.
	* testsuite/gas/z80/ez80_adl_suf.d: New file.
	* testsuite/gas/z80/ez80_isuf.s: New file.
	* testsuite/gas/z80/ez80_z80_all.d: New file.
	* testsuite/gas/z80/ez80_z80_all.s: New file.
	* testsuite/gas/z80/ez80_z80_suf.d: New file.
	* testsuite/gas/z80/r800_extra.d: New file.
	* testsuite/gas/z80/r800_extra.s: New file.
	* testsuite/gas/z80/r800_ii8.d: New file.
	* testsuite/gas/z80/r800_z80_doc.d: New file.
	* testsuite/gas/z80/z180.d: New file.
	* testsuite/gas/z80/z180.s: New file.
	* testsuite/gas/z80/z180_z80_doc.d: New file.
	* testsuite/gas/z80/z80_doc.d: New file.
	* testsuite/gas/z80/z80_doc.s: New file.
	* testsuite/gas/z80/z80_ii8.d: New file.
	* testsuite/gas/z80/z80_ii8.s: New file.
	* testsuite/gas/z80/z80_in_f_c.d: New file.
	* testsuite/gas/z80/z80_in_f_c.s: New file.
	* testsuite/gas/z80/z80_op_ii_ld.d: New file.
	* testsuite/gas/z80/z80_op_ii_ld.s: New file.
	* testsuite/gas/z80/z80_out_c_0.d: New file.
	* testsuite/gas/z80/z80_out_c_0.s: New file.
	* testsuite/gas/z80/z80_reloc.d: New file.
	* testsuite/gas/z80/z80_reloc.s: New file.
	* testsuite/gas/z80/z80_sli.d: New file.
	* testsuite/gas/z80/z80_sli.s: New file.

ld	* Makefile.am: Add new target z80-elf
	* configure.tgt: Likewise.
	* emultempl/z80.em: Add support for eZ80 and Z180 architectures.
	* emulparams/elf32z80.sh: New file.
	* emultempl/z80elf.em: Likewise.
	* testsuite/ld-z80/arch_ez80_adl.d: Likewise.
	* testsuite/ld-z80/arch_ez80_z80.d: Likewise.
	* testsuite/ld-z80/arch_r800.d: Likewise.
	* testsuite/ld-z80/arch_z180.d: Likewise.
	* testsuite/ld-z80/arch_z80.d: Likewise.
	* testsuite/ld-z80/comb_arch_ez80_z80.d: Likewise.
	* testsuite/ld-z80/comb_arch_z180.d: Likewise.
	* testsuite/ld-z80/labels.s: Likewise.
	* testsuite/ld-z80/relocs.s: Likewise.
	* testsuite/ld-z80/relocs_b_ez80.d: Likewise.
	* testsuite/ld-z80/relocs_b_z80.d: Likewise.
	* testsuite/ld-z80/relocs_f_z80.d: Likewise.
	* testsuite/ld-z80/z80.exp: Likewise.

opcodes	* z80-dis.c: Add support for eZ80 and Z80 instructions.
2020-01-02 14:14:59 +00:00
Alan Modra b14ce8bfe1 Re: Update year range in copyright notice of binutils files
Add the ChangeLog entry.
2020-01-01 18:55:18 +10:30
Alan Modra b3adc24a07 Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
Alan Modra 0b11474080 ChangeLog rotation 2020-01-01 18:12:08 +10:30
Alan Modra 5ad8755225 Re: Revise sleb128 and uleb128 reader
A missing part of git commit cd30bcef4a.

	* od-macho.c: Include elfcomm.h.
	(dump_dyld_info_rebase, dump_dyld_info_bind): Fix read_leb128 args.
	(dump_dyld_info_export_1, dump_segment_split_info): Likewise.
2019-12-30 09:35:29 +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
Alan Modra 660df28acf Prefer object over notype symbols when disassembling
Changing objdump disassembly output like this always requires some
testsuite changes, with the avr and x64_64 changes simply due to
picking up better symbols, the whole point of the patch.

The mips changes are due to mips-sgi-irix changing STT_NOTYPE symbols
to STT_OBJECT, which objdump now chooses in preference to script
symbols.  The problem is that objdump looks at the first symbol in the
section being disassembled, and if object type, just dumps out bytes
rather than disassembling.  This results in new failures:

FAIL: JAL overflow 2
FAIL: undefined weak symbol overflow
FAIL: undefined weak symbol overflow (n32)
FAIL: undefined weak symbol overflow (n64)

So for mips-sgi-irix function symbols really do need to be function
type.  I fixed a few more than just the required minimum to avoid the
above test fails.

binutils/
	* objdump.c (compare_section): New static var.
	(compare_symbols): Sort by current section only.  Don't access
	symbol name out of bounds when checking for file symbols.
	Sort section symbols and object symbols.
	(find_symbol_for_address): Remove bogus debugging and section
	symbol test.
	(disassemble_data): Move symbol sort from here..
	(disassemble_section): ..to here.  Set compare_section.
ld/
	* testsuite/ld-avr/lds-mega.d: Adjust symbols to suit objdump change.
	* testsuite/ld-avr/lds-tiny.d: Likewise.
	* testsuite/ld-x86-64/load2.d: Likewise.
	* testsuite/ld-mips-elf/compact-eh1.s: Give function symbols
	function type.
	* testsuite/ld-mips-elf/compact-eh1a.s: Likewise.
	* testsuite/ld-mips-elf/compact-eh1b.s: Likewise.
	* testsuite/ld-mips-elf/compact-eh2.s: Likewise.
	* testsuite/ld-mips-elf/compact-eh3.s: Likewise.
	* testsuite/ld-mips-elf/compact-eh3a.s: Likewise.
	* testsuite/ld-mips-elf/eh-frame5.s: Likewise.
	* testsuite/ld-mips-elf/ehdr_start-new.s: Likewise.
	* testsuite/ld-mips-elf/ehdr_start-o32.s: Likewise.
	* testsuite/ld-mips-elf/emit-relocs-1a.s: Likewise.
	* testsuite/ld-mips-elf/jaloverflow-2.s: Likewise.
	* testsuite/ld-mips-elf/jaloverflow.s: Likewise.
	* testsuite/ld-mips-elf/mips16-call-global-1.s: Likewise.
	* testsuite/ld-mips-elf/mips16-intermix-1.s: Likewise.
	* testsuite/ld-mips-elf/mips16-pic-1b.s: Likewise.
	* testsuite/ld-mips-elf/mips16-pic-4c.s: Likewise.
	* testsuite/ld-mips-elf/no-shared-1-n64.s: Likewise.
	* testsuite/ld-mips-elf/no-shared-1-o32.s: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-1b-micromips.s: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-1b.s: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-2a.s: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-3b.s: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-4b.s: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-5a.s: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-6-n32c.s: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-6-n64c.s: Likewise.
	* testsuite/ld-mips-elf/pic-and-nonpic-6-o32c.s: Likewise.
	* testsuite/ld-mips-elf/pie.s: Likewise.
	* testsuite/ld-mips-elf/relax-jalr.s: Likewise.
	* testsuite/ld-mips-elf/reloc-1a.s: Likewise.
	* testsuite/ld-mips-elf/reloc-2a.s: Likewise.
	* testsuite/ld-mips-elf/reloc-4.s: Likewise.
	* testsuite/ld-mips-elf/reloc-5.s: Likewise.
	* testsuite/ld-mips-elf/reloc-6b.s: Likewise.
	* testsuite/ld-mips-elf/textrel-1.s: Likewise.
	* testsuite/ld-mips-elf/undefweak-overflow.s: Likewise.
	* testsuite/ld-mips-elf/undefweak-overflow.d: Adjust.
2019-12-17 20:43:00 +10:30
Alan Modra 5b660084e2 Remove tic80 support
This is one way of fixing ubsan bug reports, just delete the code.

The assembler support was removed back in 2005 along with other
non-BFD assemblers, but somehow the remainder of the port stayed in.

bfd/
	* coff-tic80.c: Delete file.
	* cpu-tic80.c: Delete file.
	* archures.c: Remove tic80 support.
	* coffcode.h: Likewise.
	* coffswap.h: Likewise.
	* targets.c: Likewise.
	* config.bfd: Likewise.
	* configure.ac: Likewise.
	* Makefile.am: Likewise.
	* Makefile.in: Regenerate.
	* bfd-in2.h: Regenerate.
	* configure: Regenerate.
	* po/SRC-POTFILES.in: Regenerate.
binutils/
	* testsuite/binutils-all/objcopy.exp: Remove tic80 support.
	* testsuite/binutils-all/objdump.exp: Likewise.
gas/
	* doc/as.texi: Remove mention of tic80.
include/
	* coff/tic80.h: Delete file.
	* opcode/tic80.h: Delete file.
ld/
	* emulparams/tic80coff.sh: Delete file.
	* scripttempl/tic80coff.sc: Delete file.
	* configure.tgt: Remove tic80 support.
	* Makefile.am: Likewise.
	* Makefile.in: Regenerate.
	* po/BLD-POTFILES.in: Regenerate.
opcodes/
	* tic80-dis.c: Delete file.
	* tic80-opc.c: Delete file.
	* disassemble.c: Remove tic80 support.
	* disassemble.h: Likewise.
	* Makefile.am: Likewise.
	* configure.ac: Likewise.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* po/POTFILES.in: Regenerate.
2019-12-17 16:36:54 +10:30
Alan Modra 09c7848734 Make bfd_get_8 return a bfd_vma like other bfd_get_* functions
And similarly for bfd_get_signed_8.

bfd/
	* libbfd.c (bfd_get_8): Return a bfd_vma.
	(bfd_get_signed_8): Return a bfd_signed_vma.
	* bfd-in2.h: Regenerate.
binutils/
	* od-xcoff.c (dump_dumpx_core): Adjust for bfd_h_get_8 change.
2019-12-11 21:14:19 +10:30
Alan Modra 20135676fc PR24960, Memory leak from disassembler
PR 24960
include/
	* dis-asm.h (disassemble_free_target): Declare.
opcodes/
	* disassemble.c (disassemble_free_target): New function.
binutils/
	* objdump.c (disassemble_data): Call disassemble_free_target.
2019-12-10 09:07:29 +10:30
Alan Modra f59f89789f Delete duplicate struct objdump_disasm_info field
objdump_disasm_info.sec duplicates disassemble_info.section

	* objdump.c (struct objdump_disasm_info): Delete "sec".
	(find_symbol_for_address): Use inf->section rather than aux->sec.
	(objdump_print_addr, disassemble_bytes): Likewise.
	(disassemble_section): Don't set aux->sec.
2019-12-10 09:01:12 +10:30
Alan Modra bc754168c7 Optional matching for run_dump_test
This adds an alternative to using #... in dump files, useful where we
only want to allow specific extra output.  DW_CFA_nop in CIEs and FDEs
to pad out to required alignment (larger for 64-bit than 32-bit) is
an example where these optional match patterns are useful.

binutils/
	* testsuite/lib/binutils-common.exp (regexp_diff): Support #?REGEXP.
ld/
	* testsuite/ld-elf/eh4.d: Match optional padding DW_CFA_nop in FDEs.
	* testsuite/ld-elf/eh5.d: Likewise, and extra CIEs emitted on
	embedded targets.
2019-12-08 22:03:53 +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
Christian Eggers 618265039f Introduce new section flag: SEC_ELF_OCTETS
All symbols, sizes and relocations in this section are octets instead of
bytes.  Required for DWARF debug sections as DWARF information is
organized in octets, not bytes.

bfd/
	* section.c (struct bfd_section): New flag SEC_ELF_OCTETS.
	* archures.c (bfd_octets_per_byte): New parameter sec.
	If section is not NULL and SEC_ELF_OCTETS is set, one octet es
	returned [ELF targets only].
	* bfd.c (bfd_get_section_limit): Provide section parameter to
	bfd_octets_per_byte.
	* bfd-in2.h: regenerate.
	* binary.c (binary_set_section_contents): Move call to
	bfd_octets_per_byte into section loop. Provide section parameter
	to bfd_octets_per_byte.
	* coff-arm.c (coff_arm_reloc): Provide section parameter
	to bfd_octets_per_byte.
	* coff-i386.c (coff_i386_reloc): likewise.
	* coff-mips.c (mips_reflo_reloc): likewise.
	* coff-x86_64.c (coff_amd64_reloc): likewise.
	* cofflink.c (_bfd_coff_link_input_bfd): likewise.
	(_bfd_coff_reloc_link_order): likewise.
	* elf.c (_bfd_elf_section_offset): likewise.
	(_bfd_elf_make_section_from_shdr): likewise.
	Set SEC_ELF_OCTETS for sections with names .gnu.build.attributes,
	.debug*, .zdebug* and .note.gnu*.
	* elf32-msp430.c (rl78_sym_diff_handler): Provide section parameter
	to bfd_octets_per_byte.
	* elf32-nds.c (nds32_elf_get_relocated_section_contents): likewise.
	* elf32-ppc.c (ppc_elf_addr16_ha_reloc): likewise.
	* elf32-pru.c (pru_elf32_do_ldi32_relocate): likewise.
	* elf32-s12z.c (opru18_reloc): likewise.
	* elf32-sh.c (sh_elf_reloc): likewise.
	* elf32-spu.c (spu_elf_rel9): likewise.
	* elf32-xtensa.c (bfd_elf_xtensa_reloc): likewise
	* elf64-ppc.c (ppc64_elf_brtaken_reloc): likewise.
	(ppc64_elf_addr16_ha_reloc): likewise.
	(ppc64_elf_toc64_reloc): likewise.
	* elflink.c (bfd_elf_final_link): likewise.
	(bfd_elf_perform_complex_relocation): likewise.
	(elf_fixup_link_order): likewise.
	(elf_link_input_bfd): likewise.
	(elf_link_sort_relocs): likewise.
	(elf_reloc_link_order): likewise.
	(resolve_section): likewise.
	* linker.c (_bfd_generic_reloc_link_order): likewise.
	(bfd_generic_define_common_symbol): likewise.
	(default_data_link_order): likewise.
	(default_indirect_link_order): likewise.
	* srec.c (srec_set_section_contents): likewise.
	(srec_write_section): likewise.
	* syms.c (_bfd_stab_section_find_nearest_line): likewise.
	* reloc.c (_bfd_final_link_relocate): likewise.
	(bfd_generic_get_relocated_section_contents): likewise.
	(bfd_install_relocation): likewise.
	For section which have SEC_ELF_OCTETS set, multiply output_base
	and output_offset with bfd_octets_per_byte.
	(bfd_perform_relocation): likewise.
include/
	* coff/ti.h (GET_SCNHDR_SIZE, PUT_SCNHDR_SIZE, GET_SCN_SCNLEN),
	(PUT_SCN_SCNLEN): Adjust bfd_octets_per_byte calls.
binutils/
	* objdump.c (disassemble_data): Provide section parameter to
	bfd_octets_per_byte.
	(dump_section): likewise
	(dump_section_header): likewise. Show SEC_ELF_OCTETS flag if set.
gas/
	* as.h: Define SEC_OCTETS as SEC_ELF_OCTETS if OBJ_ELF.
	* dwarf2dbg.c: (dwarf2_finish): Set section flag SEC_OCTETS for
	.debug_line, .debug_info, .debug_abbrev, .debug_aranges, .debug_str
	and .debug_ranges sections.
	* write.c (maybe_generate_build_notes): Set section flag
	SEC_OCTETS for .gnu.build.attributes section.
	* frags.c (frag_now_fix): Don't divide by OCTETS_PER_BYTE if
	SEC_OCTETS is set.
	* symbols.c (resolve_symbol_value): Likewise.
ld/
	* ldexp.c (fold_name): Provide section parameter to
	bfd_octets_per_byte.
	* ldlang (init_opb): New argument s. Set opb_shift to 0 if
	SEC_ELF_OCTETS for the current section is set.
	(print_input_section): Pass current section to init_opb.
	(print_data_statement,print_reloc_statement,
	print_padding_statement): Likewise.
	(lang_check_section_addresses): Call init_opb for each
	section.
	(lang_size_sections_1,lang_size_sections_1,
	lang_do_assignments_1): Likewise.
	(lang_process): Pass NULL to init_opb.
2019-11-25 14:32:19 +10:30
Alan Modra e19511a60c PR273, SOM size -A
The SOM backend creates BFD sections for "spaces", and "sub-spaces".
"sub-spaces" are what we normally think of as a section, "spaces"
aggregate "sub-spaces".  Thus it does not really make sense to include
"spaces" for size -A since that would double count total size.

It so happens that real sections ought to have at least one of the
ALLOC and HAS_CONTENTS flags set, so this patch excludes "spaces" but
excluding BFD sections with no flags set.

	PR 273
	* size.c (sysv_internal_sizer, sysv_internal_printer): Exclude
	sections with no flag bits set.
	* testsuite/binutils-all/size.exp: Allow $CODE$ as a text section.
2019-11-21 22:33:42 +10:30
Nick Clifton f76d79580e Fix potential buffer overrun in objcopy's note merging code.
* objcopy.c (merge_gnu_build_notes): Allow for the possibility
	that the new notes might actually be larger than the original
	notes.
2019-11-21 10:54:20 +00:00
Alan Modra 5b537ffc55 PR46, cygwin: FAIL: cdtest with -Ur
See the comment in pe.sc to understand why ld -Ur won't work.

	PR 46
binutils/
	* testsuite/lib/binutils-common.exp (is_pecoff_format): Rewrite
	with positive logic and add more target triples.
ld/
	* scripttempl/pe.sc: Comment on ld -Ur fail.  Wrap .gcc_exc comment.
	* scripttempl/pep.sc: Likewise.
	* testsuite/ld-cdtest/cdtest.exp (test2): xfail for pe.
2019-11-21 19:09:18 +10:30
Alan Modra f2032b672a PR24499, ignore --add-gnu-debuglink for archives
objcopy --add-gnu-debuglink=foo.a.dbg foo.a just doesn't make any
sense.  Who puts executables in archives?

	PR 24499
	* objcopy.c (copy_file): Ignore --add-gnu-debuglink for archives.
2019-11-19 21:32:42 +10:30
Alan Modra 6765ee1825 PR24968, make objcopy use output ELF arch if -B not given
This should make objcopy -B redundant for the common case of producing
ELF output where the -O target defaults to the desired arch:mach.

	PR 24968
	* objcopy.c (copy_object): For ELF output and non-ELF input without
	arch, take arch from output file if not given by -B.  Don't
	bfd_get_arch_info when we already have iarch.
2019-11-19 19:26:40 +10:30
Alan Modra dd68a12bc4 PR25191, internal error in _bfd_elf_set_section_contents
This PR copies a fuzzed PE input file to ELF output, in the process
confusing the ELF backend by copying COFF-only section flags to the
output.  SEC_COFF_SHARED has the same value as SEC_ELF_COMPRESS.  One
approach to fixing this problem is of course not to reuse flag bits,
but we've run out.  So this patch only copies section flags that are
in the bfd_applicable_section_flags set when changing the flavour of
the output file.

	PR 25191
	* objcopy.c (is_nondebug_keep_contents_section): Use bfd_get_flavour.
	(copy_object): Likewise.
	(setup_section): Likewise.  If flavour of input and output files
	differ, restrict section flags to the intersection of input and
	output bfd_applicable_section_flags.
2019-11-19 15:31:48 +10:30
Alan Modra df56ecde8a Add space between program name and file for objcopy/strip/objdump messages
The GNU coding standard does indicate there should be no space in
messages like these, but we tend to put a space in all other
messages.  This patch cures the inconsistency in:

$ binutils/strip-new -F elf32-little -N .text -o pr25200 pr25200.bin
binutils/strip-new: pr25200: R_X86_64_PLT32 unsupported
binutils/strip-new:pr25200: sorry, cannot handle this file

	* bucomm.c (bfd_nonfatal_message): Add a space between program
	name and file.
2019-11-19 12:31:22 +10:30
Alan Modra 1f67cf9845 PR25198, use of out of date pointer
PR 25198
	* prdbg.c (tg_start_class_type): Correct scope of idbuf.
2019-11-18 09:20:10 +10:30
Alan Modra 831bd6aa3b PR25172, Wrong description of --stop-address=ADDR switch
PR 25172
	* objdump.c (usage): Correct --stop-address description.
2019-11-08 14:46:26 +10:30
Nick Clifton e264b5b7a5 Allow the --output option of the "ar" prorgam to extract files to locations outside of the current directory.
* ar.c (open_output_file): Check for filename validity before
	prefixing with output directory.
	Display the constructed output filename if in verbose mode.
	(extract_file): Let open_output_file display the filename.
2019-11-07 11:56:54 +00:00
Nick Clifton ef07b8082e Fix bug merging notes with objcopy when no merging results in zeroes being written back into the note section.
* objcopy.c (copy_object): Skip note sections that do not have
	an output section.  Always copy note sections, even if no
	changes are made.
2019-11-07 11:36:06 +00:00
Christian Eggers 75802ccb60 Fix an off-by-one error in the IN_RANGE macro used by readelf. Add another use of the macro.
* readelf.c (IN_RANGE): Rename parameter OFF to NELEM. Add
	comment.  Catch potential integer overflow and fix off by one
	error whilst checking reloc location against section size.
	(apply_relocations): Use IN_RANGE macro.
2019-11-06 12:29:23 +00:00
Fāng-ruì Sòng 64f52b3ec1 Implement objcopy/strip --keep-section=<sectionpattern>
llvm-objcopy and llvm-strip support an option --keep-section that
keeps some sections from being removed.

	* objcopy.c (enum option_values): Add OPTION_KEEP_SECTION.
	(SECTION_CONTEXT_KEEP): Define.  Adjust other SECTION_CONTEXT macros.
	(copy_usage): Describe --keep-section.
	(strip_usage): Likewise.
	(copy_main): Handle SECTION_CONTEXT_KEEP.
	(strip_main): Likewise.
	(is_strip_section_1): Likewise.
	* testsuite/binutils-all/objcopy.exp: Add tests.
	* testsuite/binutils-all/keep-section-1.d: New test driver file.
	* testsuite/binutils-all/keep-section-2.d: Likewise.
	* doc/binutils.texi: Document the new feature.
	* NEWS: Mention the new feature.
2019-11-04 11:55:28 +10:30
Nick Clifton a712c56a9a Update email address for Palmer Dabbelt.
* MAINTAINERS: Change palmer@sifive.com to palmer@dabbelt.com.
2019-10-30 10:52:15 +00:00
Fangrui Song 197245e341 Add a --output=<DIR> option to ar to allow the specifying of an output directory.
* ar.c (emum long option numbers): Declare.  Use to provide
	numerical values for long options.
	(long_options): Add --output option.
	(usage): Mention the --output option.
	(open_output_file): New function.  Create a filepath for an output
	file and open it.
	(extract_file): Use open_output_file().
	(open_output_file):
	* testsuite/binutils-all/ar.exp: Add a test of the new feature.
	* doc/binutils.texi: Document the new feature.
	* NEWS: Mention the new feature.
2019-10-30 10:50:23 +00:00
Alan Modra 1cc3da765d sort_gnu_build_notes fix
* objcopy.c (sort_gnu_build_notes): Correct sort of deleted
	note2.
2019-10-26 13:11:02 +10:30
H.J. Lu 760ddef46d elfedit: Report unknown x86 feature
Report unknown x86 feature:

$ ./elfedit --disable-x86-feature foo a.out
elfedit: Error: Unknown x86 feature: foo
$

	* elfedit.c (elf_x86_feature): Report unknown x86 feature.
2019-10-25 15:13:21 -07:00
H.J. Lu 256878f318 elfedit.c: Replace BYTE_PUT with byte_put
Since BYTE_PUT is defined as

 #define BYTE_PUT(field, val) byte_put (field, val, sizeof (field))

use byte_put, instead of BYTE_PUT, to put 4-byte bitmask at ptr with
"byte_put (ptr, bitmask, 4)", instead of "BYTE_PUT (ptr, bitmask)", to
work with "unsigned char *ptr".

	* elfedit.c (update_gnu_property): Replace BYTE_PUT with byte_put.
2019-10-25 15:06:39 -07:00
Nick Clifton 5c49f2cd78 Improve objcopy's note mergeing capabilities.
* objcopy.c (struct merged_note_section): New structure.  Used to
	chain together details of mergeable note sections.
	(is_merged_note_section): Rename to is_megreable_note_section and
	return true for note sections that use GNU_BUILD_ATTRS_SECTION_NAME
	as a prefix.
	(num_bytes): Delete
	(objcoopy_internal_note): Add padded_namesz field.
	(DEBUG_MERGE): New macro.  Set to non-zero to enable debugging of
	the note merging code.
	(gap_exists): Rename to overlaps_or_adjoins and return TRUE for
	overlapping notes or adjoining notes.
	(contained_by, is_deleted_note, is_version_note)
	(compare_gnu_build_notes, sort_gnu_build_notes): New functions.
	(merge_gnu_build_notes):  Rework.  Sort notes into a mergeable
	order first.  Merge them.  Then sort them into an ascending
	address order before writing them out.
	(copy_object): Handle more than one mergeable note section.
	* testsuite/binutils-all/note-2-32.d: Update for new merging
	behaviour.
	* testsuite/binutils-all/note-2-32.s: Likewise.
	* testsuite/binutils-all/note-2-64.d: Likewise.
	* testsuite/binutils-all/note-2-64.s: Likewise.
	* testsuite/binutils-all/note-3-32.d: Likewise.
	* testsuite/binutils-all/note-3-32.s: Likewise.
	* testsuite/binutils-all/note-3-64.d: Likewise.
	* testsuite/binutils-all/note-3-64.s: Likewise.
	* testsuite/binutils-all/note-4-32.d: Likewise.
	* testsuite/binutils-all/note-4-32.s: Likewise.
	* testsuite/binutils-all/note-4-64.d: Likewise.
	* testsuite/binutils-all/note-4-64.s: Likewise.
	* testsuite/binutils-all/note-6-32.s: New test source file.
	* testsuite/binutils-all/note-6-64.s: New test source file.
	* testsuite/binutils-all/note-6-32.d: New test driver file.
	* testsuite/binutils-all/note-6-64.d: New test driver file.
	* testsuite/binutils-all/objcopy.exp: Run the new test.
2019-10-25 16:46:07 +01:00
Alan Modra c0c121b01c readelf PT_PHDR check
When PT_PHDR isn't covered by a PT_LOAD header, p_vaddr in PT_PHDR
isn't valid but the value might just pass a vaddr test.  So test
p_offset as well.

	* readelf.c (process_program_headers): Check PT_PHDR p_offset
	as well as p_vaddr.  Use p_filesz, not p_memsz, in vaddr test.
2019-10-25 13:29:44 +10:30
Alan Modra 95cc7c169c ar P support
This patch extends "ar P" to allow creation of normal (as distinct
from thin) archives with full path names.

	PR 452
	PR 25104
bfd/
	* archive.c (normalize): Return file unchanged when
	BFD_ARCHIVE_FULL_PATH.
	(_bfd_construct_extended_name_table): Pass abfd, the output
	bfd, to normalize.
	(_bfd_archive_bsd44_construct_extended_name_table): Likewise.
	* bfd.c (struct bfd): Make flags a full flagword.
	(BFD_ARCHIVE_FULL_PATH): Define.
	* bfd-in2.h: Regenerate.
binutils/
	* ar.c (write_archive): Set BFD_ARCHIVE_FULL_PATH.
	* doc/binutils.texi (extract from archive): Mention
	restrictions when extracting from archives with full paths.
	(ar P): Update to current P support.
	(ar -X32_64): Fix spelling.
2019-10-21 16:13:39 +10:30
Alan Modra 6ce9ba7afc qsort: objcopy.c section sort
* objcopy.c (compare_section_lma): Correct comment.  Dereference
	section pointer earlier and lose unnecessary const.  Style fixes.
	Add final sort by id.
2019-10-14 16:47:13 +10:30
Nick Clifton 4786fbf372 Update the README-how-to-make-a-release file with a note to reset the development flag back to true after making a point release. Aldo fix a typo in the ld/NEWS file.
binutils* README-how-to-make-a-release: Add a note to reset the
	development flag back to true after making a point release.

ld	* NEWS: Delete superflous "Changes in 2.33" comment.
2019-10-13 13:33:27 +01:00
Nick Clifton 03d0d46a0e Tweak the 'how to make a release' document 2019-10-12 16:05:35 +01:00
Nick Clifton b0531efe2e Updated traditional Chinese translation for the binutils/ subdirectory 2019-10-11 11:58:22 +01:00
Alan Modra b7d9d3ee59 PR25079, "ar s" stopped working
's' is both a command and a modifier.  If given as a command then we
aren't lacking an operation.  I think the same goes when mri mode is
selected: any following command line used to be ignored.

	PR 25079
	* ar.c (decode_options): Don't try for command options if
	write_armap or mri_mode is selected.
2019-10-09 00:20:28 +10:30
Jozef Lawrynowicz c0ea7c52e1 Add support for new functionality in the msp430 backend of GCC.
This functionality will generate a new GNU object attribute for the "data region"
has been added. This object attribute is used
mark whether the compiler has generated code assuming that data could be in the
upper or lower memory regions.

Code which assumes data is always in the lower memory region is incompatible
with code which uses the full memory range for data.

The patch also adds a new assembler directive ".mspabi_attribute" to handle the
existing MSPABI object attributes. GCC will now emit both .gnu_attribute and
.mspabi_attribute directives to indicate what options the source file was
compiled with.

The assembler will now check the values set in these directives against the
options that the it has been invoked with. If there is a discrepancy, the
assembler will exit with an error.

bfd	* elf32-msp430.c (elf32_msp430_merge_mspabi_attributes): Rename to..
	(elf32_msp430_merge_msp430_attributes): Add support for merging the GNU
	object attribute for data region.

binutils* readelf.c (display_msp430_gnu_attribute): New.
	(process_arch_specific): Use msp430 specific handler for GNU
	attributes.

gas	* config/tc-msp430.c (md_parse_option): Set lower_data_region_only to
	FALSE if the data region is set to "upper", "either" or "none".
	(msp430_object_attribute): New.
	(md_pseudo_table): Handle .mspabi_attribute and .gnu_attribute.
	(msp430_md_end): Replace hard-coded attribute values with enums.
	Handle data region object attribute.
	* doc/as.texi: Document MSP430 Data Region object attribute.
	* doc/c-msp430.texi: Document the .mspabi_attribute directive.
	* testsuite/gas/msp430/attr-430-small-bad.d: New test.
	* testsuite/gas/msp430/attr-430-small-bad.l: New test.
	* testsuite/gas/msp430/attr-430-small-good.d: New test.
	* testsuite/gas/msp430/attr-430-small.s: New test.
	* testsuite/gas/msp430/attr-430x-large-any-bad.d: New test.
	* testsuite/gas/msp430/attr-430x-large-any-bad.l: New test.
	* testsuite/gas/msp430/attr-430x-large-any-good.d: New test.
	* testsuite/gas/msp430/attr-430x-large-any.s: New test.
	* testsuite/gas/msp430/attr-430x-large-lower-bad.d: New test.
	* testsuite/gas/msp430/attr-430x-large-lower-bad.l: New test.
	* testsuite/gas/msp430/attr-430x-large-lower-good.d: New test.
	* testsuite/gas/msp430/attr-430x-large-lower.s: New test.
	* testsuite/gas/msp430/msp430.exp: Run new tests.

include	* elf/msp430.h: Add enums for MSPABI and GNU object attribute tag names
	and values.

ld	* testsuite/ld-msp430-elf/attr-gnu-main.s: New test.
	* testsuite/ld-msp430-elf/attr-gnu-obj.s: New test.
	* testsuite/ld-msp430-elf/attr-gnu-region-lower-upper.d: New test.
	* testsuite/ld-msp430-elf/attr-gnu-region-lower.d: New test.
	* testsuite/ld-msp430-elf/attr-gnu-region-upper.d: New test.
	* testsuite/ld-msp430-elf/msp430-elf.exp: Run new tests.
2019-10-07 16:34:31 +01:00
Nick Alcock d344b407dd binutils: spaces -> tabs in CTF parts of objdump and readelf
For readelf particularly, this is more or less whistling in the dark:
there are hundreds of lines where spaces are used where tabs were used
on adjacent lines.

New in v5.

binutils/
	* objdump.c (main): Fix tabdamage.
	* readelf.c (CTF_DUMP): Likewise.
	(options): Likewise.
	(dump_section_as_ctf): Likewise.
2019-10-03 17:04:56 +01:00
Nick Alcock fd86991bc5 objdump: get CTF parent importing right
The linker emits CTF into a single section named .ctf, which is a CTF
archive where the default member (itself named ".ctf", or simply NULL)
is the parent of all other members.  Teach objdump to look for this by
default, rather than only trying to do it if a specific CTF parent
section was specified.  (If no parent name is specified, we get the .ctf
member from the same section as everything else, which matches what the
linker generates.)

binutils/
	* objdump.c (dump_ctf): Use the default CTF archive member as the
	parent even when no parent section is specified.
	(dump_ctf_archive_member): Only import from the parent
	if this is not the default ".ctf" member.
2019-10-03 17:04:56 +01:00
Nick Alcock 87279e3cef libctf: installable libctf as a shared library
This lets other programs read and write CTF-format data.

Two versioned shared libraries are created: libctf.so and
libctf-nobfd.so.  They contain identical content except that
libctf-nobfd.so contains no references to libbfd and does not implement
ctf_open, ctf_fdopen, ctf_bfdopen or ctf_bfdopen_ctfsect, so it can be
used by programs that cannot use BFD, like readelf.

The soname major version is presently .0 until the linker API
stabilizes, when it will flip to .1 and hopefully never change again.

New in v3.
v4: libtoolize and turn into a pair of shared libraries.  Drop
    --enable-install-ctf: now controlled by --enable-shared and
    --enable-install-libbfd, like everything else.
v5: Add ../bfd to ACLOCAL_AMFLAGS and AC_CONFIG_MACRO_DIR.  Fix tabdamage.

	* Makefile.def (host_modules): libctf is no longer no_install.
	* Makefile.in: Regenerated.
libctf/
	* configure.ac (AC_DISABLE_SHARED): New, like opcodes/.
	(LT_INIT): Likewise.
	(AM_INSTALL_LIBBFD): Likewise.
	(dlopen): Note why this is necessary in a comment.
	(SHARED_LIBADD): Initialize for possibly-PIC libiberty: derived from
	opcodes/.
	(SHARED_LDFLAGS): Likewise.
	(BFD_LIBADD): Likewise, for libbfd.
	(BFD_DEPENDENCIES): Likewise.
	(VERSION_FLAGS): Initialize, using a version script if ld supports
	one, or libtool -export-symbols-regex otherwise.
	(AC_CONFIG_MACRO_DIR): Add ../BFD.
	* Makefile.am (ACLOCAL_AMFLAGS): Likewise.
	(INCDIR): New.
	(AM_CPPFLAGS): Use $(srcdir), not $(top_srcdir).
	(noinst_LIBRARIES): Replace with...
	[INSTALL_LIBBFD] (lib_LTLIBRARIES): This, or...
	[!INSTALL_LIBBFD] (noinst_LTLIBRARIES): ... this, mentioning new
	libctf-nobfd.la as well.
	[INSTALL_LIBCTF] (include_HEADERS): Add the CTF headers.
	[!INSTALL_LIBCTF] (include_HEADERS): New, empty.
	(libctf_a_SOURCES): Rename to...
	(libctf_nobfd_la_SOURCES): ... this, all of libctf other than
	ctf-open-bfd.c.
	(libctf_la_SOURCES): Now derived from libctf_nobfd_la_SOURCES,
	with ctf-open-bfd.c added.
	(libctf_nobfd_la_LIBADD): New, using @SHARED_LIBADD@.
	(libctf_la_LIBADD): New, using @BFD_LIBADD@ as well.
	(libctf_la_DEPENDENCIES): New, using @BFD_DEPENDENCIES@.
	* Makefile.am [INSTALL_LIBCTF]: Use it.
	* aclocal.m4: Add ../bfd/acinclude.m4, ../config/acx.m4, and the
	libtool macros.
	* libctf.ver: New, everything is version LIBCTF_1.0 currently (even
	the unstable components).
	* Makefile.in: Regenerated.
	* config.h.in: Likewise.
	* configure: Likewise.
binutils/
	* Makefile.am (LIBCTF): Mention the .la file.
	(LIBCTF_NOBFD): New.
	(readelf_DEPENDENCIES): Use it.
	(readelf_LDADD): Likewise.
	* Makefile.in: Regenerated.
ld/
	* configure.ac (TESTCTFLIB): Set to the .so or .a, like TESTBFDLIB.
	* Makefile.am (TESTCTFLIB): Use it.
	(LIBCTF): Use the .la file.
	(check-DEJAGNU): Use it.
	* Makefile.in: Regenerated.
	* configure: Likewise.
include/
	* ctf-api.h: Note the instability of the ctf_link interfaces.
2019-10-03 17:04:56 +01:00
Nick Alcock 6b88d7d70c binutils: objdump does not take --ctf-symbols or --ctf-strings options
libctf figures out what to load itself, with no overriding currently
possible, so remove the documentation of these nonexistent options.
2019-10-03 17:04:55 +01:00
Nick Alcock 616febde0c binutils: readelf: when dumping CTF, load strtab and symtab automatically
We were only loading them when explicitly requested, which leads to
strings that point off into empty space (into the non-loaded "external"
ELF string table).  Avoid this unfortunate consequence by loading the
strtab and symtab by default, unless a blank name is given.

binutils/
	* readelf.c (dump_ctf_symtab_name): Give default value.
	(dump_ctf_strtab_name): Likewise.
	(dump_section_as_ctf): Allow for the null string.
2019-10-03 17:04:55 +01:00
Nick Alcock 9b32cba44d libctf, binutils: dump the CTF header
The CTF header has before now been thrown away too soon to be dumped
using the ctf_dump() machinery used by objdump and readelf: instead, a
kludge involving debugging-priority dumps of the header offsets on every
open was used.

Replace this with proper first-class dumping machinery just like
everything else in the CTF file, and have objdump and readelf use it.
(The dumper already had an enum value in ctf_sect_names_t for this
purpose, waiting to be used.)

v5: fix tabdamage.

libctf/
	* ctf-impl.h (ctf_file_t): New field ctf_openflags.
	* ctf-open.c (ctf_bufopen): Set it.  No longer dump header offsets.
	* ctf-dump.c (dump_header): New function, dump the CTF header.
	(ctf_dump): Call it.
	(ctf_dump_header_strfield): New function.
	(ctf_dump_header_sectfield): Likewise.

binutils/
	* objdump.c (dump_ctf_archive_member): Dump the CTF header.
	* readelf.c (dump_section_as_ctf): Likewise.
2019-10-03 17:04:55 +01:00
Nick Clifton de4859eacb Change objcopy's --set-section-alignment option to take a byte alignment value rather than a power of two alignment value.
PR 24942
	* objcopy.c (copy_usage): Update description of
	--set-section-alignment.
	(copy_main): Interpret numeric argument of --set-section-alignment
	as a byte alignment, not a power of two alignment.
	* doc/binutils.texi: Update description of
	--set-section-alignment.
	* testsuite/binutils-all/set-section-alignment.d: New test.
	* testsuite/binutils-all/objcopy.exp: Run the new test.
2019-10-02 11:55:02 +01:00
Alan Modra 663f67df1e PR25046, readelf "Reading xxx bytes extends past end of file for dynamic section"
PR 25046
	* readelf.c (process_program_headers): Clear dynamic_addr and
	dynamic_size earlier.
2019-09-30 14:18:14 +09:30
Alan Modra 352f6bc3e5 PR25031, nm reports wrong address on 32bit
Using saved_format breaks when nm is presented with multiple object
files, some 32-bit and some 64-bit.

	PR 25031
	* nm.c (print_format_string): New.
	(get_print_format): Delete saved_format.  Move earlier.
	(set_print_width): Call get_print_format.
	(print_value): Use print_format_string.
2019-09-24 22:53:51 +09:30
Alan Modra aa739c59d3 coff bfd.h tidy
bfd/
	* bfd-in.h: Delete coff forward refs and move coff declaration..
	* coff-bfd.h: ..to here.
	* bfd-in2.h: Regenerate.
binutils/
	* dlltool.c: Include coff-bfd.h.
2019-09-23 10:27:21 +09:30
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 00f93c4492 bfd macro conversion to inline functions
This converts some of the macros that access struct bfd fields to
inline functions.

bfd/
	* archive.c (bfd_generic_archive_p): Use bfd_set_thin_archive.
	* bfd-in.h (bfd_get_filename, bfd_get_cacheable, bfd_get_format),
	(bfd_get_target, bfd_get_flavour, bfd_family_coff, bfd_big_endian),
	(bfd_little_endian, bfd_header_big_endian, bfd_header_little_endian),
	(bfd_get_file_flags, bfd_applicable_file_flags),
	(bfd_applicable_section_flags, bfd_has_map, bfd_is_thin_archive),
	(bfd_valid_reloc_types, bfd_usrdata, bfd_get_start_address),
	(bfd_get_symcount, bfd_get_outsymbols, bfd_count_sections),
	(bfd_get_dynamic_symcount, bfd_get_symbol_leading_char): Delete.
	* bfd/bfd.c (bfd_get_filename, bfd_get_cacheable, bfd_get_format),
	(bfd_get_file_flags, bfd_get_start_address, bfd_get_symcount),
	(bfd_get_dynamic_symcount, bfd_get_outsymbols, bfd_count_sections),
	(bfd_has_map, bfd_is_thin_archive, bfd_set_thin_archive),
	(bfd_usrdata, bfd_set_usrdata): New inline functions.
	* targets.c (bfd_get_target, bfd_get_flavour),
	(bfd_applicable_file_flags, bfd_family_coff, bfd_big_endian),
	(bfd_little_endian, bfd_header_big_endian),
	(bfd_header_little_endian, bfd_applicable_section_flags),
	(bfd_get_symbol_leading_char): New inline functions.
	* bfd-in2.h: Regenerate.
binutils/
	* ar.c (write_archive): Use bfd_set_thin_archive.
gdb/
	* gdb_bfd.c (gdb_bfd_ref, gdb_bfd_unref): Use bfd_set_usrdata.
	* dwarf2read.c (dwarf2_read_gdb_index, dwarf2_read_debug_names),
	(read_indirect_string_from_dwz): Use bfd accessor.
	* dwarf2read.h (struct dwz_file <filename>): Likewise.
	* machoread.c (macho_symfile_read_all_oso): Likewise.
	* solib.c (solib_bfd_open): Likewise.
ld/
	* ldelf.c (ldelf_after_open, ldelf_place_orphan
	* ldlang.c (walk_wild_file, lang_process): Use bfd_usrdata.
	(load_symbols, ldlang_add_file): Use bfd_set_usrdata.
	* ldmain.c (add_archive_element): Use bfd_usrdata.
	* ldlang.h (bfd_input_just_syms): New inline function.
	* emultempl/aarch64elf.em (build_section_lists): Use it.
	* emultempl/mmo.em (mmo_place_orphan): Likewise.
	* emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
	* emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise.
	* emultempl/ppc64elf.em (build_section_lists): Likewise.
sim/
	* ppc/emul_generic.c (emul_add_tree_options): Delete old bfd code.
2019-09-20 18:04:02 +09:30
Tamar Christina 4e28d4cc5b AArch64: Fix objdump tests
The newly added objdump -S tests check for source line mapping of a static
variable.  But the test doesn't dump any data sections so this should never
pass.

This changes the test to dump all sections so the source mapping can be found.

binutils/ChangeLog:

	* testsuite/binutils-all/objdump.exp (objdump -S): Update testcases.
2019-09-19 13:15:52 +01:00
Alan Modra fd3619828e bfd_section_* macros
This large patch removes the unnecessary bfd parameter from various
bfd section macros and functions.  The bfd is hardly ever used and if
needed for the bfd_set_section_* or bfd_rename_section functions can
be found via section->owner except for the com, und, abs, and ind
std_section special sections.  Those sections shouldn't be modified
anyway.

The patch also removes various bfd_get_section_<field> macros,
replacing their use with bfd_section_<field>, and adds
bfd_set_section_lma.  I've also fixed a minor bug in gas where
compressed section renaming was done directly rather than calling
bfd_rename_section.  This would have broken bfd_get_section_by_name
and similar functions, but that hardly mattered at such a late stage
in gas processing.

bfd/
	* bfd-in.h (bfd_get_section_name, bfd_get_section_vma),
	(bfd_get_section_lma, bfd_get_section_alignment),
	(bfd_get_section_size, bfd_get_section_flags),
	(bfd_get_section_userdata): Delete.
	(bfd_section_name, bfd_section_size, bfd_section_vma),
	(bfd_section_lma, bfd_section_alignment): Lose bfd parameter.
	(bfd_section_flags, bfd_section_userdata): New.
	(bfd_is_com_section): Rename parameter.
	* section.c (bfd_set_section_userdata, bfd_set_section_vma),
	(bfd_set_section_alignment, bfd_set_section_flags, bfd_rename_section),
	(bfd_set_section_size): Delete bfd parameter, rename section parameter.
	(bfd_set_section_lma): New.
	* bfd-in2.h: Regenerate.
	* mach-o.c (bfd_mach_o_init_section_from_mach_o): Delete bfd param,
	update callers.
	* aoutx.h, * bfd.c, * coff-alpha.c, * coff-arm.c, * coff-mips.c,
	* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
	* compress.c, * ecoff.c, * elf-eh-frame.c, * elf-hppa.h,
	* elf-ifunc.c, * elf-m10200.c, * elf-m10300.c, * elf-properties.c,
	* elf-s390-common.c, * elf-vxworks.c, * elf.c, * elf32-arc.c,
	* elf32-arm.c, * elf32-avr.c, * elf32-bfin.c, * elf32-cr16.c,
	* elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c, * elf32-csky.c,
	* elf32-d10v.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c,
	* elf32-ft32.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c,
	* elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c,
	* elf32-m32r.c, * elf32-m68hc1x.c, * elf32-m68k.c, * elf32-mcore.c,
	* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c,
	* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
	* elf32-nios2.c, * elf32-or1k.c, * elf32-ppc.c, * elf32-pru.c,
	* elf32-rl78.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c,
	* elf32-score7.c, * elf32-sh.c, * elf32-spu.c, * elf32-tic6x.c,
	* elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, * elf32-visium.c,
	* elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
	* elf64-bpf.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mmix.c,
	* elf64-ppc.c, * elf64-s390.c, * elf64-sparc.c, * elf64-x86-64.c,
	* elflink.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c,
	* elfxx-aarch64.c, * elfxx-mips.c, * elfxx-sparc.c,
	* elfxx-tilegx.c, * elfxx-x86.c, * i386msdos.c, * linker.c,
	* mach-o.c, * mmo.c, * opncls.c, * pdp11.c, * pei-x86_64.c,
	* peicode.h, * reloc.c, * section.c, * syms.c, * vms-alpha.c,
	* xcofflink.c: Update throughout for bfd section macro and function
	changes.
binutils/
	* addr2line.c, * bucomm.c, * coffgrok.c, * dlltool.c, * nm.c,
	* objcopy.c, * objdump.c, * od-elf32_avr.c, * od-macho.c,
	* od-xcoff.c, * prdbg.c, * rdcoff.c, * rddbg.c, * rescoff.c,
	* resres.c, * size.c, * srconv.c, * strings.c, * windmc.c: Update
	throughout for bfd section macro and function changes.
gas/
	* as.c, * as.h, * dw2gencfi.c, * dwarf2dbg.c, * ecoff.c,
	* read.c, * stabs.c, * subsegs.c, * subsegs.h, * write.c,
	* config/obj-coff-seh.c, * config/obj-coff.c, * config/obj-ecoff.c,
	* config/obj-elf.c, * config/obj-macho.c, * config/obj-som.c,
	* config/tc-aarch64.c, * config/tc-alpha.c, * config/tc-arc.c,
	* config/tc-arm.c, * config/tc-avr.c, * config/tc-bfin.c,
	* config/tc-bpf.c, * config/tc-d10v.c, * config/tc-d30v.c,
	* config/tc-epiphany.c, * config/tc-fr30.c, * config/tc-frv.c,
	* config/tc-h8300.c, * config/tc-hppa.c, * config/tc-i386.c,
	* config/tc-ia64.c, * config/tc-ip2k.c, * config/tc-iq2000.c,
	* config/tc-lm32.c, * config/tc-m32c.c, * config/tc-m32r.c,
	* config/tc-m68hc11.c, * config/tc-mep.c, * config/tc-microblaze.c,
	* config/tc-mips.c, * config/tc-mmix.c, * config/tc-mn10200.c,
	* config/tc-mn10300.c, * config/tc-msp430.c, * config/tc-mt.c,
	* config/tc-nds32.c, * config/tc-or1k.c, * config/tc-ppc.c,
	* config/tc-pru.c, * config/tc-rl78.c, * config/tc-rx.c,
	* config/tc-s12z.c, * config/tc-s390.c, * config/tc-score.c,
	* config/tc-score7.c, * config/tc-sh.c, * config/tc-sparc.c,
	* config/tc-spu.c, * config/tc-tic4x.c, * config/tc-tic54x.c,
	* config/tc-tic6x.c, * config/tc-tilegx.c, * config/tc-tilepro.c,
	* config/tc-v850.c, * config/tc-visium.c, * config/tc-wasm32.c,
	* config/tc-xc16x.c, * config/tc-xgate.c, * config/tc-xstormy16.c,
	* config/tc-xtensa.c, * config/tc-z8k.c: Update throughout for
	bfd section macro and function changes.
	* write.c (compress_debug): Use bfd_rename_section.
gdb/
	* aarch64-linux-tdep.c, * arm-tdep.c, * auto-load.c,
	* coff-pe-read.c, * coffread.c, * corelow.c, * dbxread.c,
	* dicos-tdep.c, * dwarf2-frame.c, * dwarf2read.c, * elfread.c,
	* exec.c, * fbsd-tdep.c, * gcore.c, * gdb_bfd.c, * gdb_bfd.h,
	* hppa-tdep.c, * i386-cygwin-tdep.c, * i386-fbsd-tdep.c,
	* i386-linux-tdep.c, * jit.c, * linux-tdep.c, * machoread.c,
	* maint.c, * mdebugread.c, * minidebug.c, * mips-linux-tdep.c,
	* mips-sde-tdep.c, * mips-tdep.c, * mipsread.c, * nto-tdep.c,
	* objfiles.c, * objfiles.h, * osabi.c, * ppc-linux-tdep.c,
	* ppc64-tdep.c, * record-btrace.c, * record-full.c, * remote.c,
	* rs6000-aix-tdep.c, * rs6000-tdep.c, * s390-linux-tdep.c,
	* s390-tdep.c, * solib-aix.c, * solib-dsbt.c, * solib-frv.c,
	* solib-spu.c, * solib-svr4.c, * solib-target.c,
	* spu-linux-nat.c, * spu-tdep.c, * symfile-mem.c, * symfile.c,
	* symmisc.c, * symtab.c, * target.c, * windows-nat.c,
	* xcoffread.c, * cli/cli-dump.c, * compile/compile-object-load.c,
	* mi/mi-interp.c: Update throughout for bfd section macro and
	function changes.
	* gcore (gcore_create_callback): Use bfd_set_section_lma.
	* spu-tdep.c (spu_overlay_new_objfile): Likewise.
gprof/
	* corefile.c, * symtab.c: Update throughout for bfd section
	macro and function changes.
ld/
	* ldcref.c, * ldctor.c, * ldelf.c, * ldlang.c, * pe-dll.c,
	* emultempl/aarch64elf.em, * emultempl/aix.em,
	* emultempl/armcoff.em, * emultempl/armelf.em,
	* emultempl/cr16elf.em, * emultempl/cskyelf.em,
	* emultempl/m68hc1xelf.em, * emultempl/m68kelf.em,
	* emultempl/mipself.em, * emultempl/mmix-elfnmmo.em,
	* emultempl/mmo.em, * emultempl/msp430.em,
	* emultempl/nios2elf.em, * emultempl/pe.em, * emultempl/pep.em,
	* emultempl/ppc64elf.em, * emultempl/xtensaelf.em: Update
	throughout for bfd section macro and function changes.
libctf/
	* ctf-open-bfd.c: Update throughout for bfd section macro changes.
opcodes/
	* arc-ext.c: Update throughout for bfd section macro changes.
sim/
	* common/sim-load.c, * common/sim-utils.c, * cris/sim-if.c,
	* erc32/func.c, * lm32/sim-if.c, * m32c/load.c, * m32c/trace.c,
	* m68hc11/interp.c, * ppc/hw_htab.c, * ppc/hw_init.c,
	* rl78/load.c, * rl78/trace.c, * rx/gdb-if.c, * rx/load.c,
	* rx/trace.c: Update throughout for bfd section macro changes.
2019-09-19 09:40:13 +09:30
Alan Modra e6f7f6d14f bfd_asymbol_* macros
The main point of this patch is to give bfd_get_section a better name,
bfd_asymbol_section.

bfd/
	* bfd-in.h (bfd_asymbol_section): Rename from bfd_get_section.
	(bfd_get_output_section): Delete.
	(bfd_asymbol_base): Delete.
	(bfd_asymbol_section, bfd_asymbol_value, bfd_asymbol_name),
	(bfd_asymbol_bfd, bfd_asymbol_flavour): Tidy.
	(bfd_set_asymbol_name): New macro.
	* bfd-in2.h: Regenerate.
	* aout-cris.c: Update throughout to use bfd_asymbol_section.
	* aoutx.h: Likewise.
	* cofflink.c: Likewise.
	* dwarf2.c: Likewise.
	* ecoff.c: Likewise.
	* elf.c: Likewise.
	* elf32-arm.c: Likewise.
	* elf32-mips.c: Likewise.
	* elf32-score.c: Likewise.
	* elf32-score7.c: Likewise.
	* elfn32-mips.c: Likewise.
	* elfnn-aarch64.c: Likewise.
	* elfxx-mips.c: Likewise.
	* linker.c: Likewise.
	* pdp11.c: Likewise.
	* elf64-mmix.c (mmix_elf_reloc): Expand bfd_get_output_section.
binutils/
	* nm.c: Update bfd_get_section to bfd_asymbol_section throughout.
	* objcopy.c: Likewise.
	* objdump.c: Likewise.
	* rdcoff.c: Likewise.
	* objcopy.c (create_new_symbol): Use bfd_set_asymbol_name.
	(filter_symbols): Likewise.
gas/
	* symbols.c (S_IS_LOCAL): Update bfd_get_section to
	bfd_asymbol_section.
gdb/
	* arm-tdep.c (arm_record_special_symbol): Update bfd_get_section
	to bfd_asymbol_section.
ld/
	* ldcref.c (check_reloc_refs): Update bfd_get_section to
	bfd_asymbol_section.
2019-09-18 23:07:31 +09:30
Simon Marchi 2b44a6a237 binutils: doc: make `make clean` clean more things
There is a bunch of things left over after a `make clean` in the doc
directory.  This patch changes the Makefile so that everything built by
make is cleaned:

- man pages (the man_MANS variable)
- cxxfilt.man
- binutils.info

I am not sure why the last one was in MAINTAINERCLEANFILES.  It's
generated from binutils.texi using makeinfo, and it's not particularly
long to build, so I don't see why it shouldn't be cleaned like the other
files.

Note: with my automake 1,15.1 (built from source), I get a spurious diff
in Makefile.in, where the

  runstatedir = @runstatedir@

line gets removed.  I am not sure why, but I haven't included it.

binutils/ChangeLog:

	* doc/Makefile.am (MOSTLYCLEANFILES): Clean all man pages,
	cxxfilt.man and binutils.info.
	(MAINTAINERCLEANFILES): Remove.
	* doc/Makefile.in: Re-generate.
2019-09-18 09:14:59 -04:00
Simon Marchi 89ae5e6923 binutils: doc: remove binutils_TEXINFOS usages
This variable doesn't exist (it evaluates to nothing).

It was introduced in

    commit 42ecbf5eda
    Author: Daniel Jacobowitz <drow@false.org>
    Date:   Sun May 15 18:19:45 2005 +0000

And removed in

    commit c428fa83c2
    Author: H.J. Lu <hjl.tools@gmail.com>
    Date:   Thu Mar 15 14:17:20 2007 +0000

Note: with my automake 1,15.1 (built from source), I get a spurious diff
in Makefile.in, where the

  runstatedir = @runstatedir@

line gets removed.  I am not sure why, but I haven't included it.

binutils/ChangeLog:

	* doc/Makefile.am: Remove references to binutils_TEXINFOS.
	* doc/Makefile.in: Re-generate.
2019-09-18 09:11:14 -04:00
Simon Marchi 95103a8419 binutils: doc: remove stale things from Makefile
The `install-data-local: install-info` part: the comment refers to when
the Makefile had the cygnus option.  It no longer uses that, so the info
file should get installed without that rule.  I verified that `make
install` still installed $(prefix)/share/info/binutils.info.

The `DISTCLEANFILES` part: the comment talks about Automake 1.9, we are
using 1.15.1, which doesn't appear to have this problem.  binutils.info
is built fine without this snippet.

Note: with my automake 1,15.1 (built from source), I get a spurious diff
in Makefile.in, where the

  runstatedir = @runstatedir@

line gets removed.  I am not sure why, but I haven't included it.

binutils/ChangeLog:

	* doc/Makefile.am (install-data-loca): Remove target.
	(DISTCLEANFILES): Remove variable.
	* doc/Makefile.in: Re-generate.
2019-09-18 09:10:59 -04:00
Simon Marchi e0b2a78c83 Re-generate many configure and Makefile.in files
I get some spurious changes when running autoconf/automake for various
projects in the tree.  This is likely because they were generated using
distro-patched tools last time.

I ran `autoreconf -f` in the various automake projects of the
binutils-gdb tree, and this is the result.  The tools I am using have
been compiled from source, from the upstream release.

bfd/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.
	* doc/Makefile.in: Re-generate.

binutils/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.
	* doc/Makefile.in: Re-generate.

gas/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.
	* doc/Makefile.in: Re-generate.

gold/ChangeLog:

	* testsuite/Makefile.in: Re-generate.

gprof/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.

ld/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.

opcodes/ChangeLog:

	* Makefile.in: Re-generate.
	* configure: Re-generate.
2019-09-18 09:09:15 -04:00
Phil Blundell 92ea198025 Delete accidentally-checked in editor temporary file. 2019-09-16 11:03:53 +01:00
Phil Blundell bb6959602b Update version to 2.33.50 and regenerate configure scripts. 2019-09-16 11:03:53 +01:00
Tom Tromey 1ff5d5c463 Constify argument to make_tempname and make_tempdir
This constifies the argument to make_tempname and make_tempdir,
removing some casts.

I initially thought that this obsoleted the allocation in
write_archive, but write_archive closes the BFD before using the name,
so this appears not to be the case.

binutils/ChangeLog
2019-09-11  Tom Tromey  <tom@tromey.com>

	* objcopy.c (copy_archive): Update.
	* bucomm.h (make_tempname, make_tempdir): Make argument const.
	* bucomm.c (make_tempname, make_tempdir): Make argument const.
2019-09-11 07:02:46 -06:00
Alan Modra 0a4632b563 Re: Enhance the disassembler
PR 24907
	* objdump.c (disassemble_bytes): Adjust code to avoid overlong
	lines.  Correct max_reloc_offset_into_insn test.
2019-09-11 21:58:39 +09:30
Nick Clifton aebcfb76fc Enhance the disassembler so that it will reliably determine whether a reloc applies to the middle of the next insn.
PR 24907
binutils* objdump.c (null_print): New function.
	(disassemble_bytes): Delete previous_octets local and replace with
	a test of the max_reloc_offset_into_insn field of the
	bfd_arch_info structure.  If a reloc is a potential match for the
	next insn, then perform a dummy disassembly in order to calculate
	its real length.

bfd	* archures.c (bfd_arch_info_type): Add max_reloc_offset_into_insn
	field.
	(bfd_default_arch_struct): Initialise the new field.
	* bfd-in2.h: Regenerate.
	* cpu-aarch64.c: Initialise the new field.
	* cpu-alpha.c: Likewise.
	* cpu-arc.c: Likewise.
	* cpu-arm.c: Likewise.
	* cpu-avr.c: Likewise.
	* cpu-bfin.c: Likewise.
	* cpu-bpf.c: Likewise.
	* cpu-cr16.c: Likewise.
	* cpu-cr16c.c: Likewise.
	* cpu-cris.c: Likewise.
	* cpu-crx.c: Likewise.
	* cpu-csky.c: Likewise.
	* cpu-d10v.c: Likewise.
	* cpu-d30v.c: Likewise.
	* cpu-dlx.c: Likewise.
	* cpu-epiphany.c: Likewise.
	* cpu-fr30.c: Likewise.
	* cpu-frv.c: Likewise.
	* cpu-ft32.c: Likewise.
	* cpu-h8300.c: Likewise.
	* cpu-hppa.c: Likewise.
	* cpu-i386.c: Likewise.
	* cpu-ia64.c: Likewise.
	* cpu-iamcu.c: Likewise.
	* cpu-ip2k.c: Likewise.
	* cpu-iq2000.c: Likewise.
	* cpu-k1om.c: Likewise.
	* cpu-l1om.c: Likewise.
	* cpu-lm32.c: Likewise.
	* cpu-m10200.c: Likewise.
	* cpu-m10300.c: Likewise.
	* cpu-m32c.c: Likewise.
	* cpu-m32r.c: Likewise.
	* cpu-m68hc11.c: Likewise.
	* cpu-m68hc12.c: Likewise.
	* cpu-m68k.c: Likewise.
	* cpu-m9s12x.c: Likewise.
	* cpu-m9s12xg.c: Likewise.
	* cpu-mcore.c: Likewise.
	* cpu-mep.c: Likewise.
	* cpu-metag.c: Likewise.
	* cpu-microblaze.c: Likewise.
	* cpu-mips.c: Likewise.
	* cpu-mmix.c: Likewise.
	* cpu-moxie.c: Likewise.
	* cpu-msp430.c: Likewise.
	* cpu-mt.c: Likewise.
	* cpu-nds32.c: Likewise.
	* cpu-nfp.c: Likewise.
	* cpu-nios2.c: Likewise.
	* cpu-ns32k.c: Likewise.
	* cpu-or1k.c: Likewise.
	* cpu-pdp11.c: Likewise.
	* cpu-pj.c: Likewise.
	* cpu-plugin.c: Likewise.
	* cpu-powerpc.c: Likewise.
	* cpu-pru.c: Likewise.
	* cpu-riscv.c: Likewise.
	* cpu-rl78.c: Likewise.
	* cpu-rs6000.c: Likewise.
	* cpu-rx.c: Likewise.
	* cpu-s12z.c: Likewise.
	* cpu-s390.c: Likewise.
	* cpu-score.c: Likewise.
	* cpu-sh.c: Likewise.
	* cpu-sparc.c: Likewise.
	* cpu-spu.c: Likewise.
	* cpu-tic30.c: Likewise.
	* cpu-tic4x.c: Likewise.
	* cpu-tic54x.c: Likewise.
	* cpu-tic6x.c: Likewise.
	* cpu-tic80.c: Likewise.
	* cpu-tilegx.c: Likewise.
	* cpu-tilepro.c: Likewise.
	* cpu-v850.c: Likewise.
	* cpu-v850_rh850.c: Likewise.
	* cpu-vax.c: Likewise.
	* cpu-visium.c: Likewise.
	* cpu-wasm32.c: Likewise.
	* cpu-xc16x.c: Likewise.
	* cpu-xgate.c: Likewise.
	* cpu-xstormy16.c: Likewise.
	* cpu-xtensa.c: Likewise.
	* cpu-z80.c: Likewise.
	* cpu-z8k.c: Likewise.

gas	* testsuite/gas/arm/pr24907.s: New test.
	* testsuite/gas/arm/pr24907.d: Expected disassembly.
2019-09-10 15:20:58 +01:00
Phil Blundell 60391a255b Add markers for 2.33 branch to NEWS and ChangeLog files. 2019-09-09 10:27:40 +01:00
Alan Modra b16c44debc bfd_get_filename
This macro says:
/* Cast from const char * to char * so that caller can assign to
   a char * without a warning.  */

I reckon that isn't such a good idea since it can result in char*
variables where const char* is appropriate.  Not very many places
need the char* cast.

bfd/
	* aout-target.h (object_p): Formatting.
	* bfd-in.h (bfd_get_filename): Don't cast to char*.
	* corefile.c (generic_core_file_matches_executable_p): Constify
	variables and remove cast.
	* bfd-in2.h: Regenerate.
binutils/
	* nm.c (print_object_filename_bsd, print_object_filename_sysv),
	(print_object_filename_posix, print_archive_filename_bsd),
	(print_archive_filename_sysv, print_archive_filename_posix),
	(print_archive_member_bsd, print_archive_member_sysv),
	(print_archive_member_posix): Constify parameter.
	(struct output_fns <print_object_filename, print_archive_filename>),
	(<print_archive_member>): Likewise.
	* objcopy.c (copy_archive): Add cast for make_tempdir.
ld/
	* emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Constify
	variable.
	* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise.
	* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
gdb/
	* coffread.c (coff_symfile_read): Constify filename variable.
	* dbxread.c (dbx_symfile_init, coffstab_build_psymtabs),
	(elfstab_build_psymtabs, stabsect_build_psymtabs): Likewise.
	* gdb_bfd.c (gdb_bfd_close_or_warn): Likewise.
	* solib.c (reload_shared_libraries_1): Likewise.
	* symfile.c (reread_symbols): Likewise.
	* solib-aix.c (solib_aix_bfd_open): Add cast for xfree of filename.
	* solib-darwin.c (darwin_bfd_open): Likewise.
	* symfile-mem.c (symbol_file_add_from_memory): Likewise.
sim/cris/
	* sim-if.c (sim_open): Constify filename variable.
2019-09-06 12:22:59 +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
Niklas G?rtler fa463e9fc6 Add an option to objcopy to change the alignment of sections.
PR 24942
	* objcopy.c (SECTION_CONTEXT_SET_ALIGNMENT): New constant.
	(struct section_list): Add alignment field.
	(command_line_switch): Add OPTION_SET_SECTION_ALIGNMENT.
	(copy_options): Add --set-section-alignment.
	(copy_usage): Describe --set-section-alignment.
	(find_section_list): Initialise the alignment field.
	(setup_section): Handle the alignment field.
	(copy_main): Handle OPTION_SET_SECTION_ALIGNMENT.
	* doc/binutils.texi: Document the new feature.
	* NEWS: Mention the new feature.
2019-08-28 12:33:41 +01:00
Nick Clifton a1c110a3fe Add a --source-comment=<text> option to objdump which provides a prefix to dipslayed source code lines.
PR 24931
	* objdump.c (source_comment): New static variable.
	(option_values): Add OPTION_SOURCE_COMMENT.
	(long_opions): Add --source-comment.
	(print_line): If source comment is set, use it as a prefix to the
	source code line.
	(main): Handle OPTION_SOURCE_COMMENT.
	* doc/binutils.texi: Document the new option.
	* NEWS: Mention the new feature.
	* testsuite/binutils-all/objdump.exp (test_objdump_S): Add tests
	of the -S and --source-comment options.
2019-08-28 11:39:19 +01:00
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
Alan Modra 37606e67df PR24938, Null Pointer Dereference in debug.c:debug_write_type
PR 24938
	* debug.c (debug_write_type): Call empty_type for NULL type here..
	(debug_write_type): ..rather than in just one case here.
2019-08-26 19:31:10 +09:30
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 93d6a337d5 oops - omitted changelog entry from previous delta. 2019-08-22 13:16:28 +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 0b8b76098f PR24909, Uninitialized use on stack in readelf
PR 24909
	PR 23499
	* readelf.c (get_symbol_version_string): Set sym_info earlier.
2019-08-16 15:17:23 +09:30
Nick Clifton 6ae978f133 Add a description of the 'n' symbol type displayed by nm.
PR 24767
	* doc/binutils.texi (nm): Document the 'n' symbol type.
2019-08-15 15:23:18 +01:00