Commit Graph

17496 Commits

Author SHA1 Message Date
GDB Administrator
ef485e453a Automatic date update in version.in 2022-04-05 00:00:06 +00:00
GDB Administrator
cf78890fd4 Automatic date update in version.in 2022-04-04 00:00:06 +00:00
Alan Modra
9751574e09 Move microblaze relax info to target specific data
Target specific data shouldn't be put in struct bfd_section.

	* section.c (struct bfd_section): Delete relax and relax_count.
	(BFD_FAKE_SECTION): Adjust to suit.
	(struct relax_table): Move to..
	* elf32-microblaze.c (struct relax_table): ..here.
	(struct _microblaze_elf_section_data): New.
	(microblaze_elf_section_data): Define.
	(microblaze_elf_new_section_hook): New function.
	(bfd_elf32_new_section_hook): Define.
	(calc_fixup): Return a size_t.  Adjust to suit new location of
	relax and relax_count.
	(microblaze_elf_relax_section): Adjust to suit new location of
	relax and relax_count.  Make some variables size_t.
	* bfd-in2.h: Regenerate.
2022-04-03 21:34:53 +09:30
Alan Modra
924cf858c9 Revert commit 240d6706c6
PR 28592
	PR 15994
	PR 15935
	* dwarf2.c (lookup_address_in_line_info_table): Return bool rather
	than a range.
	(comp_unit_find_nearest_line): Likewise.  Return true if function
	info found without line info.
	(_bfd_dwarf2_find_nearest_line): Revert range handling code.
2022-04-03 20:56:17 +09:30
Alan Modra
2b2463e2b0 Regen bfd po/SRC-POTFILES.in 2022-04-03 20:56:17 +09:30
GDB Administrator
f1feb9c020 Automatic date update in version.in 2022-04-03 00:00:07 +00:00
GDB Administrator
25eb664374 Automatic date update in version.in 2022-04-02 00:00:06 +00:00
John Baldwin
b5c2367c3a Use pseudosections for NT_FREEBSD_X86_SEGBASES core dump notes.
This includes adding pseudosections when reading a core dump as well
as support for writing out a core dump note from a pseudosection.

bfd/ChangeLog:

	* elf-bfd.h (elfcore_write_x86_segbases): New.
	* elf.c (elfcore_grok_freebsd_note): Add pseudosections for
	NT_FREEBSD_X86_SEGBASES register notes.
	(elfcore_write_x86_segbases): New.
	(elfcore_write_register_note): Write NT_FREEBSD_X86_SEGBASES
	register notes.
2022-04-01 13:16:46 -07:00
John Baldwin
e330d4c033 elfcore_grok_freebsd_note: Remove checks of note->namesz.
This function is only called if the note name is "FreeBSD", so
checking the name size is unnecessary.

bfd/ChangeLog:

	* elf.c (elfcore_grok_freebsd_note): Remove checks for namesz.
2022-04-01 13:16:46 -07:00
H.J. Lu
801a7eab11 x86: Remove bfd_arch_l1om and bfd_arch_k1om
Remove bfd_arch_l1om and bfd_arch_k1om since L1OM/K1OM support has been
removed from gas, ld and opcodes.

