Commit Graph

16258 Commits

Author SHA1 Message Date
Alan Modra
918dc783de PR26489, ASAN: ppc64_elf_size_stubs elf64-ppc.c:13389
Stub sections are inserted after sec_info is sized, so have higher ids.
Test flags that will exclude stub sections before looking at the
sec_info array.

	PR 26489
	* elf64-ppc.c (ppc64_elf_size_stubs): Test code_sec->has_toc_reloc
	and code_sec->makes_toc_func_call before sec_info[code_sec->id].
2020-08-25 02:12:35 +09:30
Alan Modra
573eb292ee PR26492, ASAN: ppc64_elf_before_check_relocs elf64-ppc.c:4337
PR 26492
	* elf64-ppc.c (ppc_hash_table): Test is_elf_hash_table before
	accessing elf_hash_table_id.
2020-08-25 02:12:35 +09:30
Alan Modra
a8d549c006 PR26483, ASAN: ppc_elf_link_params elf32-ppc.c:2314
PR 26483
	* elf32-ppc.c (ppc_elf_hash_table): Test is_elf_hash_table before
	accessing elf_hash_table_id.
2020-08-25 02:11:13 +09:30
Mark Wielaard
19d80e5fec bfd: Handle DW_FORM_data16 for .debug_line tables containing MD5
* dwarf2.c (read_attribute_value): Handle DW_FORM_data16.
	(read_formatted_entries): Likewise. And skip zero entry.
2020-08-24 15:52:53 +01:00
Cooper Qu
531c73a37b CSKY: Add new arch CK860.
bfd/
        * bfd-in2.h (bfd_mach_ck860): New.
        * cpu-csky.c (arch_info_struct): Add item for CK860.

gas/
        * config/tc-csky.c (csky_archs): Add item for CK860,
        change ck810 and ck807's arch_flag.
        (csky_cpus): Add item for CK860.
        (md_begin): Enable DSP for CK810 and CK807 by default.
        (md_apply_fix): Fix CKCORE_TLS_IE32 relocation failure.
        * gas/testsuite/gas/csky/cskyv2_all.d: Change 'sync 0'
        to 'sync'.
        * gas/testsuite/gas/csky/cskyv2_all.s: Likewise.
        * gas/testsuite/gas/csky/cskyv2_ck860.d: New.
        * gas/testsuite/gas/csky/cskyv2_ck860.s: New.
        * gas/testsuite/gas/csky/enhance_dsp.d: Change plsli.u16
        to plsli.16.
        * gas/testsuite/gas/csky/enhance_dsp.s: Likewise.

include/
        * opcode/csky.h (CSKYV2_ISA_10E60): New.
        (CSKY_ARCH_860): New.

opcode/
        * csky-dis.c (csky_find_inst_info): Skip CK860's instructions
        in other CPUs to speed up disassembling.
        * csky-opc.h (csky_v2_opcodes): Add CK860's instructions,
        Change plsli.u16 to plsli.16, change sync's operand format.

Change-Id: I80ec1a9c0cc600d668082a9b91ae6d45b33ec0fc
2020-08-24 20:27:07 +08:00
Alan Modra
252dcdf432 PowerPC TPREL_HA/LO optimisation
ppc64 ld optimises sequences like the following
	addis 3,13,wot@tprel@ha
	lwz 3,wot@tprel@l(3)
to
	nop
	lwz 3,wot@tprel(13)
when "wot" is located near enough to the thread pointer.
However, the ABI doesn't require that R_PPC64_TPREL16_HA always be on
an addis rt,13,imm instruction, and while ld checked for that on the
high-part instruction it didn't disable the optimisation on the
low-part instruction.  This patch fixes that problem, disabling the
tprel optimisation globally if high-part instructions don't pass
sanity checks.  The optimisation is also enabled for ppc32, where
before ld.bfd had the code in the wrong place and ld.gold had it in a
block only enabled for ppc64.

