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

LoongArch: Enable shared library and PIE support

Binutils now supports shared libraries and Position-Independent Executables (PIE) for LoongArch ELF targets.

Binutils has enabled support for building shared libraries and Position-Independent Executables (PIE) for LoongArch ELF targets (loongarch*-elf). Previously, these targets withheld the necessary scripts (GENERATE_SHLIB_SCRIPT, GENERATE_PIE_SCRIPT), preventing the linker (ld) from accepting -shared and -pie flags. This change aligns LoongArch with RISC-V by unconditionally enabling these scripts, allowing for more flexible and modern executable and library creation on the architecture.

In Details

The ld linker's emulparams for LoongArch (elf32loongarch-defs.sh, elf64loongarch-defs.sh) previously excluded GENERATE_SHLIB_SCRIPT and GENERATE_PIE_SCRIPT for loongarch*-elf targets, mirroring a similar exclusion in RISC-V emulation parameters. This commit removes that exclusion, setting both variables unconditionally. This change is necessary for creating shared libraries and PIE executables on bare-metal LoongArch targets, which do not set the EMBEDDED flag.

For Context
LoongArch
A 64-bit RISC instruction set architecture developed in China.
ELF
Executable and Linkable Format. A standard file format for executables, object code, shared libraries, and core dumps on Unix-like systems.
shared library
A library that can be loaded and linked at runtime by multiple programs simultaneously, reducing memory usage and allowing for easier updates.
PIE
Position-Independent Executable. An executable program that can be loaded at any arbitrary memory address without modification. This is a security feature that makes it harder to exploit memory corruption vulnerabilities.
linker
A program that combines various pieces of code and data into a single executable file. The linker resolves symbols and references between different object files and libraries.
emulparams
Emulator parameters. Configuration files used by the GNU linker (ld) to define target-specific settings for emulation and linking.
Filed Under: loongarchbinutilslinkershared libraryPIE