bfd/

	* Makefile.am (ALL_MACHINES): Remove cpu-l1om.lo and cpu-k1om.lo.
	(ALL_MACHINES_CFILES): Remove cpu-l1om.c and cpu-k1om.c.
	* archures.c (bfd_mach_l1om): Removed.
	(bfd_mach_l1om_intel_syntax): Likewise.
	(bfd_mach_k1om): Likewise.
	(bfd_mach_k1om_intel_syntax): Likewise.
	(bfd_k1om_arch): Likewise.
	(bfd_l1om_arch): Likewise.
	(bfd_archures_list): Remove bfd_k1om_arch and bfd_l1om_arch
	references.
	* config.bfd (targ_selvecs): Remove l1om_elf64_vec.
	l1om_elf64_fbsd_vec, k1om_elf64_vec and k1om_elf64_fbsd_vec.
	(targ_archs): Remove bfd_l1om_arch and bfd_k1om_arch.
	* configure.ac (k1om_elf64_vec): Removed.
	(k1om_elf64_fbsd_vec): Likewise.
	(l1om_elf64_vec): Likewise.
	(l1om_elf64_fbsd_vec): Likewise.
	* cpu-k1om.c: Removed.
	* cpu-l1om.c: Likewise.
	* elf64-x86-64.c (elf64_l1om_elf_object_p): Removed.
	(elf64_k1om_elf_object_p): Likewise.
	(l1om_elf64_vec): Removed.
	(l1om_elf64_fbsd_vec): Likewise.
	(k1om_elf64_vec): Likewise.
	(k1om_elf64_fbsd_vec): Likewise.
	(ELF_TARGET_OS): Undefine.
	* targets.c (_bfd_target_vector): Remove k1om_elf64_vec,
	k1om_elf64_fbsd_vec, l1om_elf64_vec and l1om_elf64_fbsd_vec.
	* Makefile.in: Regenerate.
	* bfd-in2.h: Likewise.
	* configure: Likewise.

opcodes/

	* configure.ac: Remove bfd_arch_l1om/bfd_arch_k1om references.
	* disassemble.c (disassembler): Likewise.
	* configure: Regenerate.
2022-03-31 18:58:53 -07:00
GDB Administrator
d7abb2c4bd Automatic date update in version.in 2022-04-01 00:00:12 +00:00
GDB Administrator
07e9e57ca6 Automatic date update in version.in 2022-03-31 00:00:06 +00:00
GDB Administrator
c09115ad6e Automatic date update in version.in 2022-03-30 00:00:07 +00:00
Jan Beulich
ddfc2f56d5 bfd/Dwarf2: gas doesn't mangle names
Include the language identifier emitted by gas in the set of ones where
no mangled names are expected. Even if there could be "hand-mangled"
names, gas doesn't emit DW_AT_linkage_name in the first place.
2022-03-29 08:19:14 +02:00
Jan Beulich
f3bbd5c389 bfd/Dwarf2: make find-nearest-line returned function name consistent
Prior to entering the enclosing "else if()" the earlier associated if()
checks function->is_linkage and, if set, uses function->name. The
comment in patch context precedes (and explains) the setting
function->is_linkage. Yet with the flag set, we should then also return
the function name, just like said earlier if() would do when we came
here a 2nd time for the same "addr". And indeed passing the same address
twice on addr2line's command line would resolve the function for the 2nd
instance, but not for the 1st (if this code path is taken). (This,
obviously, is particularly relevant when there's no ELF symbol table in
the first place, like would be the case - naturally - in PE/COFF
binaries, for example.)
2022-03-29 08:18:49 +02:00
GDB Administrator
4a02e01a71 Automatic date update in version.in 2022-03-29 00:00:07 +00:00
GDB Administrator
b8e92c571b Automatic date update in version.in 2022-03-28 00:00:05 +00:00
GDB Administrator
5cf8c5926e Automatic date update in version.in 2022-03-27 00:00:06 +00:00
GDB Administrator
520a6a7e3a Automatic date update in version.in 2022-03-26 00:00:07 +00:00
Nick Alcock
caf606c90d libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case
My previous nm patch handled all cases but one -- if the user set NM in
the environment to a path which contained an option, libtool's nm
detection tries to run nm against a copy of nm with the options in it:
e.g. if NM was set to "nm --blargle", and nm was found in /usr/bin, the
test would try to run "/usr/bin/nm --blargle /usr/bin/nm --blargle".
This is unlikely to be desirable: in this case we should run
"/usr/bin/nm --blargle /usr/bin/nm".

Furthermore, as part of this nm has to detect when the passed-in $NM
contains a path, and in that case avoid doing a path search itself.
This too was thrown off if an option contained something that looked
like a path, e.g. NM="nm -B../prev-gcc"; libtool then tries to run
"nm -B../prev-gcc nm" which rarely works well (and indeed it looks
to see whether that nm exists, finds it doesn't, and wrongly concludes
that nm -p or whatever does not work).

