Commit graph

19042 commits

Author SHA1 Message Date
GDB Administrator
1678a15b69 Automatic date update in version.in 2024-03-29 00:00:35 +00:00
GDB Administrator
ff87ff7dc9 Automatic date update in version.in 2024-03-28 00:00:57 +00:00
GDB Administrator
db3bcacad0 Automatic date update in version.in 2024-03-27 00:00:43 +00:00
H.J. Lu
bb9a951fab Don't claim a fat IR object if no IR object should be claimed
When the linker sees an input object containing nothing but IR during
rescan, it should ignore it (LTO phase is over).  But if the input object
is a fat IR object, which has non-IR code as well, it should be used to
resolve references as if it did not contain any IR at all.  This patch
adds lto_type to bfd and linker avoids claiming a fat IR object if no IR
object should be claimed.

bfd/

	PR ld/23935
	* archive.c (_bfd_compute_and_write_armap): Check bfd_get_lto_type
	instead of lto_slim_object.
	* elflink.c (elf_link_add_object_symbols): Likewise.
	* bfd.c (bfd_lto_object_type): New.
	(bfd): Remove lto_slim_object and add lto_type.
	(bfd_get_lto_type): New function.
	* elf.c (lto_section): Removed.
	(_bfd_elf_make_section_from_shdr): Don't set lto_slim_object.
	* format.c: (lto_section): New.
	(bfd_set_lto_type): New function.
	(bfd_check_format_matches): Call bfd_set_lto_type.
	* bfd-in2.h: Regenerated.

binutils/

	PR ld/23935
	* nm.c (display_rel_file): Check bfd_get_lto_type instead of
	lto_slim_object.

ld/

	PR ld/23935
	* ldmain.c (add_archive_element): Don't claim a fat IR object if
	no IR object should be claimed.
	* testsuite/ld-plugin/lto.exp (pr20103): Adjust fat IR test.
	Add PR ld/23935 test.
	* testsuite/ld-plugin/pr23935a.c: New file.
	* testsuite/ld-plugin/pr23935b.c: Likewise.
2024-03-26 07:17:17 -07:00
GDB Administrator
00bd12130c Automatic date update in version.in 2024-03-26 00:01:06 +00:00
Andrew Burgess
f9ee45c3a9 bfd: make _bfd_section_size_insane part of the public API
If a BFD user is making use of a function like
bfd_get_section_contents to read a section into a pre-allocated
buffer, then that BFD user might also want to make use of
_bfd_section_size_insane prior to allocating the buffer they intend to
use in order to validate that the buffer size that plan to allocate is
sane.

This commit makes _bfd_section_size_insane public, by renaming it to
bfd_section_size_insane.

I've updated the existing uses within bfd/, I don't believe this
function is used outside of bfd/ currently.

One place that I plan to make use of this function is in
gdb/gdb_bfd.c, in the function gdb_bfd_get_full_section_contents.
This change isn't included in this commit, but will come later if/when
this has been merged into bfd.

There should be no change in behaviour after this commit.

bfd/

	* bfd-in2.h (bfd_section_size_insane): Add declaration.
	* compress.c (bfd_get_full_section_contents): Update for new name
	of _bfd_section_size_insane.
	(bfd_init_section_compress_status): Likewise.
	* dwarf2.c (read_section): Likewise.
	(_bfd_dwarf2_slurp_debug_info): Likewise.
	* libbfd.h (_bfd_section_size_insane): Remove declaration.
	* section.c (_bfd_section_size_insane): Rename to ...
	(bfd_section_size_insane): ... this.

binutils/

	* readelf.c (uncompress_section_contents): Update comment to
	account for new name of _bfd_section_size_insane.
