Fix alpha GOT merge issue with GPREL relocs
Prevent linker errors on Alpha by avoiding .got merges after GPREL relocs are established.
This change prevents the Alpha ELF linker from merging .got subsections after GPREL16 relocations are in place. Previous logic incorrectly allowed merges in a subsequent relaxation pass, leading to relocation errors. The fix adds a flag to track relaxation passes and inhibits merging once GPREL16 relocs exist.
In Details
The Alpha ELF linker's elf64_alpha_relax_section function now uses a no_got_merge flag. This flag is set when relax_pass is non-zero. Merging of .got subsections is prevented after this flag is set, addressing a bug where merging occurred after GPREL16 relocations were generated, causing relocation truncated to fit: GPREL16 errors. This occurs because ldelf_map_segments can re-invoke relaxation passes starting from pass 0.
- .got
- The Global Offset Table (GOT) is a data structure used by some systems to support indirect branches and data access, particularly for position-independent code.
- GPREL reloc
- A relocation entry that specifies an offset relative to the global pointer (GP) register.
- ELF relocation
- Information in an object file that describes how to remap symbolic references to actual addresses when the file is linked or loaded.
- linker relaxation
- A linker optimization pass that adjusts instruction and data addresses to potentially use smaller or more efficient encodings, often involving multiple passes.
- subsection
- A smaller, contiguous section within a larger section of an object file, used for organizing related data or code.
- Alpha architecture
- A Reduced Instruction Set Computing (RISC) instruction set architecture developed by Digital Equipment Corporation (DEC).