bfd/
	* elf32-ppc.c (ppc_elf_check_relocs): Set has_tls_reloc for
	high part tprel16 relocs.
	(ppc_elf_tls_optimize): Sanity check high part tprel16 relocs.
	Clear do_tls_opt on odd instructions.
	(ppc_elf_relocate_section): Move TPREL16_HA/LO optimisation later.
	Don't sanity check them here.
	* elf64-ppc.c (ppc64_elf_check_relocs): Set has_tls_reloc for
	high part tprel16 relocs.
	(ppc64_elf_tls_optimize): Sanity check high part tprel16 relocs.
	Clear do_tls_opt on odd instructions.
	(ppc64_elf_relocate_section): Don't sanity check TPREL16_HA.
ld/
	* testsuite/ld-powerpc/tls32.d: Update for TPREL_HA/LO optimisation.
	* testsuite/ld-powerpc/tlsexe32.d: Likewise.
	* testsuite/ld-powerpc/tlsldopt32.d: Likewise.
	* testsuite/ld-powerpc/tlsmark32.d: Likewise.
	* testsuite/ld-powerpc/tlsopt4_32.d: Likewise.
	* testsuite/ld-powerpc/tprel.s,
	* testsuite/ld-powerpc/tprel.d,
	* testsuite/ld-powerpc/tprel32.d: New tests.
	* testsuite/ld-powerpc/tprelbad.s,
	* testsuite/ld-powerpc/tprelbad.d: New test.
	* testsuite/ld-powerpc/powerpc.exp: Run them.
gold/
	* powerpc.cc (Target_powerpc): Add tprel_opt_ and accessors.
	(Target_powerpc::Scan::local): Sanity check tprel high relocs.
	(Target_powerpc::Scan::global): Likewise.
	(Target_powerpc::Relocate::relocate): Control tprel optimisation
	with tprel_opt_ and enable for 32-bit.
2020-08-24 21:15:06 +09:30
GDB Administrator
b9e188dc8b Automatic date update in version.in 2020-08-24 00:00:07 +00:00
John David Anglin
c40e66502c Disable default ELF plugins on 32-bit hppa*-*-hpux*.
PR binutils/26357
	* configure.ac: Disable plugins by default on 32-bit hppa*-*-hpux*.
	* configure: Regenerate.
2020-08-23 16:44:22 +00:00
GDB Administrator
cee12b773a Automatic date update in version.in 2020-08-23 00:00:08 +00:00
H.J. Lu
3f2e969923 elf: Keep only one '@' for undefined versioned symbols
The symbol string table in the .symtab section is optional and cosmetic.
Keep only one '@' for undefined versioned symbols, which are defined in
shared objects, in the symbol string table.  Update "nm -D" to display
only one '@' for undefined versioned symbols.

bfd/

	PR ld/26382
	* elflink.c (elf_link_output_symstrtab): Keep only one '@' for
	versioned symbols, which are defined in shared objects, in
	symbol string table.

binutils/

	PR ld/26382
	* nm.c (print_symname): Display only one '@' for undefined
	versioned symbols.
	* doc/binutils.texi: Update nm version information.

ld/

	PR ld/26382
	* testsuite/ld-elf/pr26302.nd: Updated.
	* testsuite/ld-elf/pr26302.rd: New file.
	* testsuite/ld-elf/shared.exp: Add a test for readelf -sW.
2020-08-22 08:32:02 -07:00
GDB Administrator
1d4ef7201f Automatic date update in version.in 2020-08-22 00:00:07 +00:00
Nick Clifton
ccf61261eb Fix problems with the AArch64 linker exposed by testing it with sanitization enabled.
bfd	* elfnn-aarch64.c (_bfd_aarch64_erratum_835769_scan): Only sort
	the data map if there are entries in it.
	(_bfd_aarch64_erratum_843419_scan): Likewise.

opcodes	* aarch64-dis.c (get_sym_code_type): Return FALSE for non-ELF
	symbols.
