binutils Newspaper
JULY 29, 2026
ld Proposed

ld: testsuite: Associate C identifiers with the corresponding assembler or linker symbols in a target-independent manner.

Uses `asm` keyword to make C identifier to symbol mapping target-independent in linker tests.

Jan Dubiec’s patch addresses issues in the linker testsuite where target-specific symbol naming conventions (like a leading underscore for C identifiers) cause problems when linking C and assembly code or when symbols are provided on the linker command line. By using the asm keyword, C identifiers are associated with their assembler/linker symbols in a manner that is independent of the target architecture, resolving these cross-language and command-line symbol resolution problems.

In Details

This patch refactors the binutils linker testsuite to address target-specific symbol mangling, particularly the common convention of prepending an underscore to C identifiers. It leverages the asm keyword in C to explicitly associate C identifiers with their corresponding assembler symbol names, making tests like merge4a.c and merge4b.s (and similar linking scenarios) portable across architectures that differ in their symbol naming conventions (e.g., H8 vs. ARM).

For Context
linker
A program that combines object code from one or more object files and libraries into a single executable file, resolving symbol references between them.
assembler
A program that translates assembly language code into machine code.
symbol
A name used to refer to a location in memory or a quantity, such as a variable name, function name, or constant.
symbol mangling
The process of encoding additional information into a symbol's name, often to support name decoration for function overloading, namespaces, or C++ features. For C, it often involves adding a leading underscore for global symbols.
asm keyword
In C, the asm keyword (often used with __asm__ for GNU extensions) allows inline assembly code or, in this context, provides a way to specify the assembler name for a variable or function.
COFF
Common Object File Format, a file format for executable and object code, primarily used on Windows systems.
Filed Under: binutilsldlinkertestsuiteABI