From: Jan Dubiec Date: Sat, 18 Jul 2026 07:52:54 +0000 (+0200) Subject: ld: testsuite: Associate C identifiers with symbols X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0e4e6037429cd5df3de62f6e373955c0d3b85533;p=thirdparty%2Fbinutils-gdb.git ld: testsuite: Associate C identifiers with symbols Some targets prepend an underscore to C identifier, while others do not (e.g. H8 vs. ARM). This can cause problems in two situations: 1. when linking C and assembly code; 2. when a symbol name is specified on the linker's command line. This patch resolves both issues by using the asm keyword to associate C identifiers with the corresponding assembler/linker symbol names in a target-independent manner. Signed-off-by: Jan Dubiec --- diff --git a/ld/testsuite/ld-elf/merge4a.c b/ld/testsuite/ld-elf/merge4a.c index 133303e11ac..d050c30702a 100644 --- a/ld/testsuite/ld-elf/merge4a.c +++ b/ld/testsuite/ld-elf/merge4a.c @@ -1,8 +1,8 @@ extern const char * getstr3(int); extern int printf (const char *, ...); -extern const char *addr_of_str; -extern const char *addr_of_str2; +extern const char *addr_of_str asm("addr_of_str"); +extern const char *addr_of_str2 asm("addr_of_str2"); /* "foobar" needs to be a string literal, so that it's put into a mergable string section, then merged with the "foobar" from merge4b.s diff --git a/ld/testsuite/ld-gc/pr13683.c b/ld/testsuite/ld-gc/pr13683.c index f8c87509218..57afdce3c01 100644 --- a/ld/testsuite/ld-gc/pr13683.c +++ b/ld/testsuite/ld-gc/pr13683.c @@ -1,4 +1,6 @@ -void foo(void); +void foo(void) asm("foo"); +void foo2(void) asm("foo2"); +int main(void) asm("main"); int main(void) { @@ -24,5 +26,3 @@ void foo3(void) { a = 3; } - - diff --git a/ld/testsuite/ld-gc/pr19161-1.c b/ld/testsuite/ld-gc/pr19161-1.c index 519948e9b46..0667ff64cf7 100644 --- a/ld/testsuite/ld-gc/pr19161-1.c +++ b/ld/testsuite/ld-gc/pr19161-1.c @@ -1,4 +1,5 @@ int (*p)(void); +int main(void) asm("main"); int main ()