Commit Graph

3721 Commits

Author SHA1 Message Date
Nobody ae2c13e275 Binutils 2.35 with MCST patches 2022-08-11 20:17:07 +03:00
Alibek Omarov 97ccaa1a4c Merge db49701327 (not working) 2022-08-10 13:50:15 +03:00
Nobody e0892d32d3 Binutils with MCST patches 2020-10-14 00:22:48 +03:00
Nick Clifton 6ef598a264 Remove spurious text in changelog entry 2020-08-12 11:28:52 +01:00
Nick Clifton 279745e566 Set version to 2.35.0 and enable development 2020-07-24 12:05:01 +01:00
Nick Clifton 2cb5c79dad 2.35 Release 2020-07-24 10:36:01 +01:00
Nick Clifton a0af250a0e Updated French translation for the gas/ and binutils/ sub-directories 2020-07-13 14:48:15 +01:00
Nick Clifton b3eaec43b9 Updated translations for various binutils sub-directories 2020-07-06 10:40:44 +01:00
Nick Clifton d63813ff85 Set version to 2.34.90 and regenerate files 2020-07-04 10:41:03 +01:00
Nick Clifton b115b9fd3c Add markers for binutils 2.35 branch 2020-07-04 10:16:22 +01:00
Nick Clifton 0942c7ab94 Change readelf's display of symbol names (when not in --wide mode) so that if they are going to be truncated then "[...]" is displayed at the end. Add a comment line option to disable this enhancement and restore the old behaviour.
PR 26028
binutils* readelf.c (print_symbol): Handle truncation of symbol names.
	(options): Add -T/--silent-truncation option.
	(parse_args): Handle the option.
	(print_dynamic_symbol): Correct calculation of width available to
	display symbol name.
	* doc/binutils.texi: Document the -T option to readelf.
	* NEWS: Mention the new feature.

gas	* testsuite/gas/ia64/group-2.d: Add -T option to readelf
	command line.
	* testsuite/gas/ia64/unwind.d: Likewise.
	* testsuite/gas/mmix/bspec-1.d: Likewise.
	* testsuite/gas/mmix/bspec-2.d: Likewise.
	* testsuite/gas/mmix/comment-1.d: Likewise.
	* testsuite/gas/tic6x/scomm-directive-4.d: Likewise.

ld	* testsuite/ld-powerpc/powerpc.exp: Add -T option to readelf
	command line when running some tests.
	* testsuite/ld-arm/arm-elf.exp: Likewise.
	* testsuite/ld-mips-elf/mips-elf.exp: Likewise.
	* testsuite/ld-mmix/local1.d: Likewise.
	* testsuite/ld-mmix/local3.d: Likewise.
	* testsuite/ld-mmix/local5.d: Likewise.
	* testsuite/ld-mmix/local7.d: Likewise.
	* testsuite/ld-powerpc/powerpc.exp: Likewise.
2020-07-02 11:30:52 +01:00
H.J. Lu bbd19b19e4 Remove x86 NaCl target support
NaCl has been deprecated:

https://developer.chrome.com/native-client/migration

and NaCl will completely disappear in 2021:

https://lists.llvm.org/pipermail/llvm-dev/2020-April/141107.html

Remove x86 NaCl target support from bfd, binutils, gas and ld.

bfd/

	* archures.c (bfd_mach_i386_nacl): Removed.
	(bfd_mach_i386_i386_nacl): Likewise.
	(bfd_mach_x86_64_nacl): Likewise.
	(bfd_mach_x64_32_nacl): Likewise.
	* config.bfd: Remove *-*-nacl* targets.
	* configure.ac: Remove x86 NaCl target vectors.
	* cpu-i386.c (bfd_arch_i386_onebyte_nop_fill): Removed.
	(bfd_x64_32_nacl_arch): Likewise.
	(bfd_x86_64_nacl_arch): Likewise.
	(bfd_i386_nacl_arch): Likewise.
	(bfd_x64_32_arch_intel_syntax): Updated.
	* elf32-i386.c: Don't include "elf-nacl.h".
	(elf_i386_nacl_plt): Removed.
	(elf_i386_nacl_plt0_entry): Likewise.
	(elf_i386_nacl_plt_entry): Likewise.
	(elf_i386_nacl_pic_plt0_entry): Likewise.
	(elf_i386_nacl_pic_plt_entry): Likewise.
	(elf_i386_nacl_eh_frame_plt): Likewise.
	(elf_i386_nacl_plt): Likewise.
	(elf32_i386_nacl_elf_object_p): Likewise.
	(elf_i386_get_synthetic_symtab): Updated.
	(elf_i386_link_setup_gnu_properties): Likewise.
	* elf64-x86-64.c: Don't include "elf-nacl.h".
	(elf_x86_64_nacl_plt): Removed.
	(elf64_x86_64_nacl_elf_object_p): Likewise.
	(elf_x86_64_nacl_plt0_entry): Likewise.
	(elf_x86_64_nacl_plt_entry): Likewise.
	(elf_x86_64_nacl_eh_frame_plt): Likewise.
	(elf_x86_64_nacl_plt): Likewise.
	(elf32_x86_64_nacl_elf_object_p): Likewise.
	(elf_x86_64_get_synthetic_symtab): Updated.
	(elf_x86_64_link_setup_gnu_properties): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Likewise.
	* targets.c: Remove x86 NaCl target vectors.
	* bfd-in2.h: Regenerated.
	* configure: Likewise.

binutils/

	* NEWS: Mention x86 NaCl target support removal.
	* dwarf.c (init_dwarf_regnames_by_bfd_arch_and_mach): Remove
	x86 NaCl target support.
	* testsuite/binutils-all/elfedit-1.d: Likewise.
	* testsuite/binutils-all/i386/i386.exp: Likewise.
	* testsuite/binutils-all/x86-64/objects.exp: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
	* testsuite/binutils-all/x86-64/x86-64.exp: Likewise.

