loongarch: Use linker stubs bfd instead of linker aligns bfd
LoongArch now uses the generic linker stubs BFD, improving code sharing and enabling dynamic section support.
This change switches the LoongArch backend to use the common “linker stubs” BFD instead of its previous “linker aligns” BFD. This allows LoongArch to leverage more shared code within binutils. Additionally, the linker stubs BFD is now created for all linker modes, not just relocatable linking, making it available for dynamic sections and improving its utility. The testsuite has been updated to accommodate these changes.
In Details
The LoongArch backend is updated to use elf_backend_want_stub_bfd and related common linker stub code, replacing its custom "linker aligns" BFD logic. The align_file function in loongarchelf.em is replaced by stub_file, and the LDEMUL_AFTER_OPEN_OUTPUT hook is removed. This change enables the "linker stubs" BFD in all linker modes, not just relocatable linking, providing support for dynamic sections. Testsuite adjustments were necessary for orphan section placement.
- LoongArch
- A 64-bit RISC instruction set architecture developed in China, used in various processors and embedded systems.
- linker stubs bfd
- A generic mechanism within the Binary File Descriptor (BFD) library used by the linker to handle specific types of sections or symbols, particularly those related to dynamic linking or internal linker operations. Replaces architecture-specific implementations.
- linker aligns bfd
- An older, architecture-specific BFD mechanism used by the linker, likely for managing alignment requirements of sections.
- BFD
- Binary File Descriptor library, a low-level library used by binutils and GDB to support various object file formats (like ELF, COFF, a.out).
- dynamic sections
- Sections within an executable or shared library that contain information needed for dynamic linking at runtime, such as symbol tables for shared objects and relocation entries.
- relocatable linking
- The process of creating an object file that is not yet a complete executable program but contains information (relocations) that allows the linker to adjust addresses when it is combined with other object files or loaded into memory.
- testsuite
- A collection of tests designed to verify the correctness of the software. In this case, it's the set of tests for the binutils linker.