2020-08-21 15:32:20 +01:00
Jan Beulich
610ed3e08f fix objcopy of PE images with .buildid section
Xen Project embeds a build ID in its hypervisor binary (including its
EFI variant), living in a standalone section. This usually gets placed
right after .rodata, and due to the rounding done on the (file) size of
.rodata the two sections appear to overlap (as far as e.g.
find_section_by_vma() is concerned). With the first byte "found" in
.rodata, nothing guarantees that the entire debug dir fits in that
section, leading to apparently random failure of objcopy on such an
image.

Possible alternatives to the solution chosen:
- make find_section_by_vma() honor virt_size,
- correct the recording of sizes elsewhere (ibfd has size == virt_size,
  while obfd doesn't),
- fix the linker to avoid producing apparently overlapping sections.

While touching the condition around and the contents of the disgnostic,
pull it up ahead of the bfd_malloc_and_get_section() call: There's no
point first obtaining the section contents, in order to then fail.
2020-08-21 10:28:35 +02:00
GDB Administrator
9cc9699833 Automatic date update in version.in 2020-08-21 00:00:07 +00:00
Nick Clifton
01147b2082 Ensure that compressed sections that have an ELF compression header structure at the start are correctly aligned.
PR 26428
bfd	* bfd.c (bfd_update_compression_header): Also set the sh_addralign
	field in the ELF header of the compressed sections.

ld	* testsuite/ld-elf/zlibbegin.rS: Update expected output.
	* testsuite/ld-elf/zlibnormal.rS: Likewise.
2020-08-20 15:03:21 +01:00
Nick Clifton
44466e45c5 Apply a workaround to mitigate a quadratic performance hit in the linker when writing out secondary reloc sections.
PR 26406
	* elf-bfd.h (struct bfd_elf_section_data): Add
	has_secondary_relocs field.
	* elf.c (_bfd_elf_copy_special_section_fields): Set the
	has_secondary_relocs field for sections which have associated
	secondary relocs.
	* elfcode.h (elf_write_relocs): Only call write_secondary_relocs
	on sections which have associated secondary relocs.
2020-08-20 10:19:47 +01:00
GDB Administrator
c51ed085ab Automatic date update in version.in 2020-08-20 00:00:13 +00:00
GDB Administrator
6cdb985c45 Automatic date update in version.in 2020-08-19 00:00:06 +00:00
GDB Administrator
d2bb907b8b Automatic date update in version.in 2020-08-18 00:00:07 +00:00
GDB Administrator
d3267445af Automatic date update in version.in 2020-08-17 00:00:07 +00:00
GDB Administrator
878000178e Automatic date update in version.in 2020-08-16 00:00:06 +00:00
Alan Modra
10885e2436 Set SEC_SMALL_DATA on small common
Unlike the previous patch setting SEC_SMALL_DATA during
elf_backend_symbol_processing, this patch is mostly cosmetic.

	* elf32-frv.c (elf32_frv_add_symbol_hook): Set SEC_SMALL_DATA on
	small common section.
	* elf32-m32r.c (m32r_elf_add_symbol_hook): Likewise.
	* elf32-microblaze.c (microblaze_elf_add_symbol_hook): Likewise.
	* elf32-nds32.c (nds32_elf_add_symbol_hook): Likewise.
	* elf32-nios2.c (nios2_elf_add_symbol_hook): Likewise.
	* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
	* elf32-score.c (s3_bfd_score_elf_add_symbol_hook): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_add_symbol_hook): Likewise.
	* elf32-tic6x.c (elf32_tic6x_add_symbol_hook): Likewise.
	* elf32-v850.c (v850_elf_check_relocs): Likewise.
	(v850_elf_add_symbol_hook): Likewise.
	* elf64-alpha.c (elf64_alpha_add_symbol_hook): Likewise.
	* elf64-ia64-vms.c (elf64_ia64_add_symbol_hook): Likewise.
	* elfnn-ia64.c (elfNN_ia64_add_symbol_hook): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_add_symbol_hook): Likewise.