gas/

	* NEWS: Mention x86 NaCl target support removal.
	* config/tc-i386.c: Remove x86 NaCl target support.
	* config/tc-i386.h: Likewise.
	* configure.tgt: Likewise.
	* testsuite/gas/i386/i386.exp: Likewise.
	* testsuite/gas/i386/iamcu-1.d: Likewise.
	* testsuite/gas/i386/iamcu-2.d: Likewise.
	* testsuite/gas/i386/iamcu-3.d: Likewise.
	* testsuite/gas/i386/iamcu-4.d: Likewise.
	* testsuite/gas/i386/iamcu-5.d: Likewise.
	* testsuite/gas/i386/k1om.d: Likewise.
	* testsuite/gas/i386/l1om.d: Likewise.

ld/

	* Makefile.am (ALL_EMULATION_SOURCES): Remove eelf_i386_nacl.c,
	eelf32_x86_64_nacl.c, eelf_x86_64_nacl.c.
	Remove x86 NaCl dep files.
	* NEWS: Mention x86 NaCl target support removal.
	* configure.tgt: Remove x86 NaCl target support.
	* testsuite/ld-elf/binutils.exp: Likewise.
	* testsuite/ld-elf/elf.exp: Likewise.
	* testsuite/ld-elfvers/vers.exp: Likewise.
	* testsuite/ld-i386/align-branch-1.d: Likewise.
	* testsuite/ld-i386/export-class.exp: Likewise.
	* testsuite/ld-i386/i386.exp: Likewise.
	* testsuite/ld-i386/load1.d: Likewise.
	* testsuite/ld-i386/pie1.d: Likewise.
	* testsuite/ld-i386/pr12570a.d: Likewise.
	* testsuite/ld-i386/pr12570b.d: Likewise.
	* testsuite/ld-i386/pr19636-1d.d: Likewise.
	* testsuite/ld-i386/pr19636-1l.d: Likewise.
	* testsuite/ld-i386/pr19636-2c.d: Likewise.
	* testsuite/ld-i386/pr19636-2d.d: Likewise.
	* testsuite/ld-i386/pr19636-2e.d: Likewise.
	* testsuite/ld-i386/pr20244-1a.d: Likewise.
	* testsuite/ld-i386/pr20244-1b.d: Likewise.
	* testsuite/ld-i386/pr20244-2a.d: Likewise.
	* testsuite/ld-i386/pr20244-2b.d: Likewise.
	* testsuite/ld-i386/pr20244-2c.d: Likewise.
	* testsuite/ld-i386/pr20244-4a.d: Likewise.
	* testsuite/ld-i386/pr20244-4b.d: Likewise.
	* testsuite/ld-i386/pr21884.d: Likewise.
	* testsuite/ld-ifunc/binutils.exp: Likewise.
	* testsuite/ld-ifunc/ifunc-10-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-10-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-11-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-11-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-12-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-12-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-13-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-13-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14c-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14c-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14d-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14d-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14e-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14e-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14f-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14f-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-15-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-15-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-20-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-20-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-21-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-21-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-22-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-22-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5r-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5r-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-8-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-8-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-9-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-9-x86-64.d: Likewise.
	* testsuite/ld-ifunc/pr17154-i386-now.d: Likewise.
	* testsuite/ld-ifunc/pr17154-i386.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.
	* testsuite/ld-plugin/lto.exp: Likewise.
	* testsuite/ld-x86-64/align-branch-1.d: Likewise.
	* testsuite/ld-x86-64/dwarfreloc.exp: Likewise.
	* testsuite/ld-x86-64/line.exp: Likewise.
	* testsuite/ld-x86-64/load1a.d: Likewise.
	* testsuite/ld-x86-64/load1b.d: Likewise.
	* testsuite/ld-x86-64/load1c.d: Likewise.
	* testsuite/ld-x86-64/load1d.d: Likewise.
	* testsuite/ld-x86-64/pie3.d: Likewise.
	* testsuite/ld-x86-64/pr18160.d: Likewise.
	* testsuite/ld-x86-64/pr19013-x32.d: Likewise.
	* testsuite/ld-x86-64/pr19013.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2d.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2l.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1b.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1d.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1f.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1h.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1j.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1l.d: Likewise.
	* testsuite/ld-x86-64/pr21884.d: Likewise.
	* testsuite/ld-x86-64/pr22393-3a.rd: Likewise.
	* testsuite/ld-x86-64/pr22393-3b.rd: Likewise.
	* testsuite/ld-x86-64/tlsgd10.dd: Likewise.
	* testsuite/ld-x86-64/tlsgd5.dd: Likewise.
	* testsuite/ld-x86-64/tlsgd8.dd: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* emulparams/elf32_x86_64_nacl.sh: Removed.
	* emulparams/elf_i386_nacl.sh: Likewise.
	* emulparams/elf_x86_64_nacl.sh: Likewise.
	* testsuite/ld-i386/emit-relocs-nacl.rd: Likewise.
	* testsuite/ld-i386/load1-nacl.d: Likewise.
	* testsuite/ld-i386/pie1-nacl.d: Likewise.
	* testsuite/ld-i386/plt-nacl.pd: Likewise.
	* testsuite/ld-i386/plt-pic-nacl.pd: Likewise.
	* testsuite/ld-i386/pr17709-nacl.rd: Likewise.
	* testsuite/ld-i386/pr19636-1d-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2c-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2d-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2e-nacl.d: Likewise.
	* testsuite/ld-i386/pr19827-nacl.rd: Likewise.
	* testsuite/ld-i386/pr21884-nacl.d: Likewise.
	* testsuite/ld-i386/pr21884-nacl.t: Likewise.
	* testsuite/ld-i386/tlsbin-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsbin2-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsbindesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsdesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsgdesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsnopic-nacl.rd: Likewise.
	* testsuite/ld-i386/tlspic-nacl.rd: Likewise.
	* testsuite/ld-i386/tlspic2-nacl.rd: Likewise.
	* testsuite/ld-x86-64/ilp32-4-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1a-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1b-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1c-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1d-nacl.d: Likewise.
	* testsuite/ld-x86-64/pie3-nacl.d: Likewise.
	* testsuite/ld-x86-64/plt-nacl.pd: Likewise.
	* testsuite/ld-x86-64/pr17709-nacl.rd: Likewise.
	* testsuite/ld-x86-64/pr19013-nacl.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2d-nacl.d: Likewise.
	* testsuite/ld-x86-64/pr19827-nacl.rd: Likewise.
	* testsuite/ld-x86-64/pr21884-nacl.d: Likewise.
	* testsuite/ld-x86-64/pr21884-nacl.t: Likewise.
	* testsuite/ld-x86-64/split-by-file-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsbin-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsbin2-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsbindesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsdesc-nacl.pd: Likewise.
	* testsuite/ld-x86-64/tlsdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsgdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlspic-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlspic2-nacl.rd: Likewise.
	* Makefile.in: Regenerated.
	* po/BLD-POTFILES.in: Likewise.
