ld: testsuite: Associate C identifiers with symbols
Uses asm keyword in linker testsuite to map C identifiers to assembler symbols, resolving target-specific naming inconsistencies.
This commit updates the linker’s testsuite to use the asm keyword to explicitly associate C identifiers with their corresponding assembler symbol names. This resolves issues where different targets prepend underscores or use other naming conventions for C identifiers, ensuring consistent behavior when linking C and assembly code, or when symbols are specified on the command line.
In Details
This patch adds asm annotations to C identifiers in linker testsuite files (e.g., ld/testsuite/ld-elf/merge4a.c, ld/testsuite/ld-gc/pr13683.c). This directly maps C function/variable names to their external assembler symbols, accommodating target-specific conventions like the leading underscore used by some ABIs (e.g., H8300) and not others (e.g., ARM EABI). This ensures test stability across different toolchain configurations and symbol visibility rules.
- linker
- A program that combines various object files and libraries into a single executable or library, resolving symbol references and arranging code and data in memory.
- assembler
- A program that translates assembly language code into machine code (object code).
- symbol name
- An identifier used in object files and executables to represent functions, variables, or other program elements. The linker uses these names to resolve references between different code modules.
- ABI
- Application Binary Interface. Defines how low-level code is written for a given system, including function calling conventions, data type representations, and ABI-specific symbol naming rules.
- asm keyword
- In C/C++, this keyword allows specifying an alternative assembly name for a variable or function, controlling how it's represented in the compiled output.
- target-independent
- Code or functionality that is designed to work correctly on any supported architecture or operating system without modification.