summaryrefslogtreecommitdiff
path: root/bfd
Commit message (Collapse)AuthorAgeFilesLines
* Automatic date update in version.inGDB Administrator2023-05-121-1/+1
|
* Add LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook [GCC PR109128]Joseph Myers2023-05-112-6/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is one part of the fix for GCC PR109128, along with a corresponding GCC change. Without this patch, what happens in the linker, when an unused object in a .a file has offload data, is that elf_link_is_defined_archive_symbol calls bfd_link_plugin_object_p, which ends up calling the plugin's claim_file_handler, which then records the object as one with offload data. That is, the linker never decides to use the object in the first place, but use of this _p interface (called as part of trying to decide whether to use the object) results in the plugin deciding to use its offload data (and a consequent mismatch in the offload data present at runtime). The new hook allows the linker plugin to distinguish calls to claim_file_handler that know the object is being used by the linker (from ldmain.c:add_archive_element), from calls that don't know it's being used by the linker (from elf_link_is_defined_archive_symbol); in the latter case, the plugin should avoid recording the object as one with offload data. bfd/ * plugin.c (struct plugin_list_entry): Add claim_file_v2. (register_claim_file_v2): New. (try_load_plugin): Use LDPT_REGISTER_CLAIM_FILE_HOOK_V2. (ld_plugin_object_p): Take second argument. (bfd_link_plugin_object_p): Update call to ld_plugin_object_p. (register_ld_plugin_object_p): Update argument prototype. (bfd_plugin_object_p): Update call to ld_plugin_object_p. * plugin.h (register_ld_plugin_object_p): Update argument prototype. include/ * plugin.api.h (ld_plugin_claim_file_handler_v2) (ld_plugin_register_claim_file_v2) (LDPT_REGISTER_CLAIM_FILE_HOOK_V2): New. (struct ld_plugin_tv): Add tv_register_claim_file_v2. ld/ * plugin.c (struct plugin): Add claim_file_handler_v2. (LDPT_REGISTER_CLAIM_FILE_HOOK_V2): New. (plugin_object_p): Add second argument. Update call to plugin_call_claim_file. (register_claim_file_v2): New. (set_tv_header): Handle LDPT_REGISTER_CLAIM_FILE_HOOK_V2. (plugin_call_claim_file): Add argument known_used. (plugin_maybe_claim): Update call to plugin_object_p. * testplug.c, testplug2.c, testplug3.c, testplug4.c: Handle LDPT_REGISTER_CLAIM_FILE_HOOK_V2. * testsuite/ld-plugin/plugin-1.d, testsuite/ld-plugin/plugin-10.d, testsuite/ld-plugin/plugin-11.d, testsuite/ld-plugin/plugin-13.d, testsuite/ld-plugin/plugin-14.d, testsuite/ld-plugin/plugin-15.d, testsuite/ld-plugin/plugin-16.d, testsuite/ld-plugin/plugin-17.d, testsuite/ld-plugin/plugin-18.d, testsuite/ld-plugin/plugin-19.d, testsuite/ld-plugin/plugin-2.d, testsuite/ld-plugin/plugin-26.d, testsuite/ld-plugin/plugin-3.d, testsuite/ld-plugin/plugin-30.d, testsuite/ld-plugin/plugin-4.d, testsuite/ld-plugin/plugin-5.d, testsuite/ld-plugin/plugin-6.d, testsuite/ld-plugin/plugin-7.d, testsuite/ld-plugin/plugin-8.d, testsuite/ld-plugin/plugin-9.d: Update test expectations.
* Automatic date update in version.inGDB Administrator2023-05-111-1/+1
|
* or1k relocation truncated to fit: R_OR1K_GOT16 even when using -mcmodel=largeLuca Bonissi2023-05-102-3/+18
| | | | | PR 30422 * elf32-or1k.c (or1k_elf_relocate_section): Prescan for R_OR1K_GOT_AHI16 relocs as they may occur after R_OR1K_GOT16 relocs.
* Automatic date update in version.inGDB Administrator2023-05-101-1/+1
|
* alpha-vms reloc sanity checkAlan Modra2023-05-091-2/+22
| | | | | | Stops fuzzed files triggering reads past the end of the reloc buffer. * vms-alpha.c (alpha_vms_slurp_relocs): Sanity check reloc records.
* Automatic date update in version.inGDB Administrator2023-05-091-1/+1
|
* Automatic date update in version.inGDB Administrator2023-05-081-1/+1
|
* Automatic date update in version.inGDB Administrator2023-05-071-1/+1
|
* Automatic date update in version.inGDB Administrator2023-05-061-1/+1
|
* Debug info is lost for functions only called from functions marked with ↵Nick Clifton2023-05-052-3/+21
| | | | | | | cmse_nonsecure_entr PR 30354 * elf32-arm.c (elf32_arm_gc_mark_extra_sections): If any debug sections are marked then rerun the extra marking in order to pick up any dependencies.
* Automatic date update in version.inGDB Administrator2023-05-051-1/+1
|
* MIPS: revert "default r6 if vendor is img"YunQiang Su2023-05-041-1/+1
| | | | | | | | In commit: 9171de358f230b64646bbb525a74e5f8e3dbe0dc, The default output is set to r6 if the vendor is img, It is ugly and should not be in upstream. Let's revert it.
* Automatic date update in version.inGDB Administrator2023-05-041-1/+1
|
* Make ar fasterOleg Tolmatcev2023-05-032-5/+21
| | | | * archive.c (_bfd_write_archive_contents): Use a larger buffer in order to improve efficiency.
* Improve the speed of computing checksums for COFF binaries.Oleg Tolmatcev2023-05-032-6/+67
| | | | | | * coffcode.h (coff_read_word_from_buffer): New function. * coffcode.h (COFF_CHECKSUM_BUFFER_SIZE): New constant. * coffcode.h (coff_compute_checksum): Improve speed by reducing the number of seeks and reads used.
* Remove unused args from bfd_make_debug_symbolAlan Modra2023-05-038-18/+13
| | | | | The ptr and size args are unused. Make the function look the same as bfd_make_empty_symbol.
* Generated docs and include filesAlan Modra2023-05-0329-2219/+2456
| | | | | | | | | | | | | bfd/doc/chew.c extracts documentation from source code comments annotated with keywords, and generates much of bfd.h and libbfd.h from those same comments. The docs have suffered from people (me too) adding things like CODE_FRAGMENT to the source to put code into bfd.h without realising that CODE_FRAGMENT also puts @example around said code into the docs. So we have random senseless things in the docs. This patch fixes that problem (well, the senseless things from CODE_FRAGMENT), moves most of the code out of bfd-in.h, and improves a few chew.c features. libbfd.h now automatically gets ATTRIBUTE_HIDDEN prototypes, and indentation in bfd.h and libbfd.h is better.
* Move bfd_alloc, bfd_zalloc and bfd_release to libbfd.cAlan Modra2023-05-035-85/+88
| | | | | | | | | | | These functions don't belong in opncls.c. * libbfd-in.h (bfd_release): Delete prototype. * opncls.c (bfd_alloc, bfd_zalloc, bfd_release): Move to.. * libbfd.c: ..here. Include objalloc.c and provide bfd_release with a FUNCTION comment. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate.
* Move bfd_elf_bfd_from_remote_memory to opncls.cAlan Modra2023-05-034-69/+50
| | | | | | | | | | | | | bfd_elf_bfd_from_remote_memory is just a wrapper, and the function could be implemented for other formats. Move it to opncls.c because it acts a little like some of the other bfd_open* routines. Also give it the usual FUNCTION etc. comment so prototypes and docs are handled automatically. * elf.c (bfd_elf_bfd_from_remote_memory): Move to.. * opncls.c: ..here, add FUNCTION comment. * bfd-in.h (bfd_elf_bfd_from_remote_memory): Delete prototype. * bfd-in2.h: Regenerate.
* hash.c: replace some unsigned long with unsigned intAlan Modra2023-05-033-42/+41
| | | | | | | | | * hash.c (higher_prime_number): Use uint32_t param, return value, tables and variables. (bfd_default_hash_table_size): Make it an unsigned int. (bfd_hash_set_default_size): Use unsigned int param and return. * bfd-in.h (bfd_hash_set_default_size): Update prototype. * bfd-in2.h: Regenerate.
* libbfc.c: Use stdint types for unsigned char and unsigned longAlan Modra2023-05-032-37/+37
| | | | | | | | | | * libbfd.c (bfd_put_8): Use bfd_byte rather than unsigned char. (bfd_get_8, bfd_get_signed_8): Likewise. (_bfd_read_unsigned_leb128, _bfd_safe_read_leb128): Likewise. (_bfd_read_signed_leb128): Likewise. (bfd_getb24, bfd_getl24): Replace unsigned long with uint32_t. (bfd_getb32, bfd_getl32): Likewise. (bfd_getb_signed_32, bfd_getl_signed_32): Likewise.
* Change signature of bfd crc functionsAlan Modra2023-05-032-20/+20
| | | | | | | | | | | | | | | | | | The crc calculated is 32 bits. Replace uses of unsigned long with uint32_t. Also use bfd_byte* for buffers. bfd/ * opncls.c (bfd_calc_gnu_debuglink_crc32): Use stdint types. (bfd_get_debug_link_info_1, bfd_get_debug_link_info): Likewise. (separate_debug_file_exists, bfd_follow_gnu_debuglink): Likewise. (bfd_fill_in_gnu_debuglink_section): Likewise. * bfd-in2.h: Regenerate. gdb/ * auto-load.c (auto_load_objfile_script): Update type of bfd_get_debug_link_info argument. * symfile.c (find_separate_debug_file_by_debuglink): Likewise. * gdb_bfd.c (get_file_crc): Update type of bfd_calc_gnu_debuglink_crc32 argument.
* _bfd_mips_elf_lo16_reloc vallo commentAlan Modra2023-05-031-4/+16
| | | | | | | | | | | This explains exactly why the high reloc adjustment is as it is, replacing the rather nebulous existing comment. I've also changed the expression from (lo+0x8000)&0xffff to (lo&0xffff)^0x8000 which better matches part of the standard 16-bit sign extension (resulting in exactly the same value), and hoisted the calculation out of the loop. * elfxx-mips.c (_bfd_mips_elf_lo16_reloc): Expand vallo comment. Hoist calculation out of loop.
* Automatic date update in version.inGDB Administrator2023-05-021-1/+1
|
* Automatic date update in version.inGDB Administrator2023-05-011-1/+1
|
* Automatic date update in version.inGDB Administrator2023-04-301-1/+1
|
* Automatic date update in version.inGDB Administrator2023-04-291-1/+1
|
* RISC-V: Enable x0 base relaxation for relax_pc even if --no-relax-gp.Nelson Chu2023-04-281-2/+6
| | | | | | | | | | | | | | Let --no-relax-gp only disable the gp relaxation for lui and pcrel relaxations, since x0 base and gp relaxations are different optimizations in fact, but just use the same function to handle. bfd/ * elfnn-riscv.c (_bfd_riscv_relax_pc): Like _bfd_riscv_relax_lui, set gp to zero when --no-relax-gp, then we should still keep the x0 base relaxation. (_bfd_riscv_relax_section): Enable _bfd_riscv_relax_pc when --no-relax-gp, we will disable the gp relaxation in the _bfd_riscv_relax_pc.
* RISC-V: Relax R_RISCV_[PCREL_]LO12_I/S to R_RISCV_GPREL_I/S for undefined weak.Nelson Chu2023-04-281-49/+6
| | | | | | | | bfd/ *elfnn-riscv.c (_bfd_riscv_relax_lui): For undefined weak symbol, just relax the R_RISCV_LO12_I/S to R_RISCV_GPREL_I/S, and then don't update the rs1 to zero until relocate_section. (_bfd_riscv_relax_pc): Likewise, but for R_RISCV_PCREL_LO12_I/S.
* Re: Keeping track of rs6000-coff archive element pointersAlan Modra2023-04-283-11/+28
| | | | | | | | | | | | | | | | | | | | | | | | Commit de7b90610e9e left a hole in the element checking, explained by the comment added to _bfd_xcoff_openr_next_archived_file. While fixing this, tidy some types used to hold unsigned values so that casts are not needed to avoid signed/unsigned comparison warnings. Also tidy a few things in xcoff.h. bfd/ * coff-rs6000.c (_bfd_xcoff_openr_next_archived_file): Check that we aren't pointing back at the last element. Make filestart a ufile_ptr. Update for xcoff_artdata change. (_bfd_strntol, _bfd_strntoll): Return unsigned values. (_bfd_xcoff_slurp_armap): Make off a ufile_ptr. (add_ranges): Update for xcoff_artdata change. * libbfd-in.h (struct artdata): Make first_file_filepos a ufile_ptr. * libbfd.h: Regenerate. include/ * coff/xcoff.h (struct xcoff_artdata): Replace min_elt with ar_hdr_size. (xcoff_big_format_p): In the !SMALL_ARCHIVE case return true for anything but a small archive.
* Remove deprecated bfd_readAlan Modra2023-04-283-64/+0
| | | | | | | | | 20+ years is long enough to warn. * bfd-in.h (bfd_read, bfd_write): Don't define (_bfd_warn_deprecated): Don't declare. * bfd-in2.h: Regenerate. * libbfd.c (_bfd_warn_deprecated): Delete.
* Make bfd_byte an int8_t, flagword a uint32_tAlan Modra2023-04-282-12/+12
| | | | | | | | * bfd-in.h (bfd_byte): Typedef as int8_t. (flagword): Typedef as uint32_t. (bfd_vma, bfd_signed_vma, bfd_size_type, symvalue): Use stdint types in !BFD64 case. * bfd-in2.h: Regenerate.
* Automatic date update in version.inGDB Administrator2023-04-281-1/+1
|
* Automatic date update in version.inGDB Administrator2023-04-271-1/+1
|
* RISC-V: Support XVentanaCondOps extensionPhilipp Tomsich2023-04-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ventana Micro has published the specification for their XVentanaCondOps ("conditional ops") extension at https://github.com/ventanamicro/ventana-custom-extensions/releases/download/v1.0.0/ventana-custom-extensions-v1.0.0.pdf which contains two new instructions - vt.maskc - vt.maskcn that can be used in constructing branchless sequences for various conditional-arithmetic, conditional-logical, and conditional-select operations. To support such vendor-defined instructions in the mainline binutils, this change also adds a riscv_supported_vendor_x_ext secondary dispatch table (but also keeps the behaviour of allowing any unknow X-extension to be specified in addition to the known ones from this table). As discussed, this change already includes the planned/agreed future requirements for X-extensions (which are likely to be captured in the riscv-toolchain-conventions repository): - a public specification document is available (see above) and is referenced from the gas-documentation - the naming follows chapter 27 of the RISC-V ISA specification - instructions are prefixed by a vendor-prefix (vt for Ventana) to ensure that they neither conflict with future standard extensions nor clash with other vendors bfd/ChangeLog: * elfxx-riscv.c (riscv_get_default_ext_version): Add riscv_supported_vendor_x_ext. (riscv_multi_subset_supports): Recognize INSN_CLASS_XVENTANACONDOPS. gas/ChangeLog: * doc/c-riscv.texi: Add section to list custom extensions and their documentation URLs. * testsuite/gas/riscv/x-ventana-condops.d: New test. * testsuite/gas/riscv/x-ventana-condops.s: New test. include/ChangeLog: * opcode/riscv-opc.h Add vt.maskc and vt.maskcn. * opcode/riscv.h (enum riscv_insn_class): Add INSN_CLASS_XVENTANACONDOPS. opcodes/ChangeLog: * riscv-opc.c: Add vt.maskc and vt.maskcn. Series-version: 1 Series-to: binutils@sourceware.org Series-cc: Kito Cheng <kito.cheng@sifive.com> Series-cc: Nelson Chu <nelson.chu@sifive.com> Series-cc: Greg Favor <gfavor@ventanamicro.com> Series-cc: Christoph Muellner <cmuellner@gcc.gnu.org>
* Automatic date update in version.inGDB Administrator2023-04-261-1/+1
|
* Automatic date update in version.inGDB Administrator2023-04-251-1/+1
|
* New georgian translation for the bfd sub-directoryNick Clifton2023-04-242-0/+9352
|
* asan: segfault in coff_mangle_symbolsAlan Modra2023-04-242-10/+18
| | | | | | | | | | | The testcase managed to trigger creation of a wild pointer in coff_slurp_symbol_table. Stop that happening, and fix an unrelated problem I happened to see in bfd_coff_get_syment. * coff-bfd.c (bfd_coff_get_syment): Clear fix_value after converting n_value from a pointer to an index. * coffcode.h (coff_slurp_symbol_table <C_BSTAT>): Sanity check symbol value before converting to a pointer.
* Automatic date update in version.inGDB Administrator2023-04-241-1/+1
|
* MIPS: default output r6 obj if the triple is r6YunQiang Su2023-04-233-2/+12
| | | | | | | | | | If the triple is mipsisa32r6* or mipsisa64r6*, ld/as should output r6 objects by default. The triples with vendor `img` should do same. The examples include: as xx.s -o xx.o ld -r -b binary xx.dat -o xx.o
* MIPS: support mips*64 as CPU and gnuabi64 as ABIYunQiang Su2023-04-231-2/+12
| | | | | | | | | | For MIPS64r6 ports, Debian as an example, `mipsisa64r6el` is used as the cpu name in triple. Let's recognize them by `mips*64*(el)`. For 64bit Ports, like Debian's mips64el and mips64r6el ports, `gnuabi64` is used as the abi section. Let's use N64 abi by default for the triple with gnuabi64.
* Automatic date update in version.inGDB Administrator2023-04-231-1/+1
|
* Automatic date update in version.inGDB Administrator2023-04-221-1/+1
|
* bfd: fix STRICT_PE_FORMAT buildJan Beulich2023-04-211-3/+3
| | | | | A semicolon was missing and "name" needs to be pointer-to-const. While adding "const" there, also add it for "sec".
* RISC-V: Optimize relaxation of gp with max_alignment.Lifang Xia2023-04-211-29/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This should be the first related issue, which posted in riscv-gnu-toolchain, https://github.com/riscv-collab/riscv-gnu-toolchain/issues/497 If the output sections are not between gp and the symbol, then their alignments shouldn't affect the gp relaxation. However, this patch improves this idea even more, it limits the range to the gp+-2k, which means only the output section which are in the [gp-2K, gp+2K) range need to be considered. Even if the output section candidates may be different for each relax passes, the symbol that can be relaxed ar this round will not be truncated at next round. That is because this round you can do relaxation which means that the section where the symbol is located is within the [gp-2K, gp+2K) range, so all the output section alignments between them should be considered. In other words, if the alignments between them may cause truncated, then we should already preserve the size and won't do the gp relaxation this time. This patch can resolve the github issue which mentioned above, and also passed all gcc/binutils regressions of riscv-gnu-toolchain, so should be worth and safe enough to commit. Originally, this patch also do the same optimization for the call relaxations, https://sourceware.org/pipermail/binutils/2022-October/123918.html But just in case there is something that has not been considered, we only deal with the gp relaxation at this time. bfd/ * elfnn-riscv.c (riscv_elf_link_hash_table): Added new bfd_vma, max_alignment_for_gp. It is used to record the maximum alignment of the output sections, which are in the [gp-2K, gp+2k) range. (riscv_elf_link_hash_table_create): Init max_alignment_for_gp to -1. (_bfd_riscv_get_max_alignment): Added new parameter, gp. If gp is zero, then all the output section alignments are possible candidates; Otherwise, only the output sections which are in the [gp-2K, gp+2K) range need to be considered. (_bfd_riscv_relax_lui): Called _bfd_riscv_get_max_alignment with the non-zero gp if the max_alignment_for_gp is -1. (_bfd_riscv_relax_pc): Likewise. (_bfd_riscv_relax_section): Record the first input section, so that we can reset the max_alignment_for_gp for each repeated relax passes. ld/ * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. * testsuite/ld-riscv-elf/relax-max-align-gp.*: New testcase. It fails without this patch.
* Keeping track of rs6000-coff archive element pointersAlan Modra2023-04-212-91/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rs6000-coff archives use a linked list of file offsets, where each element points to the next element. The idea is to allow updating of large archives quickly without rewriting the whole archive. (binutils ar does not do this.) Unfortunately this is an easy target for fuzzers to create an archive that will cause ar or any other tool processing archives to hang. I'd implemented guards against pointing back to the previous element, but of course that didn't last long. So this patch implements a scheme to keep track of file offset ranges used by elements as _bfd_read_ar_hdr is called for each element. See the add_range function comment. I needed a place to stash the list, so chose the obvious artdata.tdata backend extension to archive's tdata, already used by xcoff. That involved a little cleanup, because while it would be possible to continue using different artdata.tdata for the big and small archives, it's nicer to use a union. If anyone is concerned this list of element ranges might grow large and thus significantly slow down the tools, adjacent ranges are merged. In fact something like "ar t" will only ever have one range on xcoff archives generated by binutils/ar. I agree there might still be a problem with ld random element access via the armap. include/ * coff/xcoff.h (SIZEOF_AR_FILE_HDR): Use sizeof. (SIZEOF_AR_FILE_HDR_BIG, SIZEOF_AR_HDR, SIZEOF_AR_HDR_BIG): Likewise. (struct ar_ranges, struct xcoff_artdata): New. (x_artdata): Define. (xcoff_big_format_p): Rewrite. (xcoff_ardata, xcoff_ardata_big): Delete. bfd/ * coff-rs6000.c: Replace uses of xcoff_ardata and xcoff_ardata_big throughout file. (_bfd_xcoff_archive_p): Adjust artdata.tdata allocation. (add_range): New function. (_bfd_xcoff_read_ar_hdr): Use it here. Fix memory leak. (_bfd_xcoff_openr_next_archived_file): Remove old sanity checks. Set up range for header. (xcoff_write_archive_contents_old): Make the temporary artdata.tdata used here to pass info down to _bfd_compute_and_write_armap a struct xcoff_artdata. (xcoff_write_archive_contents_big): Likewise. * coff64-rs6000.c: Replace uses of xcoff_ardata and xcoff_ardata_big throughout file. (xcoff64_archive_p): Adjust artdata.tdata allocation.
* Delete struct artdata archive_headAlan Modra2023-04-215-34/+1
| | | | | | | | | | | | This element is unused. Ideally we'd be moving archive_head and other archive specific fields from struct bfd to here, but that's a much larger change than this little bit of cleanup. * libbfd-in.h (struct artdata): Delete archive_head. * libbfd.h: Regenerate. * archive.c, * coff-rs6000.c, * coff64-rs6000.c: Delete comments mentioning artdata archive_head.
* Automatic date update in version.inGDB Administrator2023-04-211-1/+1
|