2020-06-30 08:56:14 -07:00
Nick Clifton 5568cc9ee8 Add support for attributes using DW_FORM_GNU_strp_alt
* dwarf.c (read_and_display_attr_value): Support
	DW_FORM_GNU_strp_alt when used with DW_AT_dwo_name and
	DW_AT_comp_dir.
2020-06-30 13:05:18 +01:00
Alan Modra d74b88ed7f Fix nds32*-elf XPASS readelf -wiaoRlL dw5
The underlying fail was probably fixed with git commit fbaf61ad5.

	* testsuite/binutils-all/readelf.exp (readelf_dump_test): Remove
	xfail for nds32.
2020-06-30 13:32:04 +09:30
Hans-Peter Nilsson 9f27c36482 binutils/dwarf.c: Correct an `index' global shadowing error for pre-4.8 GCC
In older gcc, shadowing a function name with a local variable name is
flagged as an error, certainly a bug but which is usually worked
around in binutils:

gcc -DHAVE_CONFIG_H -I. -I$SRC/binutils  -I. -I$SRC/binutils -I../bfd -I$SRC/binutils/../bfd -I$SRC/binutils/../include -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I$SRC/binutils/../zlib -g -O2 -MT dwarf.o -MD -MP -MF $depbase.Tpo -c -o dwarf.o $SRC/binutils/dwarf.c &&\
	mv -f $depbase.Tpo $depbase.Po
cc1: warnings being treated as errors
$SRC/binutils/dwarf.c: In function 'display_debug_str_offsets':
$SRC/binutils/dwarf.c:6913: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:309: error: shadowed declaration is here
make[4]: *** [dwarf.o] Error 1

See also GCC PR c/53066.  This is just another one that crept in since
I and others last had to use an old version.  The name "idx" was used
in the preceding function, display_debug_addr.  Also, it was declared
c99 style (after a statement in the block).  Committed as obvious.

binutils:
	* dwarf.c (display_debug_str_offsets): Rename local variable
	index to idx.  Move to top of function.
2020-06-29 03:50:45 +02:00
Alan Modra 279edac53d C++ comments
binutils isn't c99 (yet).  This replaces or removes some C++ style
comments.

bfd/
	* arc-got.h: Use C style comments.
	* coff-z80.c: Likewise.
	* elf32-csky.c: Likewise.
	* peXXigen.c: Likewise.
	* elf32-m32c.c (m32c_elf_relax_delete_bytes): Remove commented out
	code.
binutils/
	* dwarf.c: Use C style comments.
	* resrc.c: Likewise.
gas/
	* config/tc-s12z.c: Use C style comments.
	* config/tc-z80.c: Likewise.
	* config/tc-xtensa.c (emit_ld_r_n): Remove commented out code.
include/
	* coff/internal.h: Use C style comments.
	* coff/pe.h: Likewise.
	* elf/ppc64.h: Likewise.
opcodes/
	* arm-dis.c: Use C style comments.
	* cr16-opc.c: Likewise.
	* ft32-dis.c: Likewise.
	* moxie-opc.c: Likewise.
	* tic54x-dis.c: Likewise.
	* s12z-opc.c: Remove useless comment.
	* xgate-dis.c: Likewise.
2020-06-29 10:07:56 +09:30
Alan Modra cfc16775b7 asan: readelf: use after free in process_archive
This tidies up in cases where fuzzed thin archives hit the error return
path in setup_nested_archive.

	* elfcomm.c (setup_nested_archive): Set nested_arch->file to NULL
	after freeing.
	(release_archive): Set fields of arch to NULL after freeing.
2020-06-27 12:55:35 +09:30
Nick Alcock 2f6ecaed66 libctf, binutils: support CTF archives like objdump
objdump and readelf have one major CTF-related behavioural difference:
objdump can read .ctf sections that contain CTF archives and extract and
dump their members, while readelf cannot.  Since the linker often emits
CTF archives, this means that readelf intermittently and (from the
user's perspective) randomly fails to read CTF in files that ld emits,
with a confusing error message wrongly claiming that the CTF content is
corrupt.  This is purely because the archive-opening code in libctf was
needlessly tangled up with the BFD code, so readelf couldn't use it.

Here, we disentangle it, moving ctf_new_archive_internal from
ctf-open-bfd.c into ctf-archive.c and merging it with the helper
function in ctf-archive.c it was already using.  We add a new public API
function ctf_arc_bufopen, that looks very like ctf_bufopen but returns
an archive given suitable section data rather than a ctf_file_t: the
archive is a ctf_archive_t, so it can be called on raw CTF dictionaries
(with no archive present) and will return a single-member synthetic
"archive".

There is a tiny lifetime tweak here: before now, the archive code could
assume that the symbol section in the ctf_archive_internal wrapper
structure was always owned by BFD if it was present and should always be
freed: now, the caller can pass one in via ctf_arc_bufopen, wihch has
the usual lifetime rules for such sections (caller frees): so we add an
extra field to track whether this is an internal call from ctf-open-bfd,
in which case we still free the symbol section.

include/
	* ctf-api.h (ctf_arc_bufopen): New.
libctf/
	* ctf-impl.h (ctf_new_archive_internal): Declare.
	(ctf_arc_bufopen): Remove.
	(ctf_archive_internal) <ctfi_free_symsect>: New.
	* ctf-archive.c (ctf_arc_close): Use it.
	(ctf_arc_bufopen): Fuse into...
	(ctf_new_archive_internal): ... this, moved across from...
	* ctf-open-bfd.c: ... here.
	(ctf_bfdopen_ctfsect): Use ctf_arc_bufopen.
	* libctf.ver: Add it.
binutils/
	* readelf.c (dump_section_as_ctf): Support .ctf archives using
	ctf_arc_bufopen.  Automatically load the .ctf member of such
	archives as the parent of all other members, unless specifically
	overridden via --ctf-parent.  Split out dumping code into...
	(dump_ctf_archive_member): ... here, as in objdump, and call
	it once per archive member.
	(dump_ctf_indent_lines): Code style fix.
2020-06-26 15:56:39 +01:00
Nick Alcock 094e34f221 binutils, ld: work with --disable-libctf
This unfortunately means conditionalizing out all the libctf code, but
the result is not too unbearably ugly, if a bit repetitive.  I have
stubbed out code in the !ENABLE_LIBCTF path to avoid extra redundant
ifdefs where it seems that might be helpful.  (The stubs are not too
disruptive, but I've tried to keep them on one line where possible to
avoid filling up the screen with stubs that nobody would care about.
If this is too much of a coding style violation I can change it.)

Changes since v2: use GCC_ENABLE rather than repeating all the
                  AC_ARG_ENABLE stuff over and over again.

ld/
	* configure.ac [--enable-libctf]: New, default yes.
	Set ENABLE_LIBCTF accordingly.
	* Makefile.am [!ENABLE_LIBCTF]: Empty LIBCTF.
	* configure: Regenerate.
	* config.in: Regenerate.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* ldlang.c (ctf_output): Conditionalize on ENABLE_LIBCTF.
	(ldlang_open_ctf): Likewise.
	(lang_merge_ctf): Likewise.
	(ldlang_ctf_apply_strsym): Likewise.
	(lang_write_ctf): Likewise.
	(ldlang_write_ctf_late): Likewise.
	(ldlang_open_ctf) [!ENABLE_LIBCTF]: Warn about the presence of CTF
	sections.
	(lang_merge_ctf) [!ENABLE_LIBCTF]: New stub.
	(ldlang_ctf_apply_strsym) [!ENABLE_LIBCTF]: Likewise.
	(lang_write_ctf) [!ENABLE_LIBCTF]: Likewise.
	(ldlang_write_ctf_late) [!ENABLE_LIBCTF]: Likewise.
	* ldelfgen.c (ldelf_emit_ctf_early): Conditionalize on
	ENABLE_LIBCTF.
	(struct ctf_strsym_iter_cb_arg): Likewise.
	(ldelf_ctf_strtab_iter_cb): Likewise.
	(ldelf_ctf_symbols_iter_cb): Likewise.
	(ldelf_examine_strtab_for_ctf): Likewise.
	(ldelf_emit_ctf_early) [!ENABLE_LIBCTF]: New stub.
	(ldelf_examine_strtab_for_ctf) [!ENABLE_LIBCTF]: New stub.

binutils/
	* configure.ac [--enable-libctf]: New, default yes.
	Set ENABLE_LIBCTF accordingly.
	* Makefile.am [!ENABLE_LIBCTF]: Empty LIBCTF and LIBCTF_NOBFD.
	* configure: Regenerate.
	* config.in: Regenerate.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* objdump.c (usage): Conditionalize portions on ENABLE_LIBCTF.
	(option_values): Likewise.
	(long_options): Likewise.
	(main): Likewise.
	(dump_ctf_indent_lines): Conditionalize out when !ENABLE_LIBCTF.
	(make_ctfsect): Likewise.
	(dump_ctf_archive_member): Likewise.
	(dump_ctf) [ENABLE_LIBCTF]: Likewise.
	(dump_ctf) [!ENABLE_LIBCTF]: New empty stub.
	* readelf.c (options): Conditionalize portions on ENABLE_LIBCTF.
	(usage): Likewise.
	(process_section_contents): Likewise.
	(shdr_to_ctf_sect): Conditionalize out when !ENABLE_LIBCTF.
	(dump_ctf_indent_lines): Likewise.
	(dump_section_as_ctf) [ENABLE_LIBCTF]: Likewise.
2020-06-26 15:56:39 +01:00
Jan Beulich 2a1bb84c67 x86: fix processing of -M disassembler option
Multiple -M options can be specified in any order. Therefore stright
assignment to fields affected needs to be avoided, such that earlier
options' effects won't be discarded. This was in particular a problem
for -Msuffix followed by certain of the other sub-options.

While updating documentation, take the liberty and also drop the
redundant mentioning of being able to comma-separate multiple options.
2020-06-26 16:42:55 +02:00
Pat Bernardi 85f7484a3a m68k: tag floating-point ABI used
This patch adds GNU attribute support to m68k and utilises it to tag the
floating-point calling convention used (hard-float or soft-float). It enables
the linker to ensure linked objects use a consistent floating-point ABI and
allows tools like GDB to infer the ABI used from the ELF file. It is based on
similar work done for PowerPC.

bfd/
	* elf32-m68k.c (m68k_elf_merge_obj_attributes): New function.
	(elf32_m68k_merge_private_bfd_data): Merge GNU attributes.
binutils/
	* readelf.c (display_m68k_gnu_attribute): New function.
	(process_arch_specific): Call display_m68k_gnu_attribute for EM_68K.
gas/
	* config/tc-m68k.c (m68k_elf_gnu_attribute): New function.
	(md_pseudo_table): Handle "gnu_attribute".
	* doc/as.texi: Document GNU attribute for M68K.
include/
	* elf/m68k.h: Add enum for GNU object attribute with floating point
	tag name and values.
ld/
	* testsuite/ld-m68k/attr-gnu-4-0.s: New file.
	* testsuite/ld-m68k/attr-gnu-4-1.s: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-2.s: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-00.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-01.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-02.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-10.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-11.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-12.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-20.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-21.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-22.d: Likewise.
	* testsuite/ld-m68k/m68k.exp: Run the new tests.
2020-06-26 14:42:19 +09:30
H.J. Lu d0dded5bc2 Add a testcase for PR binutils/26160
PR binutils/26160
	* testsuite/binutils-all/pr26160.dwp.bz2: New file.
	* testsuite/binutils-all/pr26160.r: Likewise.
	* testsuite/binutils-all/readelf.exp: Run PR binutils/26160 test.
2020-06-23 09:20:28 -07:00
Nick Clifton 39f381cb80 Fix decoding of indexed DWARF strings using pre-DWARF-5 string offset sections. Fix display of .debug_str_offsets.dwo sections.
PR 26160
	* dwarf.c (fetch_indexed_string): Detect and handle old style
	.debug_str_offset tables.
	(display_debug_str_offsets): Likewise.  Also add support for
	.debug_str_offsets.dwo sections.
2020-06-23 16:06:38 +01:00
H.J. Lu 80fda85ca1 Add a testcase for PR binutils/26112
PR binutils/26112
	* testsuite/binutils-all/pr26112.o.bz2: New file.
	* testsuite/binutils-all/pr26112.r: Likewise.
	* testsuite/binutils-all/readelf.exp: Run PR binutils/26112 test.
2020-06-23 06:52:41 -07:00
Alan Modra d081ffffa0 binutils objdump.exp remote_file typo
* testsuite/binutils-all/objdump.exp (bintest.a): Correct
	remote_file delete command.
2020-06-23 11:02:56 +09:30
Nick Clifton e4b7104b1e Add support for decoding the DW_MACRO_define_strx and DW_MACRO_undef_strx operands found in DWARF-5 .debug_macro sections.
PR 26112
	* dwarf.c (display_debug_str_offsets): Add code to display the
	contents of the .debug_str_offsets section.
	(display_debug_macro): Add support for DW_MACRO_define_strx and
	DW_MACRO_undef_strx.
2020-06-22 17:44:56 +01:00
Saagar Jha d768f160a9 Recognize some new Mach-O load commands
bfd
	* mach-o.c: Support the new load commands by reading a linkedit data
	command for them.
binutils
	* od-macho.c: Dump linkedit data for new load commands.
include
	* mach-o/loader.h: Add declarations of two new Mach-O load
	commands.
2020-06-22 14:29:20 +01:00
Alan Modra 5fd104addf Emit a warning when -z relro is unsupported
ld silently accepts -z relro and -z norelro for targets that lack the
necessary GNU_RELRO support.  This patch makes those targets emit a
warning instead, and adds testsuite infrastructure to detect when
relro is unsupported.

binutils/
	* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
	* testsuite/lib/binutils-common.exp (check_relro_support): New proc.
	(run_dump_test): Use check_relro_support to decide whether to pass
	extra ld option "-z norelro".
ld/
	* emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Omit
	-z relro and -z norelro when target support for GNU_RELRO is lacking.
	(gld${EMULATION_NAME}_before_parse): Ignore RELRO default too.
	* emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse): Ignore
	RELRO default when target support for GNU_RELRO is lacking.
	* emultempl/armelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
	* emultempl/linux.em (gld${EMULATION_NAME}_before_parse): Likewise.
	* emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
	* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
	* testsuite/ld-elf/pr16322.d: xfail when no relro support.
	* testsuite/ld-elf/pr22393-1a.d: Likewise.
	* testsuite/ld-elf/pr22393-1b.d: Likewise.
	* testsuite/ld-elf/shared.exp (pr20995-2.so, pr20995-2): Likewise.
	* testsuite/lib/ld-lib.exp (run_ld_link_tests): Use check_relro_support
	to decide whether to pass extra ld option "-z norelro".
2020-06-19 09:50:20 +09:30
Alan Modra fd17d1e695 Re: asan: readelf: process_mips_specific buffer overflow
Let's do without that unnecessary internal option buffer.  This also
fixes another bug in that the REGINFO data was being taken from the
calloc'd internal option buffer, so was all zeros.

	* readelf.c (process_mips_specific): Don't alloc memory for
	Elf_Internal_Options.
2020-06-11 14:50:48 +09:30
Alan Modra d0c4e7802d asan: readelf: process_mips_specific buffer overflow
DT_MIPS_OPTIONS is not a regular array as assumed by readelf.  This
patch corrects that assumption, and to do so easily, makes various
internal (host byte order) structs the same size as external (target
byte order) structs.

include/
	* elf/mips.h (Elf32_RegInfo): Use fixed width integer types.
	(Elf64_Internal_RegInfo, Elf_Internal_Options): Likewise.
binutils/
	* readelf.c (process_mips_specific): Assert size of internal
	types match size of external types, and simplify allocation of
	internal buffer.  Catch possible integer overflow when sanity
	checking option size.  Don't assume options are a regular array.
	Sanity check reginfo option against option size.  Use PRI macros
	when printing.
2020-06-11 13:54:46 +09:30
Ralf Habacker 25065fcd19 Fix the windmc program to conform to the behaviour of mc.exe by rejecting lines that reach end-of-file without a terminating newline character.
PR 26082
	* mclex.c (yylex): Reject lines that reach end-of-file without a
	terminating newline character.
2020-06-10 10:07:26 +01:00
Nick Clifton b37a771440 Fix a typo in the description of the strings program.
PR 26093
	* doc/binutils.texi (strings): Fix typo.
2020-06-08 11:32:15 +01:00
Nick Clifton c4b2f181c3 Fix an illegal memory access when parsing corrupt DWARF debug information.
PR 26086
	* dwarf.c (process_debug_info): Check that there is space in the
	debug_information array before filling in an entry.
2020-06-08 11:24:06 +01:00
Alan Modra 1424c35d07 Power10 tidies
binutils/
	* doc/binutils.texi (PowerPC -M option): Mention power10 and pwr10.
gas/
	* config/tc-ppc.c (md_show_usage): Mention -mpower10 and -mpwr10.
	* doc/c-ppc.texi: Likewise.
opcodes/
	* ppc-dis.c (ppc_opts): Accept -mpwr10/-Mpwr10.
2020-06-06 14:44:32 +09:30
Joel Anderson 8affa48ac7 Fix a potential infinite loop in the Windows resource parser.
PR 26082
	* mclex.c (yylex): Add test for an empty input stream.
2020-06-05 11:11:03 +01:00
Stephen Casner 8eca5c7d9f Fix unresolved test in binutils for pdp11.
* binutils/testsuite/binutils-all/pr25662-pdp11.s: Alternate source file
for test using section pseudo-ops compatible with pdp11.
* binutils/testsuite/binutils-all/objcopy.exp: Select alternate source.
2020-06-04 23:41:57 -07:00
Jose E. Marchesi b3db6d07be opcodes: support insn endianness in cgen_cpu_open
This patch adds support for a new CGEN_OPEN_INSN_ENDIAN argument
for @arch@_cgen_cpu_open.  This is useful for architectures in
which the endianness of the instruction words is not the same
than the endianness used for data.

An accompanying patch has been sent to the CGEN mailing list that
adds support for this argument on the CGEN side [1].  Its been
already pre-approved [2], and will be applied simultaneously with
this binutils series.

[1] https://sourceware.org/pipermail/cgen/2020q2/002733.html
[2] https://sourceware.org/pipermail/cgen/2020q2/002737.html

include/ChangeLog:

2020-06-04  Jose E. Marchesi  <jemarch@gnu.org>

	* opcode/cgen.h (enum cgen_cpu_open_arg): New value
	CGEN_CPU_OPEN_INSN_ENDIAN.

opcodes/ChangeLog:

2020-06-04  Jose E. Marchesi  <jemarch@gnu.org>

	* cgen-dis.in (cpu_desc_list): New field `insn_endian'.
	(print_insn_): Handle instruction endian.
	* bpf-dis.c: Regenerate.
	* bpf-desc.c: Regenerate.
	* epiphany-dis.c: Likewise.
	* epiphany-desc.c: Likewise.
	* fr30-dis.c: Likewise.
	* fr30-desc.c: Likewise.
	* frv-dis.c: Likewise.
	* frv-desc.c: Likewise.
	* ip2k-dis.c: Likewise.
	* ip2k-desc.c: Likewise.
	* iq2000-dis.c: Likewise.
	* iq2000-desc.c: Likewise.
	* lm32-dis.c: Likewise.
	* lm32-desc.c: Likewise.
	* m32c-dis.c: Likewise.
	* m32c-desc.c: Likewise.
	* m32r-dis.c: Likewise.
	* m32r-desc.c: Likewise.
	* mep-dis.c: Likewise.
	* mep-desc.c: Likewise.
	* mt-dis.c: Likewise.
	* mt-desc.c: Likewise.
	* or1k-dis.c: Likewise.
	* or1k-desc.c: Likewise.
	* xc16x-dis.c: Likewise.
	* xc16x-desc.c: Likewise.
	* xstormy16-dis.c: Likewise.
	* xstormy16-desc.c: Likewise.