2024-03-25 18:31:38 +00:00
GDB Administrator
121a4d3d80 Automatic date update in version.in 2024-03-25 00:00:23 +00:00
GDB Administrator
ec6f962151 Automatic date update in version.in 2024-03-24 00:00:33 +00:00
GDB Administrator
efd58a4379 Automatic date update in version.in 2024-03-23 00:00:33 +00:00
GDB Administrator
40dcb60aff Automatic date update in version.in 2024-03-22 00:00:33 +00:00
GDB Administrator
80313193b0 Automatic date update in version.in 2024-03-21 00:01:00 +00:00
GDB Administrator
8f39d04b97 Automatic date update in version.in 2024-03-20 00:00:44 +00:00
Nick Clifton
2c16eb1d83 Fix free of unallocated memory in the BFD library's compression code.
PR 31455
2024-03-19 12:48:04 +00:00
mengqinggang
97ce787044 LoongArch: Add relaxation for R_LARCH_CALL36
This relaxation is effective for both macro instructions (call36, tail36)
and explicit relocation instructions (pcaddu18i + jirl).

call36 f	  ->	bl f
  R_LARCH_CALL36  ->	  R_LARCH_B26

tail36 $t0, f	  ->	b f
  R_LARCH_CALL36  ->	  R_LARCH_B26
2024-03-19 14:14:47 +08:00
GDB Administrator
b42aa684f6 Automatic date update in version.in 2024-03-19 00:00:22 +00:00
Clément Chigot
d0eb2625bf bfd: add missing include <time.h>
bdfio.c is defining bfd_get_current_time which is returning a time_t.
This type is defined in time.h and thus, must be included in bfd main
header to avoid undefined type when include bfd.h.

Note that most of the time, <time.h> is pulled by <sys/stat.h> already
included in bfd.h. That's why it went unnoticed.
2024-03-18 12:53:42 +01:00
Nick Clifton
6549a232d2 Fix compiling bfd/vms-lib.c for a 32-bit host. 2024-03-18 10:26:16 +00:00
GDB Administrator
afa04bdc56 Automatic date update in version.in 2024-03-18 00:00:39 +00:00
GDB Administrator
04d7f8a5bc Automatic date update in version.in 2024-03-17 00:00:27 +00:00
GDB Administrator
2b53203690 Automatic date update in version.in 2024-03-16 00:00:24 +00:00
GDB Administrator
7bb2b94933 Automatic date update in version.in 2024-03-15 00:00:35 +00:00
GDB Administrator
3a4c6f1aa9 Automatic date update in version.in 2024-03-14 00:01:12 +00:00
H.J. Lu
4810a2d92b bfd: Use size_t in the BFD mmap interface
Change the size type in the BFD mmap interface from bfd_size_type to
size_t to be consistent with the size type of the host mmap interface.

	* bfdio.c (bfd_iovec): Change the bmmap size type to size_t.
	(bfd_mmap): Likewise.
	(memory_bmmap): Likewise.
	* cache.c (cache_bmmap): Change the bmmap size type to size_t.
	* opncls.c (opncls_bmmap): Change the bmmap size type to size_t.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.
2024-03-13 06:55:44 -07:00
H.J. Lu
2e384d4f44 bfd: Use MAP_FAILED for mmap failure
Use MAP_FAILED, instead of ((void *) -1), for mmap failure and use
((void *) -1) only if MAP_FAILED is undefined.

	* bfdio.c (bfd_mmap): Replace (void *) -1 with MAP_FAILED for
	mmap failure.
	* bfdwin.c: Don't include <sys/mman.h>.
	(MAP_FILE): Removed.
	(bfd_get_file_window): Replace (void *) -1 with MAP_FAILED for
	mmap failure.
	* cache.c: Don't include <sys/mman.h>.
	(cache_bmmap): Replace (void *) -1 with MAP_FAILED for mmap
	failure.
	* opncls.c (opncls_bmmap): Likewise.
	* sysdep.h: Include <sys/mman.h> if HAVE_MMAP is define.
	(MAP_FILE): New.  Defined as 0 if undefined.
	(MAP_FAILED): New.  Defined as ((void *) -1) if undefined.
2024-03-13 06:55:44 -07:00
H.J. Lu
32235d9095 bfd: Don't call bfd_write with 0 size
There is no need to call bfd_write with 0 size.

	* elf-strtab.c (_bfd_elf_strtab_emit): Don't call bfd_write with
	0 size.
