aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2024-12-13Automatic date update in version.inGDB Administrator1-1/+1
2024-12-12Fix races involving _bfd_section_idTom Tromey5-2/+43
BFD's threading approach is that global variables are guarded by a lock. However, while implementing this, I missed _bfd_section_id. A user pointed out, via Thread Sanitizier, that this causes a data race when gdb's background DWARF reader is enabled. This patch fixes the problem by using the BFD lock in most of the appropriate spots. However, in ppc64_elf_setup_section_lists I chose to simply assert that multiple threads are not in use instead. (Not totally sure if this is good, but I don't think this can be called by gdb.) I chose locking in bfd_check_format_matches, even though it is a relatively big hammer, because it seemed like the most principled approach, and anyway if this causes severe contention we can always revisit the decision. Also this approach means we don't need to add configury to check for _Atomic, or figure out whether bfd_section_init can be reworded to make "rollback" unnecessary. I couldn't reproduce these data races but the original reporter tested the patch and confirms that it helps. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31713
2024-12-12mangle_style: Add new DWARF5 constantsAlexandra Hájková1-0/+10
Update bfd/dwarf2.c with the post DWARF5 language codes which were added after DWARF5 was finalized. Adding them makes it possible to return the mangling style for the new language codes for Ada 2005 Fortran, C++, C and Assembly. Reviewed-By: Andrew Burgess <aburgess@redhat.com> Approved-By: Jan Beulich <jbeulich@suse.com>
2024-12-12Revert bfd_use_reserved_id patchAlan Modra2-20/+2
Commit fc1cfaa5f1 and bc110b6e40 were made to avoid testsuite regressions on a number of targets that used bfd id in symbol hashing. Since it no longer seems necessary to start plugin bfd id's from -1 and count down, revert the functional changes in those patches.
2024-12-12Use bfd id to validate dwarf2 cacheAlan Modra1-8/+5
Using a bfd pointer to validate the cache isn't very robust. If a bfd is closed somehow without clearing the cache, then it's possible that another bfd is opened using the same memory and thus orig_bfd compares equal to the new bfd. * dwarf2.c (struct dwarf2_debug): Add orig_bfd_id. Delete orig_bfd. (_bfd_dwarf2_slurp_debug_info): Validate stash with orig_bfd_id.
2024-12-12tdata related object_p tidy for various formatsAlan Modra14-145/+92
The aout object_p function copies any existing tdata. Apparently this was done for hp300, an old target that is no longer supported. See commit ebd241352942. This isn't useful for current sources, nor is it necessary or useful any more to preserve tdata in object_p functions when a target doesn't match. When I was fixing this, I noticed some object_p functions rudely didn't release memory on failures, and others had nits in the bfd_error returns. * aoutx.h (some_aout_object_p): Don't restore previous tdata on failure. Don't copy any existing tdata. * archive.c (bfd_generic_archive_p): Don't restore previous tdata on failure. * pdp11.c (some_aout_object_p): Likewise. * coff-rs6000.c (_bfd_xcoff_archive_p): Allocate both artdata and extension in one call. Don't restore previous tdata on failure. * coff64-rs6000.c (xcoff64_archive_p): Likewise. * coffgen.c (coff_real_object_p): Don't restore previous tdata on failure. * ihex.c (ihex_object_p): Likewise. Simplify release of tdata on scan failure. * mach-o.c (bfd_mach_o_scan): Don't set tdata here. Do set error on read_command failure. (bfd_mach_o_header_p): Set tdata here, release on failure. Tidy bfd_error return values. (bfd_mach_o_fat_archive_p): Tidy error return values. * mmo.c (mmo_mkobject): Do not test current tdata. * pef.c (bfd_pef_scan_start_address): Set bfd_error on failure. (bfd_pef_scan): Don't set tdata here. (bfd_pef_object_p): Set tdata here, release on failure. Tidy bfd_error return values. (bfd_pef_xlib_object_p): Tidy bfd_error return values. * srec.c (srec_object_p): Don't restore previous tdata on failure. Do release tdata on failure. (symbolsrec_object_p): Likewise. * tekhex.c (tekhex_object_p): Don't ignore tekhex_mkobject failure. Release tdata on failure. * vms-alpha.c (alpha_vms_object_p): Don't restore previous tdata on failure. Simplify release of tdata. * xsym.c (bfd_sym_scan): Don't set tdata here. (bfd_sym_object_p): Set tdata here. Release on failure.
2024-12-12Automatic date update in version.inGDB Administrator1-1/+1
2024-12-11Automatic date update in version.inGDB Administrator1-1/+1
2024-12-10LoongArch: Default to a maximum page size of 64KiBWANG Xuerui2-1/+9
As per the spec (Section 7.5.10, LoongArch Reference Manual Vol. 1), LoongArch machines are not limited in page size choices, and currently page sizes of 4KiB, 16KiB and 64KiB are supported by mainline Linux. While 16KiB is the most common, the current BFD code says it is the maximum; this is not correct, and as an effect, almost all existing binaries are incompatible with a 64KiB kernel because the sections are not sufficiently aligned, while being totally fine otherwise. This is needlessly complicating integration testing [1]. This patch fixes the inconsistency, and also brings BFD behavior in line with that of LLD [2]. [1] https://github.com/loongson-community/discussions/issues/47 [2] https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/lld/ELF/Arch/LoongArch.cpp#L174-L183 bfd/ * elfnn-loongarch.c (ELF_MAXPAGESIZE): Bump to 64KiB. (ELF_MINPAGESIZE): Define as 4KiB. (ELF_COMMONPAGESIZE): Define as 16KiB. ld/ * testsuite/ld-loongarch-elf/64_pcrel.d: Update assertions after changing the target max page size to 64KiB. * testsuite/ld-loongarch-elf/data-got.d: Likewise. * testsuite/ld-loongarch-elf/desc-relex.d: Likewise. * testsuite/ld-loongarch-elf/relax-align-ignore-start.d: Likewise. * testsuite/ld-loongarch-elf/tlsdesc_abs.d: Make the fuzzy match work as intended by not checking exact instruction words. * testsuite/ld-loongarch-elf/tlsdesc_extreme.d: Likewise. Signed-off-by: WANG Xuerui <git@xen0n.name>
2024-12-10Automatic date update in version.inGDB Administrator1-1/+1
2024-12-09Automatic date update in version.inGDB Administrator1-1/+1
2024-12-08Automatic date update in version.inGDB Administrator1-1/+1
2024-12-07Automatic date update in version.inGDB Administrator1-1/+1
2024-12-06RISC-V: PR27566, consider ELF_MAXPAGESIZE/COMMONPAGESIZE for gp relaxations.Nelson Chu1-2/+27
For default linker script, if a symbol's value outsides the bounds of the defined section, then it may cross the data segment alignment, so we should reserve more size about MAXPAGESIZE and COMMONPAGESIZE when doing gp relaxations. Otherwise we may meet the truncated errors since the data segment alignment might move the section forward. bfd/ PR 27566 * elfnn-riscv.c (_bfd_riscv_relax_lui): Consider MAXPAGESIZE and COMMONPAGESIZE if the symbol's value outsides the bounds of the defined section. (_bfd_riscv_relax_pc): Likewise. ld/ PR 27566 * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. * testsuite/ld-riscv-elf/relax-data-segment-align*: New testcase for pr27566. Without this patch, the rv32 binutils will meet truncated errors for this testcase.
2024-12-06Automatic date update in version.inGDB Administrator1-1/+1
2024-12-05Automatic date update in version.inGDB Administrator1-1/+1
2024-12-04Automatic date update in version.inGDB Administrator1-1/+1
2024-12-03Updated Russian translation and new Malay translation for the BFD sub-directoryNick Clifton1-0/+9711
2024-12-03LoongArch: Fix the infinite loop caused by calling undefweak symbolLulu Cai1-0/+39
The undefweak symbol value of non-default visibility is 0 and does not use plt entry, and will not be relocated in the relocate_secion function. As a result, an infinite loop is generated because bl %plt(sym) => bl 0. Fix this by converting the call into a jump address 0.
2024-12-03Automatic date update in version.inGDB Administrator1-1/+1
2024-12-02aarch64: GCS feature check in GNU note properties for input objectsSrinath Parvathaneni3-4/+114
This patch adds support for Guarded Control Stack in AArch64 linker. This patch implements the following: 1) Defines GNU_PROPERTY_AARCH64_FEATURE_1_GCS bit for GCS in GNU_PROPERTY_AARCH64_FEATURE_1_AND macro. 2) Adds readelf support to read and print the GCS feature in GNU properties in AArch64. Displaying notes found in: .note.gnu.property [ ]+Owner[ ]+Data size[ ]+Description GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 Properties: AArch64 feature: GCS 3) Adds support for the "-z gcs" linker option and document all the values allowed with this option (-z gcs[=always|never|implicit]) where "-z gcs" is equivalent to "-z gcs=always". When '-z gcs' option is omitted from the command line, it defaults to "implicit" and relies on the GCS feature marking in GNU properties. 4) Adds support for the "-z gcs-report" linker option and document all the values allowed with this option (-z gcs-report[=none|warning|error]) where "-z gcs-report" is equivalent to "-z gcs-report=warning". When this option is omitted from the command line, it defaults to "warning". The ABI changes adding GNU_PROPERTY_AARCH64_FEATURE_1_GCS to the GNU property GNU_PROPERTY_AARCH64_FEATURE_1_AND is merged into main and can be found in [1]. [1] https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst Co-authored-by: Matthieu Longo <matthieu.longo@arm.com> Co-authored-by: Yury Khrustalev <yury.khrustalev@arm.com>
2024-12-02aarch64: rename BTI error/warning messageMatthieu Longo1-4/+4
The previous message for missing BTI feature in GNU properties was not very clear. The new message explains that a missing GNU property marking is lacking on this specific input.
2024-12-02aarch64: limit number of reported issues on missing GNU propertiesMatthieu Longo3-0/+35
This patch attempts to make the linker output more friendly for the developers by limiting the number of emitted warning/error messages related to BTI issues. Every time an error/warning related to BTI is emitted, the logger also increments the BTI issues counter. A batch of errors/warnings is limited to a maximum of 20 explicit errors/warnings. At the end of the merge, a summary of the total of errors/warning is given if the number exceeds the limit of 20 invidual messages.
2024-12-02aarch64: bugfix when finding 1st bfd input with GNU propertyMatthieu Longo1-1/+6
The current implementation of searching the first input BFD with GNU properties has a bug. The search was not filtering on object inputs belonging to the output link unit only, but was also including dynamic objects, BFD plugins, and linker-created files. This means that the initial initialization of the output properties were skewed, and warnings on input files that should have been emitted were not. This patch fixes the filtering to exclude the object input files not belonging to the output link unit, not having the same ELF class, and not the same target architecture.
2024-12-02aarch64: remove early exit when setting up GNU properties with partial linkingMatthieu Longo1-3/+0
There is an early exit in _bfd_aarch64_elf_link_setup_gnu_properties that is enabled when the output link unit is relocatable, i.e. ld generates an output file that can in turn serve as input to ld. (see ld manual, -r,--relocatable for more details). At this stage, the GNU properties have already been merged and errors or warnings (if any) have already been issued. However, OUTPROP has not been updated yet. Not updating OUTPROP means that implicits enablement of BTI PLTs via the GNU properties will be ignored for final links. Indeed, the enablement of BTI PLTs is checked inside _bfd_aarch64_add_call_stub_entries by looking up at gnu_property_aarch64_feature_1_and (OUTPROP). Since the final link does not happen in the case of partial linking, the behaviour with or without the early exit should be the same. Given that there is currently no comment for explain why the exit is there, and that there might in the future be cases were these properties affect relocatable links, it is preferrable to drop the early exit.
2024-12-02aarch64: refactoring _bfd_aarch64_elf_link_setup_gnu_properties (part 5)Matthieu Longo1-18/+24
Use _bfd_aarch64_elf_check_bti_report to report any BTI issue on the first input object.
2024-12-02aarch64: refactoring _bfd_aarch64_elf_link_setup_gnu_properties (part 4)Matthieu Longo1-22/+27
Move the code related to the creation of the gnu.note section to a separate function: _bfd_aarch64_elf_create_gnu_property_section
2024-12-02aarch64: refactoring _bfd_aarch64_elf_link_setup_gnu_properties (part 3)Matthieu Longo1-16/+34
Move the code related to the search of the first bfd input with GNU properties to a separate function: _bfd_aarch64_elf_find_1st_bfd_input_with_gnu_property
2024-12-02aarch64: refactoring _bfd_aarch64_elf_link_setup_gnu_properties (part 2)Matthieu Longo1-9/+10
Simplify this for-loop with too many "break" instructions inside.
2024-12-02aarch64: refactoring _bfd_aarch64_elf_check_bti_reportMatthieu Longo3-11/+12
Before this patch, warnings were reported normally, and errors (introduced by a previous patch adding '-z bti-report' option) were logged as error but were not provoking a link failure. The root of the issue was a misuse of _bfd_error_handler to report the errors. Replacing _bfd_error_handler by info->callbacks->einfo, with the addition of the formatter '%X' for errors fixed the issue.
2024-12-02aarch64: refactoring _bfd_aarch64_elf_link_setup_gnu_properties (part 1)Matthieu Longo3-33/+41
Exposing the output GNU property as a parameter of _bfd_aarch64_elf_link_setup_gnu_properties seems to break the encapsulation. The output GNU property update should be part of the function that sets up the GNU properties. This patch removes the parameter, and perform the update of the GNU property on the output object inside the function.
2024-12-02aarch64: rename gnu_and_prop to gnu_property_aarch64_feature_1_andMatthieu Longo2-19/+19
2024-12-02aarch64: simplify condition in elfNN_aarch64_merge_gnu_propertiesMatthieu Longo1-4/+2
The current condition used to check if a GNU feature property is set on an input object before the merge is a bit confusing. (aprop && !<something about aprop>) || !aprop It seems easier to understand if it is changed as follows: (!aprop || !<something about aprop>)
2024-12-02aarch64: rename parameter of _bfd_aarch64_elf_merge_gnu_propertiesMatthieu Longo1-9/+9
The current naming of the AArch64 feature GNU property of the output bfd does not reflect what it is. This patch renames it from "prop" to "outprop".
2024-12-02aarch64: use only one type for feature marking reportMatthieu Longo3-19/+25
2024-12-02aarch64: group software protection options under a same struct.Matthieu Longo3-67/+88
- declare a new struc aarch_protection_opts to store all the configuration options related to software protections (i.e. bti-plt, pac-plt, bti-report level). - add a new option "-z bti-report" to configure the log level of reported issues when BTI PLT is forced. - encapsulate the BTI report inside _bfd_aarch64_elf_check_bti_report.
2024-12-02RISC-V: Add support for ssdbltrp and smdbltrp extension.Dongyan Chen1-0/+4
This implements the ssdbltrp extensons, version 1.0[1] and the smdbltrp extensions, version1.0[2]. [1] https://github.com/riscv/riscv-isa-manual/blob/main/src/ssdbltrp.adoc [2] https://github.com/riscv/riscv-isa-manual/blob/main/src/smdbltrp.adoc bfd/ChangeLog: * elfxx-riscv.c: Add 'ssdbltrp' and 'smdbltrp' to the list of konwn standard extensions. gas/ChangeLog: * NEWS: Updated. * testsuite/gas/riscv/imply.d: Ditto. * testsuite/gas/riscv/imply.s: Ditto. * testsuite/gas/riscv/march-help.l: Ditto.
2024-12-02Automatic date update in version.inGDB Administrator1-1/+1
2024-12-01Correct hpux-core.c thread_section_p signatureAlan Modra1-1/+1
Fix fallout from commit 0a1b45a20eaa.
2024-12-01Re: PR32399, buffer overflow printing core_file_failing_commandAlan Modra6-21/+31
Fix more potential buffer overflows, and correct trad-code.c and cisco-core.c where they should be using bfd_{z}alloc rather than bfd_{z}malloc. To stop buffer overflows with fuzzed objects that don't have a terminator on the core_file_failing_command string, this patch allocates an extra byte at the end of the entire header buffer rather than poking a NUL at the end of the name array (u_comm[] or similar) because (a) it's better to not overwrite the file data, and (b) it is possible that some core files make use of fields in struct user beyond the end of u_comm to extend the command name. The patch also changes some unnecessary uses of bfd_zalloc to bfd_alloc. There's not much point in clearing memeory that will shortly be completely overwritten. PR 32399 * aix5ppc-core.c (xcoff64_core_p): Allocate an extra byte to ensure the core_file_failing_command string is terminated. * netbsd-core.c (netbsd_core_file_p): Likewise. * ptrace-core.c (ptrace_unix_core_file_p): Likewise. * rs6000-core.c (rs6000coff_core_p): Likewise. * trad-core.c (trad_unix_core_file_p): Likewise, and bfd_alloc tdata rather than bfd_zmalloc. * cisco-core.c (cisco_core_file_validate): bfd_zalloc tdata.
2024-12-01Automatic date update in version.inGDB Administrator1-1/+1
2024-11-30Automatic date update in version.inGDB Administrator1-1/+1
2024-11-29PR32399, buffer overflow printing core_file_failing_commandAlan Modra6-7/+12
Assorted targets do not check, as the ELF targets do, that the program name in a core file is NUL terminated. Fix some of them. I haven't attempted to fix all targets because editing host specific code can easily result in build bugs, which aren't discovered until someone build binutils for that host. (Of the files edited here, I can't easily compile hpux-core.c and osf-core.c on a linux system.) PR 32399 * hppabsd-core.c (hppabsd_core_core_file_p): Ensure core_command string is terminated. * hpux-core.c (hpux_core_core_file_p): Likewise. * irix-core.c (irix_core_core_file_p): Likewise. * lynx-core.c (lynx_core_file_p): Likewise. * osf-core.c (osf_core_core_file_p): Likewise. * mach-o.c (bfd_mach_o_core_file_failing_command): Likewise.
2024-11-29Automatic date update in version.inGDB Administrator1-1/+1
2024-11-28Automatic date update in version.inGDB Administrator1-1/+1
2024-11-27PE LD: Merge .CRT .ctors and .dtors into .rdataLiu Hao1-1/+2
PR 32264
2024-11-27Re: nios2: Remove binutils support for Nios II targetAlan Modra2-3/+1
Remove a now unused config file, regenerate POTFILES to remove nios2 refs, and modify config.bfd to report the target is obsolete.
2024-11-27Automatic date update in version.inGDB Administrator1-1/+1
2024-11-26nios2: Remove binutils support for Nios II target.Sandra Loosemore15-6461/+2
The Nios II architecture has been EOL'ed by the vendor. This patch removes all binutils, bfd, gas, binutils, and opcodes support for this target with the exception of the readelf utility. (The ELF EM_* number remains valid and the relocation definitions from the Nios II ABI will never change in future, so retaining the readelf support seems consistent with its purpose as a utility that tries to parse the headers in any ELF file provided as an argument regardless of target.)
2024-11-26PR32387 ppc64 TLS optimization bug with -fno-plt codeAlan Modra1-0/+9
The inline plt code emitted by gcc is incompatible with the linker/ld.so --tls-get-addr-optimize scheme. This is the runtime optimisation where the first call to __tls_get_addr results in __tls_get_addr updating the tls_index pair, then the special linker stub using that to short-circuit second and subsequent calls for a given tls symbol. Enabled by default when the linker sees __tls_get_addr_opt is preseent, and enabled in ld.so when DT_PPC64_OPT has PPC64_OPT_TLS set. Note that this is distinct from link-time tls optimisation. PR 32387 * elf64-ppc.c (ppc64_elf_check_relocs): Disable tls_get_addr_opt on detecting inline plt calls to __tls_get_addr.