binutils/ChangeLog:

2020-06-04  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* objdump.c (disassemble_data): Set disasm_info.endian_code to
        disasm_info.endian after the latter is initialized to the
        endianness reported by BFD.
2020-06-04 16:17:42 +02:00
Alan Modra 0a4f37af5c tcl global directive outside proc body does nothing (binutils)
* testsuite/binutils-all/i386/i386.exp
	* testsuite/binutils-all/x86-64/objects.exp
	* testsuite/binutils-all/x86-64/x86-64.exp
2020-06-04 16:11:23 +09:30
Joel Anderson 913e0fd473 [PATCH] fix windmc typedef bug
While a typedef can be specified in message files for the messages following
with the `MessageIdTypedef` directive, only the last typedef was honored by
windmc. This corrects this behavior, matching mc.exe functionality.

	* windmc.h (struct mc_node): Add id_typecast field.
	* mcparse.y (message): Initialise the id_typecast field.
	* windmc.c (write_dbg): Use the id_typecast field as a parameter
	when calling write_dbg_define.
	(write_header): Likewise.
2020-06-03 16:44:37 +01:00
Alan Modra 4a32244804 PR26069, strip/objcopy memory leaks
PR 26069
	* objcopy.c (copy_relocations_in_section): Free relpp on error.
	Don't accidentally free isection->orelocation.
