aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2024-05-08RISC-V: Support B, Zaamo and Zalrsc extensions.Nelson Chu1-4/+16
* https://github.com/riscv/riscv-b/tags Added standard B extension back, which implies Zba, Zbb and Zbs extensions. * https://github.com/riscv/riscv-zaamo-zalrsc/tags Splited standard A extension into two new extensions, Zaamo and Zalrsc. The A extension implies Zaamo and Zalrsc extensions. Not sure if we need to do the similar check as i and zicsr/zifencei. Passed riscv[32|64]-[elf/linux] binutils testcases. bfd/ * elfxx-riscv.c (riscv_implicit_subsets): Added imply rules for A and B extensions. The A implies Zaamo and Zalrsc, the B implies Zba, Zbb and Zbs. (riscv_supported_std_ext): Supported B extension with v1.0. (riscv_supported_std_z_ext): Supported Zaamo and Zalrsc with v1.0. (riscv_multi_subset_supports, riscv_multi_subset_supports_ext): Updated. include/ * opcode/riscv.h (riscv_insn_class): Removed INSN_CLASS_A, Added INSN_CLASS_ZAAMO and INSN_CLASS_ZALRSC. opcodes/ * riscv-opc.c (riscv_opcodes): Splited standard A extension into two new extensions, Zaamo and Zalrsc. gas/ * testsuite/gas/riscv/march-imply-a.d: New testcase. * testsuite/gas/riscv/march-imply-b.d: New testcase. * testsuite/gas/riscv/attribute-01.d: Updated. * testsuite/gas/riscv/attribute-02.d: Updated. * testsuite/gas/riscv/attribute-03.d: Updated. * testsuite/gas/riscv/attribute-04.d: Updated. * testsuite/gas/riscv/attribute-05.d: Updated. * testsuite/gas/riscv/attribute-10.d: Updated. * testsuite/gas/riscv/mapping-symbols.d: Updated. * testsuite/gas/riscv/march-imply-g.d: Updated. * testsuite/gas/riscv/march-imply-unsupported.d: Updated. * testsuite/gas/riscv/march-ok-reorder.d: Updated. ld/ * testsuite/ld-riscv-elf/attr-merge-arch-01.d: Updated. * testsuite/ld-riscv-elf/attr-merge-arch-02.d: Updated. * testsuite/ld-riscv-elf/attr-merge-arch-03.d: Updated. * testsuite/ld-riscv-elf/attr-merge-user-ext-01.d: Updated.
2024-05-08Automatic date update in version.inGDB Administrator1-1/+1
2024-05-07Automatic date update in version.inGDB Administrator1-1/+1
2024-05-06Automatic date update in version.inGDB Administrator1-1/+1
2024-05-05Automatic date update in version.inGDB Administrator1-1/+1
2024-05-04bus error with fuzzed archive elementAlan Modra1-1/+12
* libbfd.c (bfd_mmap_local): Sanity check rsize against actual file offset and size, not an archive element offset and size.
2024-05-04Automatic date update in version.inGDB Administrator1-1/+1
2024-05-03Automatic date update in version.inGDB Administrator1-1/+1
2024-05-02Automatic date update in version.inGDB Administrator1-1/+1
2024-05-01Automatic date update in version.inGDB Administrator1-1/+1
2024-04-30RISC-V: PR29823, defined the missing elf_backend_obj_attrs_handle_unknown.Nelson Chu1-0/+13
bfd/ PR 29823 * elfnn-riscv.c (riscv_elf_obj_attrs_handle_unknown): New function. (elf_backend_obj_attrs_handle_unknown): Defined to riscv_elf_obj_attrs_handle_unknown.
2024-04-30Automatic date update in version.inGDB Administrator1-1/+1
2024-04-29Fix initiali state of DWARF v5 line number table in BFD libraryNick Clifton1-4/+3
PR 30783
2024-04-29Fix building Loongarch BFD with a 32-bit compilerNick Clifton1-1/+1
2024-04-29Automatic date update in version.inGDB Administrator1-1/+1
2024-04-28Automatic date update in version.inGDB Administrator1-1/+1
2024-04-27Automatic date update in version.inGDB Administrator1-1/+1
2024-04-26Automatic date update in version.inGDB Administrator1-1/+1
2024-04-25LoongArch: Add bad static relocation check and output more information to userLulu Cai1-2/+31
Absolute address symbols cannot be used with -shared. We output more information to the user than just BFD_ASSETR.
2024-04-25LoongArch: The symbol got type can only be obtained after initializationLulu Cai1-1/+8
When scanning relocations and determining whether TLS type transition is possible, it will try to obtain the symbol got type. If the symbol got type record has not yet been allocated space and initialized, it will cause ld to crash. So when uninitialized, the symbol is set to GOT_UNKNOWN.
2024-04-25Automatic date update in version.inGDB Administrator1-1/+1
2024-04-24Automatic date update in version.inGDB Administrator1-1/+1
2024-04-23bfd: Remove duplicate word in elf-vxworks.cOlivier Hainque1-1/+1
PR ld/31652 * elf-vxworks.c (elf_vxworks_emit_relocs): Drop duplicate word.
2024-04-23PR31667, objcopy/strip corrupts solaris binariesAlan Modra1-7/+6
Using want_p_paddr_set_to_zero in commit 45d92439aebd was wrong. Even solaris targets don't have want_p_paddr_set_to_zero, but we should handle them at least somewhat reasonably. PR 31667 * elf.c (IS_SECTION_IN_INPUT_SEGMENT): Remove bed arg, add paddr_valid. Don't use bed->want_p_paddr_set_to_zero. (INCLUDE_SECTION_IN_SEGMENT): Likewise. (rewrite_elf_program_header): Adjust to suit.
2024-04-23ignore some symbols in elf.c:swap_out_symsAlan Modra1-55/+48
The reason behind this patch was noticing that generic ELF targets fail to remove "bar" in the recently committed ld-elf/undefweak-1 test. (Despite that, those targets pass the test due to it being too strict when matching symbols. "bar" gets turned into a local weak defined absolute symbol.) swap_out_syms currently drops local section syms that are defined in discarded sections. Extend that to also drop other symbols in discarded sections too, even global symbols. The linker goes to quite a lot of effort to ensure globals in discarded section take a definition from the kept linkonce or comdat group section. So the global sym change should only affect cases where something is quite wrong about the set of linkonce or comdat group sections. However that change to elf_map_symbols meant we dropped _DYNAMIC_LINK / _DYNAMIC_LINKING for mips, a global absolute symbol given STT_SECTION type for some reason. That problem is fixed by reverting the pr14493 change which is no longer needed due to a) BSF_SECTION_SYM_USED on x86, and b) fixing objcopy to use copy_private_symbol_data. bfd/ PR 14493 * elf.c (ignore_sym): Rename from ignore_section_sym. Return true for any symbol without a section or in a discarded section. Revert pr14493 change. (elf_map_symbols): Tidy. Use ignore_sym on all symbols. (swap_out_syms): Tidy. ld/ * testsuite/ld-elf/undefweak-1.rd: Match any "bar".
2024-04-23copy_private_symbol_dataAlan Modra1-2/+2
bfd_copy_private_symbol_data is a bfd function that appeared in commit 89665c8562da a long time ago, but seemingly wasn't used anywhere until Jan added it to gas/symbols.c in commit 6a2b6326c21e. The function is used to modify ELF symbol st_shndx for symbols defined in odd sections like .symtab, so that they get the corresponding section st_shndx in an output file. This patch fixes some bitrot in the function. After commit c03551323c04 which introduced output_elf_obj_tdata, elf_strtab_sec and elf_shstrtab_sec will segfault if used on an input bfd. PR 14493 * elf.c (_bfd_elf_copy_private_symbol_data): Don't use elf_strtab_sec and elf_shstrtab_sec.
2024-04-23Automatic date update in version.inGDB Administrator1-1/+1
2024-04-22Automatic date update in version.inGDB Administrator1-1/+1
2024-04-21Automatic date update in version.inGDB Administrator1-1/+1
2024-04-20Automatic date update in version.inGDB Administrator1-1/+1
2024-04-19Re: elf: Strip unreferenced weak undefined symbolsAlan Modra1-2/+3
PR ld/31652 * elflink.c (_bfd_elf_link_output_relocs): Don't segfault on NULL rel_hash.
2024-04-18elf: Strip unreferenced weak undefined symbolsH.J. Lu3-28/+47
Linker will resolve an undefined symbol only if it is referenced by relocation. Unreferenced weak undefined symbols serve no purpose. Weak undefined symbols appear in the dynamic symbol table only when they are referenced by dynamic relocation. Mark symbols with relocation and strip undefined weak symbols if they don't have relocation and aren't in the dynamic symbol table. bfd/ PR ld/31652 * elf-bfd.h (elf_link_hash_entry): Add has_reloc. * elf-vxworks.c (elf_vxworks_emit_relocs): Set has_reloc. * elflink.c (_bfd_elf_link_output_relocs): Likewise. (elf_link_output_extsym): Strip undefined weak symbols if they don't have relocation and aren't in the dynamic symbol table. ld/ PR ld/31652 * testsuite/ld-elf/elf.exp: Run undefweak tests. * testsuite/ld-elf/undefweak-1.rd: New file. * testsuite/ld-elf/undefweak-1a.s: Likewise. * testsuite/ld-elf/undefweak-1b.s: Likewise. * testsuite/ld-x86-64/weakundef-1.nd: Likewise. * testsuite/ld-x86-64/weakundef-1a.s: Likewise. * testsuite/ld-x86-64/weakundef-1b.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run undefweak tests.
2024-04-19memory leak in bfd/dwarf2.cAlan Modra1-0/+2
* dwarf2.c (_bfd_dwarf2_cleanup_debug_info): Free dwarf_addr_buffer and dwarf_str_offsets_buffer.
2024-04-19Automatic date update in version.inGDB Administrator1-1/+1
2024-04-18HPPA64 linker: Do not force the generation of DT_FLAGS for Linux targets.Nick Clifton1-4/+12
PR 30743
2024-04-18Re: Fix address violations when reading corrupt VMS recordsAlan Modra1-9/+15
Fixes error reports about the length of EEOM records produced by gas. PR 21618 * vms-alpha.c (evax_bfd_print_emh): Don't read subtyp if short record. Consolidate error messages. (evax_bfd_print_eeom): Allow length 10 record.
2024-04-18alpha_vms_get_section_contents vs. fuzzed filesAlan Modra1-24/+26
This patch is in response to an oss-fuzz report regarding use-of-uninitialized-value in bfd_is_section_compressed_info from section contents provided by alpha_vms_get_section_contents. That hole is covered by using bfd_zalloc rather than bfd_alloc. The rest of the patch is mostly a tidy. In a function returning section contents, I tend to prefer a test on the section properties over a test on file properties. That's why I've changed the file flags test to one on section filepos and flags before calling _bfd_generic_get_section_contents. Also, fuzzed objects can easily have sections with file backing in relocatable objects, or sections without file backing in images. Possible confusion is avoided by testing each section. Note that we are always going to run into out-of-memory with fuzzed alpha-vms object files due to sections with contents via ETIR records. eg. ETIR__C_STO_IMMR stores a number of bytes repeatedly, with a 32-bit repeat count. So section contents can be very large from a relatively small file. I'm inclined to think that an out-of-memory error is fine for such files. * vms-alpha.c (alpha_vms_get_section_contents): Handle sections with non-zero filepos or without SEC_HAS_CONTENTS via _bfd_generic_get_section_contents. Zero memory allocated for sections filled by ETIR records.
2024-04-18Automatic date update in version.inGDB Administrator1-1/+1
2024-04-16elf: Skip the archive if the symbol isn't referencedH.J. Lu1-3/+5
Also skip the archive if the symbol isn't referenced by a regular object. bfd/ PR ld/31644 * elflink.c (elf_link_add_archive_symbols): Also skip the archive if the symbol isn't referenced by a regular object. ld/ PR ld/31644 * testsuite/ld-plugin/lto.exp: Run PR ld/31644 tests. * testsuite/ld-plugin/pr31644a.c: New test. * testsuite/ld-plugin/pr31644b.c: Likewise. * testsuite/ld-plugin/pr31644c.c: Likewise.
2024-04-17Automatic date update in version.inGDB Administrator1-1/+1
2024-04-17ARC e_flags vs. objcopyAlan Modra1-6/+6
While the patch that Nick reverted in commit 3f6a060c7543 was in the source, "FAIL: objcopy executable (pr25662)" was seen on ARC. The failure was triggered by the .ARC.attributes section being removed by the linker script. When a file lacking this section is copied by objcopy, e_flags from the input is copied to the output (in this case the value 0x406), but arc_elf_final_write_processing then logical-ors in 0x300 when Tag_ARC_ABI_osver is not found. * elf32-arc.c (arc_elf_final_write_processing): Don't ignore existing e_flags for objcopy.
2024-04-16Avoid cache race in bfd_check_format_matchesTom Tromey5-5/+109
Running the gdb test suite with the thread sanitizer enabled shows a race when bfd_check_format_matches and bfd_cache_close_all are called simultaneously on different threads. This patch fixes this race by having bfd_check_format_matches temporarily remove the BFD from the file descriptor cache -- leaving it open while format-checking proceeds. In this setup, the BFD client is responsible for closing the BFD again on the "checking" thread, should that be desired. gdb does this by calling bfd_cache_close in the relevant worker thread. An earlier version of this patch omitted the "possibly_cached" helper function. However, this ran into crashes in the binutils test suite involving the archive-checking abort in bfd_cache_lookup_worker. I do not understand the purpose of this check, so I've simply had the new function work around it. I couldn't find any comments explaining this situation, either. I suspect that there may still be races related to this case, but I don't think I have access to the platforms where gdb deals with archives. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31264
2024-04-16Thread-safety improvements for bfd_check_format_matchesTom Tromey4-121/+183
A gdb bug found that bfd_check_format_matches has some data races when called from multiple threads. In particular, it changes the BFD error handler, which is a global. It also has a local static variable ("in_check_format") that is used for recursion detection. And, finally, it may emit warnings to the per-xvec warning array, which is a global. This patch removes all the races here. The first part of patch is to change _bfd_error_handler to directly handle the needs of bfd_check_format_matches. This way, the error handler does not need to be changed. This change lets us use the new per-thread global (error_handler_messages, replacing error_handler_bfd) to also remove the need for in_check_format -- a single variable suffices. Finally, the global per-xvec array is replaced with a new type that holds the error messages. The outermost such type is stack-allocated in bfd_check_format_matches. I tested this using the binutils test suite. I also built gdb with thread sanitizer and ran the test case that was noted as failing. Finally, Alan sent me the test file that caused the addition of the xvec warning code in the first place, and I confirmed that "nm-new" has the same behavior on this file both before and after this patch. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31264 Co-Authored-By: Alan Modra <amodra@gmail.com>
2024-04-16Fix test for sections with different VMA<->LMA relationships so that it only ↵Nick Clifton1-6/+13
applies to allocated sections, and only sections in the same segment are checked. PR 31450
2024-04-16Remove debug printout from 9dd918142787246ea7ed53494d9cbc6b51486133Simon Cook1-2/+0
2024-04-16Automatic date update in version.inGDB Administrator1-1/+1
2024-04-15Remove dependency upon shlwapi library when building BFD for Windows/MinGW ↵Nick Clifton1-12/+56
environments. PR 31527
2024-04-15When mapping sections to segments ensure that we do not add sections whose ↵Vijay Shankar1-3/+9
VMA->LMA relationship does not match the relationship of earlier sections in the segment. PR 31540
2024-04-15LoongArch: ld:Report an error when seeing an unrecognized relocationLulu Cai1-2/+7
If we generate an object file using an assembler with the new relocations added, and then linking those files with an older linker, the link will still complete and the linked file will be generated. In this case we should report an error instead of continuing the linking process.
2024-04-15Automatic date update in version.inGDB Administrator1-1/+1