Fix all of these by clipping all options (defined as everything
including and after the first " -") before deciding whether nm
contains a path (but not using the clipped value for anything else),
and then removing all options from the path-modified nm before
looking to see whether that nm existed.

NM=my-nm now does a path search and runs e.g.
  /usr/bin/my-nm -B /usr/bin/my-nm

NM=/usr/bin/my-nm now avoids a path search and runs e.g.
  /usr/bin/my-nm -B /usr/bin/my-nm

NM="my-nm -p../wombat" now does a path search and runs e.g.
  /usr/bin/my-nm -p../wombat -B /usr/bin/my-nm

NM="../prev-binutils/new-nm -B../prev-gcc" now avoids a path search:
  ../prev-binutils/my-nm -B../prev-gcc -B ../prev-binutils/my-nm

This seems to be all combinations, including those used by GCC bootstrap
(which, before this commit, fails to bootstrap when configured
--with-build-config=bootstrap-lto, because the lto plugin is now using
--export-symbols-regex, which requires libtool to find a working nm,
while also using -B../prev-gcc to point at the lto plugin associated
with the GCC just built.)

Regenerate all affected configure scripts.

	* libtool.m4 (LT_PATH_NM): Handle user-specified NM with
	options, including options containing paths.
2022-03-25 12:02:35 +00:00
GDB Administrator
891172d1d4 Automatic date update in version.in 2022-03-25 00:00:07 +00:00
GDB Administrator
21152986f1 Automatic date update in version.in 2022-03-24 00:00:07 +00:00
Jan Beulich
36e2d65d26 ELF32: don't silently truncate relocation addends
At least x86-64's x32 sub-mode and RISC-V's 32-bit mode calculate
addends as 64-bit values, but store them in signed 32-bit fields when
generating the file without encountering any earlier error. When the
relocated field is a 64-bit one, the value resulting after processing
the relocation record when linking (or the latest when loading) may
thus be wrong due to the truncation.

With the code change in place, one x32 testcase actually triggers the
new diagnostic. That one case of too large a (negative) addend is being
adjusted alongside the addition of a new testcase to actually trigger
the new error. (Note that due to internal BFD behavior the relocation in
.data doesn't get processed anymore after the errors in .text.)

Note that in principle it is possible to express 64-bit relocations in
ELF32, but this would require .rel relocations, i.e. with the addend
stored in the 64-bit field being relocated. But I guess it would be a
lot of effort for little gain to actually support this.
2022-03-23 08:43:13 +01:00
GDB Administrator
9457d59e9d Automatic date update in version.in 2022-03-23 00:00:08 +00:00
Steiner H Gunderson
86ed2a5eae Fix return code in _bfd_dwarf2_find_nearest_line().
* dwarf2.c (_bfd_dwarf2_find_nearest_line): if a function name is
	found, but no line number info, then return a result of 2.
2022-03-22 15:32:32 +00:00
GDB Administrator
389eb00afc Automatic date update in version.in 2022-03-22 00:00:06 +00:00
Steiner H Gunderson
30cbd32aec Reduce O(n2) performance overhead when parsing DWARF unit information.
PR 28978
	* dwarf2.c (scan_unit_for_symbols): When performing second pass,
	check to see if the function or variable being processed is the
	same as the previous one.
2022-03-21 14:29:12 +00:00
GDB Administrator
692e92c5af Automatic date update in version.in 2022-03-21 00:00:07 +00:00
liuzhensong
d218dba3f4 LoongArch: Fix LD check fails.
Some test cases about ifunc.

  bfd/
    * elfnn-loongarch.c
    * elfxx-loongarch.h

   === ld Summary ===
  of expected passes             1430
  of expected failures           11
  of untested testcases          1
  of unsupported tests           154
2022-03-20 09:37:12 +08:00
liuzhensong
3b14682a43 LoongArch: Update ABI eflag in elf header.
Update LoongArch ABI eflag in elf header.
    ilp32s  0x5
    ilp32f  0x6
    ilp32d  0x7
    lp64s   0x1
    lp64f   0x2
    lp64d   0x3

  bfd/
    * elfnn-loongarch.c Check object flags while ld.

  gas/
    * tc-loongarch.c Write eflag to elf header.

  include/elf
        * loongarch.h Define ABI number.
2022-03-20 09:37:12 +08:00
liuzhensong
748594bc07 LoongArch: Use functions instead of magic numbers.
Replace the magic numbers in gas(tc-loongarch.c) and
  bfd(elfnn-loongarch.c) with the functions defined in
  the howto table(elfxx-loongarch.c).

  gas/
    * config/tc-loongarch.c: use functions.

  bfd/
    * elfnn-loongarch.c: use functions.
    * elfxx-loongarch.c: define functions.
    * elfxx-loongarch.h
2022-03-20 09:37:12 +08:00
GDB Administrator
1ab7a698a8 Automatic date update in version.in 2022-03-20 00:00:06 +00:00
GDB Administrator
03a5735dbd Automatic date update in version.in 2022-03-19 00:00:06 +00:00
Viorel Preoteasa
a747a286b9 Fix ld-arm bug in encoding of blx calls jumping from thumb to arm instructions
PR 28924
	* elf32-arm.c (THM_MAX_FWD_BRANCH_OFFSET): Fix definition.
	(THM2_MAX_FWD_BRANCH_OFFSET): Likewise.
2022-03-18 15:32:28 +00:00
Tsukasa OI
41d6ac5da6 RISC-V: Cache management instructions
This commit adds 'Zicbom' / 'Zicboz' instructions.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_multi_subset_supports): Add handling for
	new instruction classes.