2020-06-03 17:59:44 +09:30
Alan Modra 0bee4d1c08 binutils archive tests
There are a number of targets that don't support thin archives (*),
and vms doesn't even support file name extensions other than .obj for
archives containing object files.  This patch adjusts the testsuite
to cater for the vms restriction, and reenables testing for non-ELF
alpha targets.  That adds a few alpha-dec-vms fails and one
alpha-linuxecoff fail but testsuite fails on those targets are nothing
new.

(*) It might seem like they do if binutils is built with
--enable-plugins but the plugin archive support is broken, causing the
wrong type of archives to be created by ar for those targets.

	* testsuite/binutils-all/ar.exp (obj): Set up object file name
	extension.  Use throughout.  Don't completely exclude non-ELF
	alpha targets.  Run long_filenames test for tic30.  Exclude thin
	archive tests for aix, ecoff and vms.
	* estsuite/binutils-all/objdump.exp (obj): Set up object file name
	extension.  Use throughout.  Don't exclude non-ELF alpha targets
	from "bintest.a".
2020-06-02 15:00:14 +09:30
Max Filippov ab7ad28739 binutils: Add myself as Xtensa maintainer
2020-05-28  Max Filippov  <jcmvbkbc@gmail.com>
binutils/
	* MAINTAINERS (Xtensa): Add myself as maintainer.