2020-08-15 15:14:42 +09:30
Alan Modra
4d1823674e PR26389, nm prints "c" for a common symbol with -flto and -fcommon
git commit 49d9fd42ac chose to make nm print 'C' for the normal
common section, and 'c' for other commons.  This was an attempt to
make common symbols in .scommon and other small common sections show
a 'c' type without a section name comparison, but it failed for
nm --plugin on lto objects where normal common symbols are stashed in
a "plug" section.  It's also wrong for large common symbols.  So
instead set SEC_SMALL_DATA on sections created for small commons, and
key off that flag to show 'c' type.  If your ELF target doesn't have
an elf_backend_symbol_processing function, then you won't see 'c' for
symbols in .scommon.

Note that due to bfd_decode_symclass decoding common symbols without
a chance for coff_section_type to treat .scommon specially, then
having .scommon in the array of special sections handled by
coff_section_type prior to 49d9fd42ac was entirely ineffective.
That fact escaped me when writing 49d9fd42ac.  Unless .scommon
didn't have SEC_IS_COMMON set, which would be a little weird.

	PR 26389
	* syms.c (bfd_decode_symclass): Choose 'c' for commons only when
	SEC_SMALL_DATA.
	* elf32-m32r.c (_bfd_m32r_elf_symbol_processing): Set SEC_SMALL_DATA
	on small common section.
	* elf32-score.c (s3_bfd_score_elf_symbol_processing): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_symbol_processing): Likewise.
	* elf32-tic6x.c (elf32_tic6x_symbol_processing): Likewise.
	* elf32-v850.c (v850_elf_symbol_processing): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_symbol_processing): Likewise.
	* ecoff.c (ecoff_set_symbol_info, ecoff_link_add_externals): Likewise.
2020-08-15 14:16:02 +09:30
GDB Administrator
a9ca57d09a Automatic date update in version.in 2020-08-15 00:00:07 +00:00
Alan Modra
19bddbe95c Allow larger bfd_default_hash_table_size
* hash.c (bfd_hash_set_default_size): Use higher_prime_number
	rather than another copy of primes.  Increase maximum default
	size allowed.
2020-08-14 21:37:24 +09:30
GDB Administrator
dac736f6a1 Automatic date update in version.in 2020-08-14 00:00:07 +00:00
Alan Modra
73d0dc162e Obsolete ia64
* config.bfd: Obsolete ia64*-*-*.
2020-08-13 14:13:43 +09:30
Alan Modra
2b6ba032ad Obsolete arm-symbianelf
* config.bfd: Obsolete arm*-*-symbianelf*.
2020-08-13 09:58:13 +09:30
GDB Administrator
e5a59fd37e Automatic date update in version.in 2020-08-13 00:00:07 +00:00
Alan Modra
6738c8a7c9 PowerPC64 --no-pcrel-optimize
This new option effectively ignores R_PPC64_PCREL_OPT, disabling the
optimization of instructions marked by that relocation.  The patch
also disables GOT indirect to GOT/TOC pointer relative code editing
when --no-toc-optimize.

bfd/
	* elf64-ppc.h (struct ppc64_elf_params): Add no_pcrel_opt.
	* elf64-ppc.c (ppc64_elf_relocate_section): Disable GOT reloc
	optimizations when --no-toc-optimize.  Disable R_PPC64_PCREL_OPT
	optimization when --no-pcrel-optimize.
ld/
	* emultempl/ppc64elf.em (params): Init new field.
	(enum ppc64_opt): Add OPTION_NO_PCREL_OPT.
	(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS),
	(PARSE_AND_LIST_ARGS_CASES): Support --no-pcrel-optimize.
2020-08-13 08:10:18 +09:30
Alan Modra
75e100a30d PR26348, Malloc error in write_zeros
This adds a few more sanity checks on ELF objects, and a BFD flag to
disable objcopy and strip when fuzzed input files belong in the "too
hard" basket.