include/ChangeLog:

	* opcode/riscv-opc.h (MATCH_CBO_CLEAN, MASK_CBO_CLEAN,
	MATCH_CBO_FLUSH, MASK_CBO_FLUSH, MATCH_CBO_INVAL,
	MASK_CBO_INVAL, MATCH_CBO_ZERO, MASK_CBO_ZERO): New macros.
	* opcode/riscv.h (enum riscv_insn_class): Add new instruction
	classes INSN_CLASS_ZICBOM and INSN_CLASS_ZICBOZ.

opcodes/ChangeLog:

	* riscv-opc.c (riscv_opcodes): Add cache-block management
	instructions.
2022-03-18 15:32:22 +08:00
Tsukasa OI
3b374308d3 RISC-V: Prefetch hint instructions and operand set
This commit adds 'Zicbop' hint instructions.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_multi_subset_supports): Add handling for
	new instruction class.

gas/ChangeLog:

	* config/tc-riscv.c (riscv_ip): Add handling for new operand
	type 'f' (32-byte aligned pseudo S-type immediate for prefetch
	hints).
	(validate_riscv_insn): Likewise.

include/ChangeLog:

	* opcode/riscv-opc.h (MATCH_PREFETCH_I, MASK_PREFETCH_I,
	MATCH_PREFETCH_R, MASK_PREFETCH_R, MATCH_PREFETCH_W,
	MASK_PREFETCH_W): New macros.
	* opcode/riscv.h (enum riscv_insn_class): Add new instruction
	class INSN_CLASS_ZICBOP.

opcodes/ChangeLog:

	* riscv-dis.c (print_insn_args): Add handling for new operand
	type.
	* riscv-opc.c (riscv_opcodes): Add prefetch hint instructions.
2022-03-18 15:32:16 +08:00
GDB Administrator
9ef0cc6c3a Automatic date update in version.in 2022-03-18 00:00:08 +00:00
Alan Modra
c9178f285a ubsan: Null dereference in parse_module
* vms-alpha.c (parse_module): Sanity check that DST__K_RTNBEG
	has set module->func_table for DST__K_RTNEND.  Check return
	of bfd_zalloc.
2022-03-17 21:32:44 +10:30
Alan Modra
98c445c0b9 asan: Buffer overflow in evax_bfd_print_dst
With "name" a char*, the length at name[0] might be negative, escaping
buffer limit checks.

	* vms-alpha.c (evax_bfd_print_dst): Make name an unsigned char*.
	(evax_bfd_print_emh): Likewise.
