Fix tic6x linker failure related to dynamic sections
Corrected a linker check that incorrectly failed for tic6x targets due to premature dynamic section verification.
This commit fixes a bug in the BFD linker that caused failures for the tic6x target (PR34550). The issue stemmed from an optimization that moved the check for dynamic_sections_created too early in the linking process. This check needs to occur after the hash table type is verified. The fix ensures this check is performed at the appropriate stage, allowing bfd_elf_link_create_dynamic_sections to run, which correctly handles early exits if dynamic sections are already present.
In Details
In elf_link_add_object_symbols within BFD's elflink.c, a check for !htab->dynamic_sections_created was moved earlier in commit ee7896781dc7. This premature check caused failures on targets like tic6x where the hash table might not be immediately available or correctly typed. The fix reverts this change, placing the check after compatible_format has verified the hash table type. It also simplifies the logic by allowing bfd_elf_link_create_dynamic_sections to execute, as it contains its own early-exit logic for already created dynamic sections.
- BFD
- The Binary File Descriptor library, a low-level component of GNU Binutils used for manipulating object file formats.
- linker
- A program that combines one or more object files (produced by a compiler) into a single executable file, library file, or another object file.
- tic6x
- A family of digital signal processors (DSPs) from Texas Instruments, often targeted by specialized toolchains.
- dynamic sections
- Sections within an ELF object file that are relevant for dynamic linking, such as .dynamic and .dynsym.
- hash table
- In the context of ELF, a data structure used by the dynamic linker to efficiently locate symbols.
- ELF
- Executable and Linkable Format. A standard file format for executables, object code, shared libraries, and core dumps on many Unix-like systems.