2020-05-28 21:06:51 -07:00
Alan Modra 3f3c36087e ar many_files test
This tests for the issue fixed with git commit 0490dd41ae.

	* testsuite/binutils-all/ar.exp (many_files): New test.
2020-05-23 14:56:07 +09:30
Alan Modra 9db70fc365 Replace "if (x) free (x)" with "free (x)", binutils
* addr2line.c: Replace "if (x) free (x)" with "free (x)" throughout.
	* dlltool.c: Likewise.
	* elfcomm.c: Likewise.
	* rddbg.c: Likewise.
	* readelf.c: Likewise.
	* stabs.c: Likewise.
	* windmc.c: Likewise.
	* windres.c: Likewise.
	* wrstabs.c: Likewise.
2020-05-21 10:45:33 +09:30
Alan Modra c31ab5a001 asan: readelf: wild read in get_num_dynamic_syms
* readelf.c (get_num_dynamic_syms): Bounds check mipsxlat array
	access.
2020-05-21 10:11:57 +09:30
Nelson Chu 8f595e9b4f [PATCH v2 0/9] RISC-V: Support version controling for ISA standard extensions and CSR
1. Remove the -mriscv-isa-version and --with-riscv-isa-version options.
We can still use -march to choose the version for each extensions, so there is
no need to add these.

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

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

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

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

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

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

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

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

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

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