2022-03-17 21:32:44 +10:30
Alan Modra
0c6a3cd135 asan: Buffer overflow in som_set_reloc_info
* som.c (som_set_reloc_info): Add symcount parameter.  Don't
	access symbols past symcount.  Don't access fixup past end_fixups.
	(som_slurp_reloc_table): Adjust som_set_reloc_info calls.
2022-03-17 21:32:44 +10:30
Alan Modra
c55f2b9c61 Re: asan: buffer overflow in peXXigen.c
In the process of fixing a buffer overflow in commit fe69d4fcf0,
I managed to introduce a fairly obvious NULL pointer dereference..

	* peXXigen.c (_bfd_XX_bfd_copy_private_bfd_data_common): Don't
	segfault on not finding section.  Wrap overlong lines.
2022-03-17 21:32:44 +10:30
Alan Modra
df573325cb Re: bfd: add AMDGCN architecture
* po/SRC-POTFILES.in: Regenerate.
2022-03-17 21:32:43 +10:30
GDB Administrator
4417601f70 Automatic date update in version.in 2022-03-17 00:00:16 +00:00
Simon Marchi
978602e83f bfd: add AMDGCN architecture
Add support for the AMDGCN architecture to BFD.

This is the bare minimum to get

  $ ./configure --target=amdgcn-hsa-amdhsa --disable-gas
  $ make all-binutils

working later in this series.

The specific AMDGCN models added here are a bit arbitrary, based on
what we intend to initially support in GDB.  This list will need to be
updated in the future anyway.  The complete up-to-date list of existing
AMDGPU models can be found here:

  https://llvm.org/docs/AMDGPUUsage.html#processors

The ELF format for this architecture is documented here:

  https://llvm.org/docs/AMDGPUUsage.html#elf-code-object

The flags for the "HSA" OS ABI are properly versioned and documented on
that page.  But the NONE, PAL and MESA3D OS ABIs are not well documented
nor versioned.  Taking a peek at the LLVM source code, we see that they
encode their flags the same way as HSA v3.  For example, for PAL:

  c8b614cd74/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (L601)

So at least, we know that all AMDGPU objects (of which AMDGCN objects
are a subset of) at the time of writing encode the specific GPU model in
the EF_AMDGPU_MACH field of e_flags.

bfd/ChangeLog:

	* Makefile.am (ALL_MACHINES, ALL_MACHINES_CFILES):
	Add cpu-amdgcn.c.
	(BFD64_BACKENDS): Add elf64-amdgcn.lo.
	(BFD64_BACKENDS_CFILES): Add elf64-amdgcn.c.
	* Makefile.in: Re-generate.
	* cpu-amdgcn.c: New.
	* elf64-amdgcn.c: New.
	* archures.c (bfd_architecture): Add bfd_arch_amdgcn and related
	mach defines.
	(bfd_amdgcn_arch): New.
	(bfd_archures_list): Add bfd_amdgcn_arch.
	* bfd-in2.h: Re-generate.
	* config.bfd: Handle amdgcn* target.
	* configure.ac: Handle amdgcn_elf64_le_vec.
	* configure: Re-generate.
	* elf-bfd.h (elf_target_id): Add AMDGCN_ELF_DATA.
	* targets.c (amdgcn_elf64_le_vec): New.
	(_bfd_target_vector): Add amdgcn_elf64_le_vec.

include/ChangeLog:

	* elf/amdgpu.h: New.
	* elf/common.h (ELFOSABI_AMDGPU_HSA): Add.

Change-Id: I969f7b14960797e88891c308749a6e341eece5b2
2022-03-16 09:00:27 -04:00
GDB Administrator
22546800ad Automatic date update in version.in 2022-03-16 00:00:23 +00:00
GDB Administrator
bf573a0cc6 Automatic date update in version.in 2022-03-15 00:00:27 +00:00
GDB Administrator
d4661bf0e9 Automatic date update in version.in 2022-03-14 00:00:15 +00:00
GDB Administrator
4f4a30bee6 Automatic date update in version.in 2022-03-13 00:00:23 +00:00
GDB Administrator
9fb67c2345 Automatic date update in version.in 2022-03-12 00:00:14 +00:00
GDB Administrator
a655f19af9 Automatic date update in version.in 2022-03-11 00:00:26 +00:00