2024-03-13 06:55:44 -07:00
Hau Hsu
90840a8656 RISC-V: Add -march=help for gas
Use -march=help for gas to print all supported extensions and versions.

Here is part of the output of `as -march=help`:
All available -march extensions for RISC-V:
        e                                       1.9
        i                                       2.1, 2.0
        m                                       2.0
        a                                       2.1, 2.0
        f                                       2.2, 2.0
        d                                       2.2, 2.0
        q                                       2.2, 2.0
        c                                       2.0
        v                                       1.0
        h                                       1.0
        zicbom                                  1.0
        zicbop                                  1.0
        ...

This patch assumes that the supported extensions with the same versions
are listed together. For example:
static struct riscv_supported_ext riscv_supported_std_ext[] =
{
  ...
  {"i",         ISA_SPEC_CLASS_20191213,        2, 1, 0 },
  {"i",         ISA_SPEC_CLASS_20190608,        2, 1, 0 },
  {"i",         ISA_SPEC_CLASS_2P2,             2, 0, 0 },
  ...
};

For the "i" extension, 2.1.0 with different spec class are listed together.
This patch records the previous printed extension and version.  If the
current extension and version are the same as the previous one, skip
printing.

bfd/
	* elfxx-riscv.c (riscv_print_extensions): New function.  Print
	available extensions and versions.
	* elfxx-riscv.h (riscv_print_extensions): New declaration.
gas/
	* gas/config/tc-riscv.c (md_parse_option): Parse 'help' keyword in
	-march option to print available extensions and versions.
	* testsuite/gas/riscv/march-help.l: New testcase for -march=help.
	* testsuite/gas/riscv/riscv.exp: Updated.
2024-03-13 13:47:34 +08:00
GDB Administrator
ef11c1eaff Automatic date update in version.in 2024-03-13 00:00:36 +00:00
GDB Administrator
402c361af6 Automatic date update in version.in 2024-03-12 00:00:46 +00:00
GDB Administrator
5790996072 Automatic date update in version.in 2024-03-11 00:00:31 +00:00
GDB Administrator
a23cc3f389 Automatic date update in version.in 2024-03-10 00:00:26 +00:00
Alan Modra
5cd5266180 Reinstate bfd_print_error as an extern function
* bfd.c (_bfd_print): Renamed from bfd_print_error.
	(bfd_print_error): Reinstate previous code but using the above.
	(error_handler_fprintf, error_handler_sprintf): Adjust.
	* bfd-in2.h: Regenerate.
2024-03-09 21:00:02 +10:30
Alan Modra
0c947d990a Re: Move bfd_init to bfd.c
Commit b1c95bc4dd cleared some bfd static variables, with bad
results since bfd_set_error_program_name is often called before
bfd_init.

	* bfd.c (bfd_init): Don't clear _bfd_error_program_name.
2024-03-09 19:52:16 +10:30
Alan Modra
bd8d76258f print cached error messages using _bfd_error_handler
* bfd.c (bfd_print_error): Make static.  Don't print program name.
	(error_handler_fprintf): Print program name here.
	* format.c (print_warnmsg): Use _bfd_error_handler to print
	cached messages.
	* bfd-in2.h: Regenerate.
2024-03-09 14:35:09 +10:30
GDB Administrator
0d3e7c8b72 Automatic date update in version.in 2024-03-09 00:00:29 +00:00
H.J. Lu
cdabd12b18 bfd: Change the --with-mmap default to true
Change the configure default to using mmap.

	* configure.ac: Change the --with-mmap default to true.
	* configure: Regenerated.