gas	* testsuite/gas/riscv/priv-reg-fail-read-only-01.s: Updated.
	* config/tc-riscv.c (default_arch_with_ext, default_isa_spec):
	Static variables which are used to set the ISA extensions. You can
	use -march (or ELF build attributes) and -misa-spec to set them,
	respectively.
	(ext_version_hash): The hash table used to handle the extensions
	with versions.
	(init_ext_version_hash): Initialize the ext_version_hash according
	to riscv_ext_version_table.
	(riscv_get_default_ext_version): The callback function of
	riscv_parse_subset_t.  According to the choosed ISA spec,
	get the default version for the specific extension.
	(riscv_set_arch): Set the callback function.
	(enum options, struct option md_longopts): Add new option -misa-spec.
	(md_parse_option): Do not call riscv_set_arch for -march.  We will
	call it later in riscv_after_parse_args.  Call riscv_get_isa_spec_class
	to set default_isa_spec class.
	(riscv_after_parse_args): Call init_ext_version_hash to initialize the
	ext_version_hash, and then call riscv_set_arch to set the architecture
	with versions according to default_arch_with_ext.
	* testsuite/gas/riscv/attribute-02.d: Set 0p0 as default version for
	x extensions.
	* testsuite/gas/riscv/attribute-03.d: Likewise.
	* testsuite/gas/riscv/attribute-09.d: New testcase.  For i-ext, we
	already set it's version to 2p1 by march, so no need to use the default
	2p2 version.  For m-ext, we do not set the version by -march and ELF arch
	attribute, so set the default 2p0 to it.  For zicsr, it is not defined in
	ISA spec 2p2, so set 0p0 to it.
	* testsuite/gas/riscv/attribute-10.d: New testcase.  The version of
	zicsr is 2p0 according to ISA spec 20191213.
	* config/tc-riscv.c (DEFAULT_RISCV_ARCH_WITH_EXT)
	(DEFAULT_RISCV_ISA_SPEC): Default configure option settings.
	You can set them by configure options --with-arch and
	--with-isa-spec, respectively.
	(riscv_set_default_isa_spec): New function used to set the
	default ISA spec.
	(md_parse_option): Call riscv_set_default_isa_spec rather than
	call riscv_get_isa_spec_class directly.
	(riscv_after_parse_args): If the -isa-spec is not set, then we
	set the default ISA spec according to DEFAULT_RISCV_ISA_SPEC by
	calling riscv_set_default_isa_spec.
	* testsuite/gas/riscv/attribute-01.d: Add -misa-spec=2.2, since
	the --with-isa-spec may be set to different ISA spec.
	* testsuite/gas/riscv/attribute-02.d: Likewise.
	* testsuite/gas/riscv/attribute-03.d: Likewise.
	* testsuite/gas/riscv/attribute-04.d: Likewise.
	* testsuite/gas/riscv/attribute-05.d: Likewise.
	* testsuite/gas/riscv/attribute-06.d: Likewise.
	* testsuite/gas/riscv/attribute-07.d: Likewise.
	* configure.ac: Add configure options, --with-arch and
	--with-isa-spec.
	* configure: Regenerated.
	* config.in: Regenerated.
	* config/tc-riscv.c (default_priv_spec): Static variable which is
	used to check if the CSR is valid for the chosen privilege spec. You
	can use -mpriv-spec to set it.
	(enum reg_class): We now get the CSR address from csr_extra_hash rather
	than reg_names_hash.  Therefore, move RCLASS_CSR behind RCLASS_MAX.
	(riscv_init_csr_hashes): Only need to initialize one hash table
	csr_extra_hash.
	(riscv_csr_class_check): Change the return type to void.  Don't check
	the ISA dependency if -mcsr-check isn't set.
	(riscv_csr_version_check): New function.  Check and find the CSR address
	from csr_extra_hash, according to default_priv_spec.  Report warning
	for the invalid CSR if -mcsr-check is set.
	(reg_csr_lookup_internal): Updated.
	(reg_lookup_internal): Likewise.
	(md_begin): Updated since DECLARE_CSR and DECLARE_CSR_ALIAS are changed.
	(enum options, struct option md_longopts): Add new GAS option -mpriv-spec.
	(md_parse_option): Call riscv_set_default_priv_version to set
	default_priv_spec.
	(riscv_after_parse_args): If -mpriv-spec isn't set, then set the default
	privilege spec to the newest one.
	(enum riscv_csr_class, struct riscv_csr_extra): Move them to
	include/opcode/riscv.h.
	* testsuite/gas/riscv/priv-reg-fail-fext.d: This test case just want
	to check the ISA dependency for CSR, so fix the spec version by adding
	-mpriv-spec=1.11.
	* testsuite/gas/riscv/priv-reg-fail-fext.l: Likewise.  There are some
	version warnings for the test case.
	* gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.d: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-read-only-02.d: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d: New test case.
	Check whether the CSR is valid when privilege version 1.9 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: New test case.
	Check whether the CSR is valid when privilege version 1.9.1 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d: New test case.
	Check whether the CSR is valid when privilege version 1.10 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d: New test case.
	Check whether the CSR is valid when privilege version 1.11 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise.
	* config/tc-riscv.c (DEFAULT_RISCV_ISA_SPEC): Default configure option
	setting.  You can set it by configure option --with-priv-spec.
	(riscv_set_default_priv_spec): New function used to set the default
	privilege spec.
	(md_parse_option): Call riscv_set_default_priv_spec rather than
	call riscv_get_priv_spec_class directly.
	(riscv_after_parse_args): If -mpriv-spec isn't set, then we set the
	default privilege spec according to DEFAULT_RISCV_PRIV_SPEC by
	calling riscv_set_default_priv_spec.
	* testsuite/gas/riscv/csr-dw-regnums.d: Add -mpriv-spec=1.11, since
	the --with-priv-spec may be set to different privilege spec.
	* testsuite/gas/riscv/priv-reg.d: Likewise.
	* configure.ac: Add configure option --with-priv-spec.
	* configure: Regenerated.
	* config.in: Regenerated.
	* config/tc-riscv.c (explicit_attr): Rename explicit_arch_attr to
	explicit_attr.  Set it to TRUE if any ELF attribute is found.
	(riscv_set_default_priv_spec): Try to set the default_priv_spec if
	the priv attributes are set.
	(md_assemble): Set the default_priv_spec according to the priv
	attributes when we start to assemble instruction.
	(riscv_write_out_attrs): Rename riscv_write_out_arch_attr to
	riscv_write_out_attrs.  Update the arch and priv attributes.  If we
	don't set the corresponding ELF attributes, then try to output the
	default ones.
	(riscv_set_public_attributes): If any ELF attribute or -march-attr
	options is set (explicit_attr is TRUE), then call riscv_write_out_attrs
	to update the arch and priv attributes.
	(s_riscv_attribute): Make sure all arch and priv attributes are set
	before any instruction.
	* testsuite/gas/riscv/attribute-01.d: Update the priv attributes if any
	ELF attribute or -march-attr is set.  If the priv attributes are not
	set, then try to update them by the default setting (-mpriv-spec or
	--with-priv-spec).
	* testsuite/gas/riscv/attribute-02.d: Likewise.
	* testsuite/gas/riscv/attribute-03.d: Likewise.
	* testsuite/gas/riscv/attribute-04.d: Likewise.
	* testsuite/gas/riscv/attribute-06.d: Likewise.
	* testsuite/gas/riscv/attribute-07.d: Likewise.
	* testsuite/gas/riscv/attribute-08.d: Likewise.
	* testsuite/gas/riscv/attribute-09.d: Likewise.
	* testsuite/gas/riscv/attribute-10.d: Likewise.
	* testsuite/gas/riscv/attribute-unknown.d: Likewise.
	* testsuite/gas/riscv/attribute-05.d: Likewise.  Also, the priv spec
	set by priv attributes must be supported.
	* testsuite/gas/riscv/attribute-05.s: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p9.d: Likewise.  Updated
	priv attributes according to the -mpriv-spec option.
	* testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p10.d: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p11.d: Likewise.
	* testsuite/gas/riscv/priv-reg.d: Removed.
	* testsuite/gas/riscv/priv-reg-version-1p9.d: New test case.  Dump the
	CSR according to the priv spec 1.9.
	* testsuite/gas/riscv/priv-reg-version-1p9p1.d: New test case.  Dump the
	CSR according to the priv spec 1.9.1.
	* testsuite/gas/riscv/priv-reg-version-1p10.d: New test case.  Dump the
	CSR according to the priv spec 1.10.
	* testsuite/gas/riscv/priv-reg-version-1p11.d: New test case.  Dump the
	CSR according to the priv spec 1.11.
	* config/tc-riscv.c (md_show_usage): Add descriptions about
	the new GAS options.
	* doc/c-riscv.texi: Likewise.
