aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2024-03-15Automatic date update in version.inGDB Administrator1-1/+1
2024-03-14Automatic date update in version.inGDB Administrator1-1/+1
2024-03-13bfd: Use size_t in the BFD mmap interfaceH.J. Lu5-16/+16
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-13bfd: Use MAP_FAILED for mmap failureH.J. Lu6-19/+19
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-13bfd: Don't call bfd_write with 0 sizeH.J. Lu1-1/+1
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-13RISC-V: Add -march=help for gasHau Hsu2-0/+49
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-13Automatic date update in version.inGDB Administrator1-1/+1
2024-03-12Automatic date update in version.inGDB Administrator1-1/+1
2024-03-11Automatic date update in version.inGDB Administrator1-1/+1
2024-03-10Automatic date update in version.inGDB Administrator1-1/+1
2024-03-09Reinstate bfd_print_error as an extern functionAlan Modra2-4/+32
* 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-09Re: Move bfd_init to bfd.cAlan Modra1-1/+0
Commit b1c95bc4dd73 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-09print cached error messages using _bfd_error_handlerAlan Modra3-31/+3
* 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-09Automatic date update in version.inGDB Administrator1-1/+1
2024-03-08bfd: Change the --with-mmap default to trueH.J. Lu2-2/+2
Change the configure default to using mmap. * configure.ac: Change the --with-mmap default to true. * configure: Regenerated.
2024-03-08bfd: Don't hard-code BFD_JUMP_TABLE_COPYH.J. Lu14-4/+20
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-08RISC-V: Support Zabha extension.Jiawei1-0/+6
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-08Automatic date update in version.inGDB Administrator1-1/+1
2024-03-07Automatic date update in version.inGDB Administrator1-1/+1
2024-03-06LoongArch: Add dtpoff calculation functionLulu Cai1-1/+11
When tls_sec is NULL, we should not access the virtual address of tls_sec.
2024-03-06LoongArch: Delete extra instructions when TLS type transitionLulu Cai1-167/+253
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-06Don't use bfd_error_handler in bfd_abortAlan Modra1-9/+9
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-06Automatic date update in version.inGDB Administrator1-1/+1
2024-03-05Automatic date update in version.inGDB Administrator1-1/+1
2024-03-04Automatic date update in version.inGDB Administrator1-1/+1
2024-03-03Automatic date update in version.inGDB Administrator1-1/+1
2024-03-02Automatic date update in version.inGDB Administrator1-1/+1
2024-03-01Automatic date update in version.inGDB Administrator1-1/+1
2024-02-29bfd: Add ATTRIBUTE_HIDDEN to x86 internal functionsH.J. Lu3-38/+46
* elfxx-x86.h: Add ATTRIBUTE_HIDDEN to internal functions. * libbfd-in.h (_bfd_get_link_info): Add ATTRIBUTE_HIDDEN. * libbfd.h: Regenerated.
2024-02-29RISC-V: Initial ld.bfd support for TLSDESC.Tatsuyuki Ishi1-12/+92
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-29RISC-V: Define and use GOT entry size constants for TLS.Tatsuyuki Ishi1-7/+9
As the size calculation is split by global and local symbols, using a shared constant definition for its size improves clarity. bfd/ * elfnn-riscv.c: Add macros for sizes of a normal GOT entry, TLS GD and TLS IE entry. (allocate_dynrelocs): Replace GOT size expressions with the new constants. (riscv_elf_size_dynamic_sections): Likewise. (riscv_elf_relocate_section): Likewise.
2024-02-29RISC-V: Add TLSDESC reloc definitions.Tatsuyuki Ishi4-1/+90
bfd/ * elfxx-riscv.c: Add 5 TLSDESC reloc descriptions. * reloc.c: Likewise. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. include/ * elf/riscv.h: Add 5 TLSDESC reloc descriptions.
2024-02-29Automatic date update in version.inGDB Administrator1-1/+1
2024-02-28PR23881, pdp11 binutils fails if too much debug dataAlan Modra4-7/+60
The PR testcase overflows one of the exec header fields, e_syms (the size of the symbol table), leading to the string table offset being wrong. Things go downhill from there. Fixed by checking for overflow. This happens to trigger in the ld testsuite, so xfail that test. PR 23881 bfd/ * libaout.h (swap_exec_header_out): Return a bool. * aoutx.h (swap_exec_header_out): Check for overflow in exec header. * pdp11.c (swap_exec_header_out): Likewise. * i386lynx.c (WRITE_HEADERS): Adjust. ld/ * testsuite/ld-scripts/map-address.exp: xfail pdp11.
2024-02-28Automatic date update in version.inGDB Administrator1-1/+1
2024-02-27s390: Add r_offset check to the weak undef changeAndreas Krebbel1-1/+2
Since we are accessing up to 2 bytes before the relocation target we should better make sure there are actually 2 bytes before it. ChangeLog: * bfd/elf64-s390.c (elf_s390_relocate_section): Make sure rel->r_offset is large enough.
2024-02-27s390: Avoid reloc overflows on undefined weak symbolsAndreas Krebbel1-0/+54
Replace relative long addressing instructions of weak symbols, which will definitely resolve to zero, with either a load address of 0, a NOP, or a trapping insn. This prevents the PC32DBL relocation from overflowing in case the binary will be loaded at 4GB or more. bfd/ChangeLog: * bfd/elf64-s390.c (elf_s390_relocate_section): Replace instructions using undefined weak symbols with relative addressing to avoid relocation overflows. ld/ChangeLog: * ld/testsuite/ld-s390/s390.exp: * ld/testsuite/ld-s390/8GB.ld: New test. * ld/testsuite/ld-s390/weakundef-1.dd: New test. * ld/testsuite/ld-s390/weakundef-1.s: New test.
2024-02-27LoongArch: Modify inconsistent behavior of ld with ↵ticat_fp1-8/+1
--unresolved-symbols=ignore-all Remove duplicated check when producing executable files that reference external symbols defined in other files. RELOC_FOR_GLOBAL_SYMBOL will check it. Testcase is: resolv.c: int main(int argc, char *argv[]) { return argc; } t.c: extern const struct my_struct ms1; static const struct my_struct *ms = &ms1; t.h: typedef struct my_struct { char *str; int i; } my_struct; Compiling and linking command with: gcc t.c -c ; gcc resolv.c -c gcc resolv.o t.o -o resolv -Wl,--unresolved-symbols=ignore-all Got error as: ~/install/usr/bin/ld: t.o:(.data.rel+0x0): undefined reference to `ms1' collect2: error: ld returned 1 exit status
2024-02-27Avoid unused space in .rela.dyn if sec was discardedJinyang He1-0/+2
The relsec size is still increased although sec is discarded, which cause a lot of unused space allocated. Avoid size increased if sec was discarded. bfd/ChangeLog: * bfd/elfnn-loongarch.c: (allocate_dynrelocs): Do not increase sreloc size when discarded_section. ld/ChangeLog: * ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp: Add test. * ld/testsuite/ld-loongarch-elf/pie_discard.d: New test. * ld/testsuite/ld-loongarch-elf/pie_discard.s: New test. * ld/testsuite/ld-loongarch-elf/pie_discard.t: New test.
2024-02-27LoongArch: ld: Fix other pop relocs overflow check and add testsJinyang He1-9/+25
Add reloc_unsign_bits() to fix others sop_pop relocs overflow check. Then add over/underflow tests for relocs B*, SOP_POP* and PCREL20_S2. bfd/ChangeLog: * bfd/elfxx-loongarch.c: Add reloc_unsign_bits(). ld/ChangeLog: * ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp: Add tests. * ld/testsuite/ld-loongarch-elf/abi1_max_imm.dd: New test. * ld/testsuite/ld-loongarch-elf/abi1_max_imm.s: New test. * ld/testsuite/ld-loongarch-elf/abi1_sops.s: New test. * ld/testsuite/ld-loongarch-elf/abi2_max_imm.s: New test. * ld/testsuite/ld-loongarch-elf/abi2_overflows.s: New test. * ld/testsuite/ld-loongarch-elf/max_imm_b16.d: New test. * ld/testsuite/ld-loongarch-elf/max_imm_b21.d: New test. * ld/testsuite/ld-loongarch-elf/max_imm_b26.d: New test. * ld/testsuite/ld-loongarch-elf/max_imm_pcrel20.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_b16.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_b21.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_b26.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_pcrel20.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_s_0_10_10_16_s2.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_s_0_5_10_16_s2.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_s_10_12.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_s_10_16.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_s_10_16_s2.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_s_10_5.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_s_5_20.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_u.d: New test. * ld/testsuite/ld-loongarch-elf/overflow_u_10_12.d: New test. * ld/testsuite/ld-loongarch-elf/underflow_b16.d: New test. * ld/testsuite/ld-loongarch-elf/underflow_b21.d: New test. * ld/testsuite/ld-loongarch-elf/underflow_b26.d: New test. * ld/testsuite/ld-loongarch-elf/underflow_pcrel20.d: New test. * ld/testsuite/ld-loongarch-elf/underflow_s_0_10_10_16_s2.d: New test. * ld/testsuite/ld-loongarch-elf/underflow_s_0_5_10_16_s2.d: New test. * ld/testsuite/ld-loongarch-elf/underflow_s_10_12.d: New test. * ld/testsuite/ld-loongarch-elf/underflow_s_10_16.d: New test. * ld/testsuite/ld-loongarch-elf/underflow_s_10_16_s2.d: New test. * ld/testsuite/ld-loongarch-elf/underflow_s_10_5.d: New test. * ld/testsuite/ld-loongarch-elf/underflow_s_5_20.d: New test.
2024-02-27LoongArch: bfd: Fix some bugs of howto tablemengqinggang1-5/+5
R_LARCH_IRELATIVE: For dynamic relocation that does not distinguish between 32/64 bits, size and bitsize set to 8 and 64. R_LARCH_TLS_DESC64: Change size to 8. R_LARCH_SOP_POP_32_S_0_5_10_16_S2: Change src_mask to 0, dst_mask to 0x03fffc1f.
2024-02-27Automatic date update in version.inGDB Administrator1-1/+1
2024-02-26LoongArch: bfd: Correct the name of R_LARCH_SOP_POP_32_U in howto_tableJinyang He1-1/+1
2024-02-26Automatic date update in version.inGDB Administrator1-1/+1
2024-02-25Automatic date update in version.inGDB Administrator1-1/+1
2024-02-24xtensa: move xtensa_make_property_section from bfd to gasAlan Modra1-33/+1
This function is only used by gas, so move it there. Necessary for gas to keep track of group sections as they are created. PR 25333 bfd/ * elf32-xtensa.c (xtensa_make_property_section): Delete. (xtensa_property_section_name): Make public. include/ * elf/xtensa.h (xtensa_make_property_section): Delete. (xtensa_property_section_name): Declare gas/ * config/tc-xtensa.c (xtensa_make_property_section): New, moved from elf32-xtensa.c.
2024-02-24Make is_relocatable_executable only affect dynamic section symsAlan Modra1-11/+2
I believe the only elflink.c specialties for is_relocatable_executable needed by tic6x are those directly related to dynamic section symbols. I might be wrong, the code in record_dynamic_symbol and record_link_assignment predated the tic6x port, but I think these were symbian specific hacks. The shlib-app-1* testsuite changes aren't needed for this patch. I started making them when trying to remove is_relocatable_executable completely, but figure it is worth keeping the more permissive address matching for some future generic linker change. The static-app-1* changes also adjust to the fact that an unneeded "c" no longer appears in the dynamic symbol table. bfd/ * elflink.c (bfd_elf_link_record_dynamic_symbol): Don't do anything special for is_relocatable_executable. (bfd_elf_record_link_assignment): Likewise. ld/ * testsuite/ld-tic6x/shlib-app-1.rd: Make some address matching more permissive. * testsuite/ld-tic6x/shlib-app-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise. * testsuite/ld-tic6x/static-app-1.rd: Likewise, and adjust expected dynamic symbol table. * testsuite/ld-tic6x/static-app-1b.rd: Likewise. * testsuite/ld-tic6x/static-app-1r.rd: Likewise. * testsuite/ld-tic6x/static-app-1rb.rd: Likewise.
2024-02-24Automatic date update in version.inGDB Administrator1-1/+1
2024-02-23Automatic date update in version.inGDB Administrator1-1/+1
2024-02-22Automatic date update in version.inGDB Administrator1-1/+1