2024-03-08 05:44:12 -08:00
H.J. Lu
433b4f8ab7 bfd: Don't hard-code BFD_JUMP_TABLE_COPY
In BFD_JUMP_TABLE_COPY, replace _bfd_generic_init_private_section_data
with NAME##_init_private_section_data so that ELF targets can properly
replace it with _bfd_elf_init_private_section_data.

	* aout-target.h (MY_init_private_section_data): New.
	* coff-rs6000.c (_bfd_xcoff_init_private_section_data): New.
	* coffcode.h (coff_init_private_section_data): New.
	* elfxx-target.h (bfd_elfNN_init_private_section_data): New.
	* libecoff.h (_bfd_ecoff_init_private_section_data): New.
	* mach-o-target.c (bfd_mach_o_init_private_section_data): New.
	* mmo.c (mmo_init_private_section_data): New.
	* plugin.c (bfd_plugin_init_private_section_data): New.
	* ppcboot.c (ppcboot_init_private_section_data): New.
	* som.c (som_init_private_section_data): New.
	* targets.c (BFD_JUMP_TABLE_COPY): Replace
	_bfd_generic_init_private_section_data with
	NAME##_init_private_section_data.
	* vms-alpha.c (vms_init_private_section_data): New.
	* elf-bfd.h (_bfd_generic_init_private_section_data): Removed.
	* bfd-in2.h: Regenerated.
2024-03-08 05:43:51 -08:00
Jiawei
dac0b8a4af RISC-V: Support Zabha extension.
The Zabha extension[1] supports for byte and halfword
atomic memory operations. This patch add all instructions
include in Zabha. Further work is waiting Zacas[2] merge.

[1] https://github.com/riscv/riscv-zabha/tags
[2] https://sourceware.org/pipermail/binutils/2023-May/127700.html

Version log:
Add new imply relation that Zabha extension implies A extension.