2020-05-20 17:22:48 +01:00
H.J. Lu 8ac10c5bfc Allow readelf to issue warnings if checking is enabled and there are discrepancies between the dynamic tags and the dynamic sections.
PR binutils/25809
	* readelf.c (process_program_headers): Warn if the PT_DYNAMIC
	segment doesn't match the .dynamic section and checks are
	enabled.
	(struct filedata): Add dynamic_symtab_section and
	dynamic_strtab_section fields.
	(process_section_headers): Set dynamic_symtab_section to the
	.dynsym section.  Set dynamic_strtab_section to the .dynstr
	section.
	(process_dynamic_section): Warn if the .dynsym section doesn't
	match DT_SYMTAB and DT_SYMENT or the .dynstr section doesn't
	DT_STRTAB and DT_STRSZ.  But only if checks are enabled.
2020-05-19 16:47:12 +01:00
Alan Modra c177f3771c Use bfd_get_filename throughout binutils
* ar.c (map_over_members, get_pos_bfd, delete_members, move_members),
	(replace_members): Use bfd_get_filename rather than accessing
	bfd->filename directly.
	* arsup.c (map_over_list, ar_delete, ar_replace, ar_extract): Likewise.
	* binemul.c (do_ar_emul_append): Likewise.
	* coffgrok.c (coff_grok): Likewise.
2020-05-19 12:35:56 +09:30
Stafford Horne 83d27139ca binutils: Add myself as maintainer for OpenRISC
binutils/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* MAINTAINERS (OR1K): Add myself as maintainer.
2020-05-18 05:27:13 +09:00
Andrew Burgess d11a9fabab objcopy: Mention 'entry address' in description
The ELF header contains a start address, which is also sometimes
called the entry address.  The 'objdump -x' output calls this field
the 'start address', while readelf calls it 'entry point address'.
The linker talks about setting the 'entry' point in its manual.

I've always thought of this field as the 'entry address', and so when
I recently wanted to know if objcopy could adjust this field I opened
up the manual and searched for 'entry', which found no hits.

I thought it would be useful (for people like me) if the description
of 'set-start' and 'adjust-start' in the objcopy manual mentioned the
word 'entry' to make it easier to find.

binutils/ChangeLog:

	* doc/binutils.texi: Mention 'entry address' in the set-start and
	adjust-start options descriptions.
2020-05-07 11:39:39 +01:00