bfd/
	PR 26348
	* bfd.c (struct bfd): Add read_only.
	* elfcode.h (elf_swap_shdr_in): Test both sh_offset and sh_size.
	Set read_only on warning.
	(elf_object_p): Sanity check program header alignment.  Set
	read_only on warning.
	* bfd-in2.h: Regenerate.
binutils/
	PR 26348
	* objcopy.c (copy_object): Report file name with endian error.
	Error and return on abfd->read_only.
2020-08-13 08:09:08 +09:30
Jon Turney
2fef937354
Fix signedness comparison warning in elfcore_grok_win32pstatus()
bfd/ChangeLog:

2020-08-12  Jon Turney  <jon.turney@dronecode.org.uk>

	* elf.c (elfcore_grok_win32pstatus): Use unsigned int for
	win32pstatus note type to avoid signedness comparison warning.
2020-08-12 16:39:25 +01:00
Jon Turney
404ec93359
Only warn about malformed win32pstatus notes
bfd/ChangeLog:

2020-07-21  Jon Turney  <jon.turney@dronecode.org.uk>

	* elf.c (elfcore_grok_win32pstatus): Warn on malformed
	win32pstatus notes, and return TRUE so we continue rather than
	stopping as if it was an error.
2020-08-12 15:08:30 +01:00
Jon Turney
d61f3d0383
Add handling for 64-bit module addresses in Cygwin core dumps
bfd/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

	* elf.c (elfcore_grok_win32pstatus): Handle NOTE_INFO_MODULE64.
2020-08-12 15:08:28 +01:00
Jon Turney
04ec0fa297
Refine size constraints applied to win32pstatus ELF notes
Don't reject any win32pstatus notes smaller than minimum size for a
NOTE_INFO_THREAD.

This only happens to work because the Cygwin dumper tool currently
writes all these notes as the largest size of the union, (which wastes
lots of space in the core dump).

Instead, apply the appropriate size constraint for each win32pstatus
note type.

bfd/ChangeLog:

2020-07-11  Jon Turney  <jon.turney@dronecode.org.uk>

	* elf.c (elfcore_grok_win32pstatus): Don't apply size constraint
	for NOTE_INFO_THREAD to all win32pstatus ELF notes, instead apply
	appropriate size constraint for each win32pstatus note type.
2020-08-12 15:08:27 +01:00
Jon Turney
03c29a6faf
Don't hardcode CONTEXT size for a NOTE_INFO_THREAD win32pstatus note
Don't hardcode the size of the Win32 API thread CONTEXT type read from a
NOTE_INFO_THREAD win32pstatus note (since it's different on different
architectures).

bfd/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

	* elf.c (elfcore_grok_win32pstatus): Don't hardcode the size of
	the Win32 API thread CONTEXT type read from a NOTE_INFO_THREAD
	win32pstatus note.
2020-08-12 15:08:25 +01:00
Jon Turney
8fbac78b14
Define constants for win32pstatus ELF notes
Define constants for win32pstatus ELF notes, as they were prior to
4a6636fb, and say what specifies them.

bfd/ChangeLog:

2020-07-11  Jon Turney  <jon.turney@dronecode.org.uk>

	* elf.c (NOTE_INFO{_PROCESS,_THREAD,_MODULE}): Define.
	(elfcore_grok_win32pstatus): Use.
2020-08-12 15:08:23 +01:00
Jon Turney
ff2084b9ef
Read tid from correct offset in win32pstatus NOTE_INFO_THREAD
Fix the offset used to read the tid from a win32pstatus ELF note.

This probably meant that registers were only being correctly recovered
from the core dump for the current thread.

It looks like this has beeen incorrect since 4a6636fb.

Also fix offsets used in NOTE_INFO_PROCESS (which is not actually
generated by the Cygwin dumper tool).

Also improve comment.

bfd/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

	* elf.c (elfcore_grok_win32pstatus): Fix the offset used to read
	the tid from a win32pstatus NOTE_INFO_THREAD ELF note.  Fix
	offsets used to read NOTE_INFO_PROCESS.