bfd/ChangeLog:

        * elfxx-riscv.c (riscv_implicit_subsets): New imply.
        (riscv_multi_subset_supports): New extension.
        (riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

        * testsuite/gas/riscv/zabha-32.d: New test.
        * testsuite/gas/riscv/zabha.d: New test.
        * testsuite/gas/riscv/zabha.s: New test.

include/ChangeLog:

        * opcode/riscv-opc.h (MATCH_AMOADD_B): New opcodes.
        (MASK_AMOADD_B): Ditto.
        (MATCH_AMOXOR_B): Ditto.
        (MASK_AMOXOR_B): Ditto.
        (MATCH_AMOOR_B): Ditto.
        (MASK_AMOOR_B): Ditto.
        (MATCH_AMOAND_B): Ditto.
        (MASK_AMOAND_B): Ditto.
        (MATCH_AMOMIN_B): Ditto.
        (MASK_AMOMIN_B): Ditto.
        (MATCH_AMOMAX_B): Ditto.
        (MASK_AMOMAX_B): Ditto.
        (MATCH_AMOMINU_B): Ditto.
        (MASK_AMOMINU_B): Ditto.
        (MATCH_AMOMAXU_B): Ditto.
        (MASK_AMOMAXU_B): Ditto.
        (MATCH_AMOSWAP_B): Ditto.
        (MASK_AMOSWAP_B): Ditto.
        (MATCH_AMOADD_H): Ditto.
        (MASK_AMOADD_H): Ditto.
        (MATCH_AMOXOR_H): Ditto.
        (MASK_AMOXOR_H): Ditto.
        (MATCH_AMOOR_H): Ditto.
        (MASK_AMOOR_H): Ditto.
        (MATCH_AMOAND_H): Ditto.
        (MASK_AMOAND_H): Ditto.
        (MATCH_AMOMIN_H): Ditto.
        (MASK_AMOMIN_H): Ditto.
        (MATCH_AMOMAX_H): Ditto.
        (MASK_AMOMAX_H): Ditto.
        (MATCH_AMOMINU_H): Ditto.
        (MASK_AMOMINU_H): Ditto.
        (MATCH_AMOMAXU_H): Ditto.
        (MASK_AMOMAXU_H): Ditto.
        (MATCH_AMOSWAP_H): Ditto.
        (MASK_AMOSWAP_H): Ditto.
        (DECLARE_INSN): New declare.
        * opcode/riscv.h (enum riscv_insn_class): New class.

opcodes/ChangeLog:

        * riscv-opc.c: New instructions.
2024-03-08 10:04:25 +08:00
GDB Administrator
acab5b12b9 Automatic date update in version.in 2024-03-08 00:00:21 +00:00
GDB Administrator
5b95198e2e Automatic date update in version.in 2024-03-07 00:00:53 +00:00
Lulu Cai
d5de762be7 LoongArch: Add dtpoff calculation function
When tls_sec is NULL, we should not access the virtual address
of tls_sec.
2024-03-06 14:47:03 +08:00
Lulu Cai
0e45942b2c LoongArch: Delete extra instructions when TLS type transition
This modification mainly changes the timing of type transition,
adds relaxation to the old LE instruction sequence, and fixes
bugs in extreme code models.

We strictly distinguish between type transition and relaxation.
Type transition is from one type to another, while relaxation
is the removal of instructions under the same TLS type. Detailed
instructions are as follows:

1. For type transition, only the normal code model of DESC/IE
does type transition, and each relocation is accompanied by a
RELAX relocation. Neither abs nor extreme will do type transition,
and no RELAX relocation will be generated.
The extra instructions when DESC transitions to other TLS types
will be deleted during the type transition.

2. Implemented relaxation for the old LE instruction sequence.
The first two instructions of LE's 32-bit and 64-bit models
use the same relocations and cannot be distinguished based on
relocations. Therefore, for LE's instruction sequence, any code
model will try to relax.

3. Some function names have been adjusted to facilitate understanding,
parameters have been adjusted, and unused macros have been deleted.
2024-03-06 14:47:03 +08:00
Alan Modra
55e01dbd76 Don't use bfd_error_handler in bfd_abort
We don't want to lose an abort message when bfd_set_error_handler has
been called to ignore or cache errors.

	PR ld/31444
	* bfd.c (_bfd_abort): Don't use _bfd_error_handler.
2024-03-06 11:22:29 +10:30
GDB Administrator
ea1b1dc0b5 Automatic date update in version.in 2024-03-06 00:00:59 +00:00
GDB Administrator
a7ea089b0b Automatic date update in version.in 2024-03-05 00:00:23 +00:00
GDB Administrator
1485a3fb63 Automatic date update in version.in 2024-03-04 00:00:24 +00:00
GDB Administrator
90f8d97c8e Automatic date update in version.in 2024-03-03 00:00:24 +00:00
GDB Administrator
668183c244 Automatic date update in version.in 2024-03-02 00:00:28 +00:00
GDB Administrator
3f13a7b28c Automatic date update in version.in 2024-03-01 00:00:49 +00:00
H.J. Lu
801977ce47 bfd: Add ATTRIBUTE_HIDDEN to x86 internal functions
* elfxx-x86.h: Add ATTRIBUTE_HIDDEN to internal functions.
	* libbfd-in.h (_bfd_get_link_info): Add ATTRIBUTE_HIDDEN.
	* libbfd.h: Regenerated.
2024-02-29 04:32:26 -08:00
Tatsuyuki Ishi
159afbb761 RISC-V: Initial ld.bfd support for TLSDESC.
Only relocation handling for now; relaxation is not implemented yet.

bfd/
    * elfnn-riscv.c (riscv_elf_check_relocs): Record GOT reference and
    paired relocation for TLSDESC_HI20.
    (riscv_elf_adjust_dynamic_symbol): Allocate GOT and reloc slots for
    TLSDESC symbols.
    (riscv_elf_size_dynamic_sections): Likewise but for local symbols.
    (tlsdescoff): New helper to determine static addend for R_TLSDESC.
    (riscv_elf_relocate_section): Ignore TLSDESC_CALL reloc for now (it is
    relaxation only).
    Handle TLSDESC_{LOAD,ADD}_LO12 as paired pcrel relocs.
    For TLS GOT slot generation, generalize the logic to handle any
    combination of (GD, IE, TLSDESC).
    Add TLSDESC Rela generation.
    * ld/testsuite/ld-riscv-elf/tls*: Add TLSDESC instruction sequences
    next to the existing GD and IE sequences. Update expectations.
2024-02-29 15:02:55 +08:00