aboutsummaryrefslogtreecommitdiff
path: root/bfd
AgeCommit message (Collapse)AuthorFilesLines
2025-12-10Automatic date update in version.inHEADmasterGDB Administrator1-1/+1
2025-12-10x86: Add _bfd_elf_x86_copy_special_section_fieldsH.J. Lu4-96/+18
When Linux/x86 objcopy is used on Solaris binary, it sets EI_OSABI to ELFOSABI_SOLARIS, but it doesn't set the sh_info and sh_link fields of Solaris specific sections. Add _bfd_elf_x86_copy_special_section_fields to return false for Solaris binary to properly set the sh_info and sh_link fields of Solaris specific sections. PR binutils/33705 * elf32-i386.c (elf32_i386_copy_solaris_special_section_fields): Removed. (elf_backend_copy_special_section_fields): Likewise. * elf64-x86-64.c (elf64_x86_64_copy_solaris_special_section_fields): Likewise. (elf_backend_copy_special_section_fields): Likewise. * elfxx-x86.c (_bfd_elf_x86_copy_special_section_fields): New. * elfxx-x86.h (_bfd_elf_x86_copy_special_section_fields): Likewise. (elf_backend_copy_special_section_fields): Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-12-09BFD: Unify relocation error reportingMaciej W. Rozycki5-174/+103
A couple of targets use virtually the same code for error reporting in relocation processing. Merge the copies, removing small discrepancies such as a fallback call to `abort' for NDS32 targets as per PR 17512, and factor out for backends to use.
2025-12-09tail recursion in _bfd_elf_link_hide_symbolAlan Modra1-5/+3
We can clear the flags first if no backend hide_symbol function tests or sets them, which is true. * elflink.c (_bfd_elf_link_hide_symbol): Clear flags before calling elf_backend_hide_symbol, to enable tail recursion.
2025-12-09Automatic date update in version.inGDB Administrator1-1/+1
2025-12-09i386: Add GLIBC_ABI_GNU_TLS dependency only if usedH.J. Lu1-1/+2
Add GLIBC_ABI_GNU_TLS version dependency only if ___tls_get_addr is referenced by regular object. bfd/ PR ld/33287 PR ld/33702 * elfxx-x86.c (_bfd_x86_elf_link_check_relocs): Set has_tls_get_addr_call only if referenced by regular object. ld/ PR ld/33287 PR ld/33702 * testsuite/ld-i386/i386.exp: Run PR ld/33702 test. * testsuite/ld-i386/no-tls.c: New file. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-12-08bfd: fix build with C23Guinevere Larsen3-21/+24
Starting in C23, strchr and strrchr will return const char *, if fed a const char *. This means that several files in the BFD directory will fail to build as they are assigning the return of those functions to a char *. Fix this by const-ifying several variables. The only place where that wasn't just that was in targets.c, where a variable was being used in subsequent strrchr invocations to change the underlying string, so a new variable had to be introduced. No user-visible change should happen after this commit.
2025-12-08Automatic date update in version.inGDB Administrator1-1/+1
2025-12-07Automatic date update in version.inGDB Administrator1-1/+1
2025-12-06hppa64: Set has_local_dynsyms when adding __text_seg/__data_segH.J. Lu1-0/+2
commit 54fbc12d6404b645363f901110a21f4410067df5 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Nov 28 16:07:57 2025 +0800 elf: Renumber local dynamic symbols only if needed caused regressions for hppa64-linux which adds local dynamic symbols, __text_seg and __data_seg in elf64_hppa_late_size_sections. Set has_local_dynsyms to true when adding __text_seg and __data_seg. * elf64-hppa.c (elf64_hppa_late_size_sections): Set has_local_dynsyms to true when adding __text_seg and __data_seg. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-12-06Automatic date update in version.inGDB Administrator1-1/+1
2025-12-05x86-64: use BFD_RELOC_32_PLT_PCREL in favor of custom typeJan Beulich4-5/+1
No reason to have a separate type when the generic one has no (other) meaning for this target.
2025-12-05x86-64: use BFD_RELOC_64_PLTOFF in favor of custom typeJan Beulich4-5/+1
No reason to have a separate type when the generic one has no (other) meaning for this target.
2025-12-05bfd: drop BFD_RELOC_VPE4KMATH_*Jan Beulich3-12/+0
These relocation types are entirely unused.
2025-12-05bfd: drop BFD_RELOC_I370_D12Jan Beulich3-9/+0
i370 support is long gone from binutils, and this relocation is entirely unused.
2025-12-05Automatic date update in version.inGDB Administrator1-1/+1
2025-12-04Automatic date update in version.inGDB Administrator1-1/+1
2025-12-03Automatic date update in version.inGDB Administrator1-1/+1
2025-12-02x86: traverse loc_hash_table only if usedH.J. Lu4-14/+24
Traverse x86 loc_hash_table only if it is used. * elf32-i386.c (elf_i386_output_arch_local_syms): Traverse loc_hash_table only if has_loc_hash_table is set. * elf64-x86-64.c (elf_x86_64_output_arch_local_syms): Likewise. * elfxx-x86.c (_bfd_elf_x86_get_local_sym_hash): Set has_loc_hash_table. (_bfd_x86_elf_late_size_sections): Traverse loc_hash_table only if has_loc_hash_table is set. * elfxx-x86.h (elf_x86_link_hash_table): Move plt0_pad_byte and add has_loc_hash_table. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-12-02mips regression fixesAlan Modra1-1/+1
Commit 54fbc12d64 introduced mips-linux testsuite regressions. +FAIL: MIPS magic __ehdr_start symbol test 1 (o32) +FAIL: PR ld/21334 MIPS GOT16 relocation in static binary +FAIL: PR ld/21375 in SVR4 executable (hidden) These are all assertion failures in mips_elf_sort_hash_table BFD_ASSERT (hsd.max_local_dynindx <= htab->root.local_dynsymcount + 1); This was a pre-existing problem exposed by commit 54fbc12d64. * elfxx-mips.c (mips_elf_sort_hash_table): Properly test for no dynsyms.
2025-12-02Automatic date update in version.inGDB Administrator1-1/+1
2025-12-01Automatic date update in version.inGDB Administrator1-1/+1
2025-11-30elf: Properly place base symbols in DT_GNU_HASH and DT_HASHH.J. Lu2-4/+53
The base symbol, a symbol with the empty version string, created by asm (".symver foo_base, foo@"); is used to provide a compatibility symbol in a versioned shared library for binaries linked against the previous unversioned shared library. The dynamic linker will pick the first match to resolve the unversioned symbol reference. If the newest version, VERS_1, asm (".symver foo_v1, foo@@VERS_1"); is picked before the base symbol in DT_GNU_HASH and DT_HASH, foo@@VERS_1, instead of foo@, will be used to resolve the unversioned reference. Properly place base symbols in DT_GNU_HASH and DT_HASH so that they will be picked first. Also check defined function symbol, foo, and undefined function symbol, bar, separately to support different dynamic symbol orders. bfd/ PR ld/33577 PR ld/33673 * elf-bfd.h (elf_link_hash_entry): Add base_symbol. (elf_link_hash_table): Add has_base_symbols. * elflink.c (_bfd_elf_merge_symbol): Set base_symbol and has_base_symbols if the version string is empty. (collect_gnu_hash_codes): Add base_symbol. (elf_gnu_hash_process_symidx): Skip if base symbol doesn't match. (bfd_elf_size_dynsym_hash_dynstr): If there are base symbols, output base symbols first in DT_GNU_HASH. (elf_outext_info): Add base_symbol. (elf_link_output_extsym): Skip if base symbol doesn't match. (_bfd_elf_final_link): If there are base symbols, output base symbols last in DT_HASH. ld/ PR ld/33577 PR ld/33673 * testsuite/ld-elfvers/pr33577-unversioned.rd: Removed. * testsuite/ld-elfvers/pr33577-versioned.rd: Likewise. * testsuite/ld-elfvers/pr33577-unversioned-a.rd: New file. * testsuite/ld-elfvers/pr33577-unversioned-b.rd: Likewise. * testsuite/ld-elfvers/pr33577-versioned-a.rd: Likewise. * testsuite/ld-elfvers/pr33577-versioned-b.rd: Likewise. * ld-elfvers/vers.exp (base_symbol_test): New. Run PR ld/33673 tests. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-11-30elf: Renumber local dynamic symbols only if neededH.J. Lu2-4/+11
Only hppa, ia64 and sparc ELF targets use local dynamic symbols. But elf_link_renumber_local_hash_table_dynsyms is always called to renumber local dynamic symbols even if there is none. Add has_local_dynsyms to elf_link_hash_table and set it to true only if there are local dynamic symbols. Renumber local dynamic symbols only if there are local dynamic symbols. * elf-bfd.h (elf_link_hash_table): Add has_local_dynsyms. * elflink.c (_bfd_elf_link_renumber_dynsyms): Renumber local dynamic symbols only if there are local dynamic symbols. (_bfd_elf_adjust_dynamic_symbol): Set has_local_dynsyms if there are local dynamic symbols. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-11-30ELF symbol version output cleanupAlan Modra1-12/+5
* elflink.c (elf_link_output_extsym): Localise code setting VERSYM_HIDDEN to previous branch of "if" where def_regular might be true. Delete noversion. Set vs_vers to zero instead.
2025-11-30bfd: fix potential missing seekRoman Kapl1-0/+1
If a file was closed by cache and then bfd_open_file was called followed by e.g. bfd_seek to the original position, the seek would be optimized out while the real file position was still zero (as fopened). I added `bfd_io_force` to force the seek at next IO occasion. This could lead e.g. to appearence of a corrupted object in ld: symbol number 0 uses unsupported binding of 6 or invalid string offset #X >= #Y for section Signed-off-by: Roman Kapl <code@rkapl.cz>
2025-11-30Automatic date update in version.inGDB Administrator1-1/+1
2025-11-29Automatic date update in version.inGDB Administrator1-1/+1
2025-11-28ld: support most modifiers for printf() like vfinfo() format specifiersJan Beulich1-1/+1
Not doing so is pretty error prone: One needs to distinguish e.g. ->einfo() and alike invocations out of libbfd from _bfd_error_handler() ones. Omit support for * though for now, as that would be more intrusive to implement. Use this then to disambiguate x86'es ISA level diagnostic of unknown bits, where decimal vs hex isn't immediately clear.
2025-11-28Automatic date update in version.inGDB Administrator1-1/+1
2025-11-27Obsolete support for Solaris < 10Rainer Orth1-0/+4
Support for Solaris 8 and 9 has long been removed from GCC: * Solaris 8 support in GCC 4.8 (2013) * Solaris 9 support in GCC 5 (2015) so it's time to obsolete anything before Solaris 10 in binutils, too. Both wouldn't even build since binutils 2.41. Tested on both i386-pc-solaris2.8 (with and without --enable-obsolete) and i386-pc-solaris2.11. 2025-11-26 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> bfd: * config.bfd <*-*-solaris2.[0-9]*>: Obsolete.
2025-11-27Automatic date update in version.inGDB Administrator1-1/+1
2025-11-27PR 33453 linker generated .eh_frameAlan Modra6-40/+58
This is the final piece to fix the PR33453 testcase. It makes use of the extended size final link buffer when writing linker generated .eh_frame. PR 33453 * elf-bfd.h (_bfd_elf_write_linker_section_eh_frame): Declare. * elf-eh-frame.c (_bfd_elf_write_linker_section_eh_frame): New. * elf32-ppc.c (ppc_elf_finish_dynamic_sections): Use new function. * elf64-ppc.c (ppc64_elf_finish_dynamic_sections): Likewise. * elf64-s390.c (elf_s390_finish_dynamic_sections): Likewise. * elfxx-x86.c (_bfd_x86_elf_finish_dynamic_sections): Likewise.
2025-11-27PR 33453 backend_finish_dynamic_sections final link bufferAlan Modra52-64/+115
This adds a pointer parameter to backend_finish_dynamic_sections, to give the function access to the final link section contents buffer. The patch is entirely mechanical changes in preparation for the next patch. No use is made of the buffer here.
2025-11-27PR 33453 allow extra for .eh_frame in final link bufferAlan Modra1-4/+15
The PR33453 testcase overflows a buffer allocated for the .eh_frame section. This happens with a silly large alignment for .eh_frame, creating a large gap between two .eh_frame sections. When the last FDE of the first section is stretched to cover the gap, we get a buffer overflow. This patch makes the final link buffer large enough to cover such gaps. It doesn't fix the testcase yet, because there the first .eh_frame section in question is the x86 plt_eh_frame section which uses a different buffer. However, similar testcases could be constructed using object file .eh_frame sections. PR 33453 * elflink.c (bfd_elf_final_link): Round up max_contents_size for .eh_frame alignment.
2025-11-27Tidy .eh_frame rawsize manipulationAlan Modra3-11/+16
bfd_elf_discard_info is only called once. Well, it was until commit 9b854f169df9 introduced cmdline_emit_object_only_section, but I think and hope that function does enough reinitialisation to not cause a problem. There would be a problem if bfd_elf_discard_info was called iteratively, shrinking an eh_frame section on the first pass, then further shrinking on another pass. That's because _bfd_elf_discard_section_eh_frame uses rawsize to store the last section size, which is against the general rules for input sections. rawsize needs to be kept as the initial size to be able to read section contents again (or you'd need to cache the edited contents). Other eh_frame functions would break too. So this tidy makes it obvious when looking at _bfd_elf_discard_section_eh_frame alone that rawsize is only set once, to the initial size. There are no functional changes here. * elf-bfd.h (_bfd_elf_discard_section_eh_frame): Update decl. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Return an int status. Don't set rawsize unless it is zero. * elflink.c (bfd_elf_discard_info): Use new return status from _bfd_elf_discard_section_eh_frame rather than comparing section size with rawsize.
2025-11-26Automatic date update in version.inGDB Administrator1-1/+1
2025-11-25LoongArch: set PRSTATUS_SIZE=0x1e0 to match kernel's struct elf_prstatus sizelijian11-1/+1
As PRSTATUS_SIZE is now with the value 0x1d8, which causes inconsistency with the kernel definition and then can not lead to the correct branch for loongarch64 backend. With the correct value 0x1e0 for the master branch, the loongarch64 banckend will work well. Signed-off-by: Li Jian <lijian1@kylinos.cn>
2025-11-24hppa64: Fix bogus warning from elf_hppa_final_link_relocateJohn David Anglin1-1/+2
2025-11-24 John David Anglin <danglin@gcc.gnu.org> bfd/ChangeLog: * elf64-hppa.c (elf_hppa_final_link_relocate): Initialize opd_off.
2025-11-25Automatic date update in version.inGDB Administrator1-1/+1
2025-11-24hppa64: Fix R_PARISC_LTOFF_FPTR64 and R_PARISC_LTOFF_TP64 relocation supportJohn David Anglin1-203/+193
The elf_hppa_final_link_relocate function didn't handle R_PARISC_LTOFF_FPTR64 and R_PARISC_LTOFF_TP64 relocations for local symbols. DLT and OPD output relocation support for local symbols is consolidated in elf_hppa_dlt_dynrel_reloc() and elf_hppa_opd_dynrel_relocs(). 2025-11-24 John David Anglin <danglin@gcc.gnu.org> bfd/ChangeLog: * elf64-hppa.c (elf_hppa_dlt_dynrel_reloc): New. (elf_hppa_opd_dynrel_relocs): New. (elf_hppa_final_link_relocate): Use elf_hppa_dlt_dynrel_reloc() and elf_hppa_opd_dynrel_relocs(). Fix relocation support for R_PARISC_LTOFF_FPTR64 and R_PARISC_LTOFF_TP64.
2025-11-25PR 33474 SEGV in init_reloc_cookieAlan Modra1-0/+2
This segfault is triggered by a tekhex input. PR 33474 * elflink.c (bfd_elf_gc_sections): Don't try to parse .eh_frame in non-ELF input files.
2025-11-25PR 33473 SEGV in _bfd_elf_gc_mark_debug_special_section_groupAlan Modra2-5/+8
The code that faulted made the assumption that a group section always had at least one valid member. Fix that assumption. Also fail if all entries in a SHT_GROUP section are invalid. (An empty group will not result in a call to process_sht_group_entries.) PR 33473 * elflink.x (_bfd_elf_gc_mark_debug_special_section_group): Don't segfault on empty group. * elf.c (process_sht_group_entries): Return false if all entries are invalid.
2025-11-24Use version index 1 for defined symbolsMichael Matz1-7/+1
It's reasonable to use version index 0 for undefined symbols, so let's continue doing that. For defined (global) symbols that aren't otherwise versioned continue using VER_NDX_GLOBAL (partly reverting behaviour introduced in commit f685e395). bfd/ PR ld/33577 * elflink.c (elf_link_output_extsym): Don't set noversion for defined syms. ld/ PR ld/33577 * ld-elfvers/vers16.dsym: Add back the "Base" version for defined syms.
2025-11-24aarch64: constify BTI and GCS report functionsMatthieu Longo2-7/+10
This patch consitifies the arguments of the functions used to report BTI and GCS errors, and also renames the argument "ebfd" to "abfd" as this naming is confusing and inconsistent with others places.
2025-11-24bfd: rename parsing methods of object attribute v1 APIMatthieu Longo8-29/+49
This patch is a preparation for the introduction of object attributes v2. It aims at: - making clear what methods are used to parse OAv1 - adding more constaints on parameters type by using enums instead of defines. - hiding the attribute tag type behind a typedef. - preparing the move of object attributes's parsing code to another file. Note: the name obj_attr_v1_process_attribute is exposed in the API. Ideally, the version should not be part of the name, and be hidden behind a macro. However, a later patch will unify the parsing of OAv1 and OAv2, and will make the use of such a macro obsolete.
2025-11-24bfd: rename old references to build attributesMatthieu Longo3-9/+9
A previous refactoring patch [1] introduced "build_attributes" in the functions naming. However this naming is specific to the AArch64 Build Attributes specification, and should be replaced by "object_attributes" going forward. [1]: 011e50143f0ec1be271f93facb56def9394947d2
2025-11-24RISC-V: Tidy and aligned riscv_supported_std_[z|x]_ext tablesNelson Chu1-105/+105
2025-11-24Automatic date update in version.inGDB Administrator1-1/+1
2025-11-23Automatic date update in version.inGDB Administrator1-1/+1