2020-08-12 15:08:21 +01:00
Nick Clifton
79ddc88496 Updated Serbian and Russian translations for various sub-directories 2020-08-12 11:25:38 +01:00
GDB Administrator
8989de8220 Automatic date update in version.in 2020-08-12 00:00:07 +00:00
GDB Administrator
0110183789 Automatic date update in version.in 2020-08-11 00:00:07 +00:00
GDB Administrator
40f3419a81 Automatic date update in version.in 2020-08-10 00:00:09 +00:00
GDB Administrator
0770687e1e Automatic date update in version.in 2020-08-09 00:00:08 +00:00
GDB Administrator
bc853409cc Automatic date update in version.in 2020-08-08 00:00:06 +00:00
David Faust
d844f10ac2 bpf: fix false overflow in eBPF ELF backend linker
When performing DISP{16,32} relocations, the eBPF ELF backend linker
needs to convert the relocation from an address into a signed number
of 64-bit words (minus one) to jump.

Because of this unsigned-to-signed conversion, special care needs to
be taken when dividing to ensure the sign bits remain correct.
Otherwise, a false relocation overflow error can be triggered.

bfd/ChangeLog

2020-08-07  David Faust  <david.faust@oracle.com>

	* elf64-bpf.c (bpf_elf_relocate_section): Ensure signed division for
	DISP16 and DISP32 relocations.

ld/ChangeLog

2020-08-07  David Faust  <david.faust@oracle.com>

	* testsuite/ld-bpf/call-3.s: New file.
	* testsuite/ld-bpf/call-3.d: Likewise.
2020-08-07 20:36:47 +02:00
GDB Administrator
939bf1224d Automatic date update in version.in 2020-08-07 00:00:09 +00:00
David Faust
3ee9565c95 bpf: relocation fixes for eBPF ELF backend
The eBPF ELF backend was not properly recording relocation addends
during installation, nor reading and applying them when performing
the final relocation. This lead to various issues with incorrect
relocations.

These issues are fixed with a new howto special function to install
the relocations, and updates to bpf_elf_relocate_section to read and
use the addends as recorded in the input_bfd.

bfd/ChangeLog

2020-08-05  David Faust  <david.faust@oracle.com>

	* elf64-bpf.c (bpf_elf_generic_reloc): New function.
	(bpf_elf_howto_table): Use it here.
	(bpf_elf_relocate_section): Use addends recorded in input_bfd for
	instruction and data relocations.

ld/ChangeLog

2020-08-05  David Faust  <david.faust@oracle.com>

	* testsuite/ld-bpf/call-2.s: New file.
	* testsuite/ld-bpf/call-2.d: Likewise.
	* testsuite/ld-bpf/reloc-data-be.d: Likewise.
	* testsuite/ld-bpf/reloc-data-le.d: Likewise.
	* testsuite/ld-bpf/reloc-data.s: Likewise.
	* testsuite/ld-bpf/reloc-insn-external-be.d: Likewise.
	* testsuite/ld-bpf/reloc-insn-external-le.d: Likewise.
	* testsuite/ld-bpf/reloc-insn-external.s: Likewise.
	* testsuite/ld-bpf/reloc-insn32-be.d: Likewise.
	* testsuite/ld-bpf/reloc-insn32-le.d: Likewise.
	* testsuite/ld-bpf/reloc-insn32.s: Likewise.
	* testsuite/ld-bpf/reloc-insn64-be.d: Likewise.
	* testsuite/ld-bpf/reloc-insn64-le.d: Likewise.
	* testsuite/ld-bpf/reloc-insn64.s: Likewise.
2020-08-06 15:14:54 +02:00
GDB Administrator
f5750f89e3 Automatic date update in version.in 2020-08-06 00:00:06 +00:00
GDB Administrator
b7563b2492 Automatic date update in version.in 2020-08-05 00:00:07 +00:00
GDB Administrator
31be51609c Automatic date update in version.in 2020-08-04 00:00:06 +00:00