binutils Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ld/testsuite

ld: Pin hash style in LoongArch shared library tests

LoongArch shared library tests now explicitly set the hash style to 'both'.

Three linker test cases for LoongArch shared libraries (relr-data-shared.d, relr-discard-shared.d, relr-got-shared.d) have been updated to explicitly pass --hash-style=both. This ensures consistent test results across different environments, as the default hash style for bare-metal targets (like loongarch*-elf) differs from that of Linux (sysv vs. both), affecting symbol indexing in relocation entries. This change is a prerequisite for enabling shared library and PIE support on LoongArch, allowing these tests to pass correctly.

In Details

The LoongArch ELF linker test suite, specifically tests involving DT_RELR relocations and shared libraries, requires explicit pinning of the hash style. The default hash style for loongarch*-elf is sysv, while the Linux default is both. The test expectations were written against the both style. This commit modifies relr-data-shared.d, relr-discard-shared.d, and relr-got-shared.d to pass --hash-style=both. This ensures that the symbol indices in the .dynsym table, which are compared in the tests, are consistent regardless of the target's default hash style.

For Context
ld
The GNU linker, responsible for combining object files and libraries into an executable or another library.
LoongArch
A 64-bit RISC instruction set architecture developed in China.
shared library
A library that can be loaded and linked at runtime by multiple programs simultaneously, reducing memory usage and allowing for easier updates.
hash style
Refers to the algorithm used by the linker to organize symbols in the symbol table. Common styles include 'sysv', 'gnu', and 'both'.
DT_RELR
A dynamic section tag in ELF files indicating the presence of relocation entries in a specific format, often used for Position-Independent Code (PIC).
symbol index
The position of a symbol within the dynamic symbol table (.dynsym) of an ELF object file. This index is used in relocation entries.
Filed Under: loongarchbinutilslinkertestsuiteshared library