]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ld: testsuite: Associate C identifiers with symbols
authorJan Dubiec <jdx@o2.pl>
Sat, 18 Jul 2026 07:52:54 +0000 (09:52 +0200)
committerAlan Modra <amodra@gmail.com>
Sun, 19 Jul 2026 05:22:05 +0000 (14:52 +0930)
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 <jdx@o2.pl>
ld/testsuite/ld-elf/merge4a.c
ld/testsuite/ld-gc/pr13683.c
ld/testsuite/ld-gc/pr19161-1.c

index 133303e11ac727f0bc4dbfedef0cbba287617c78..d050c30702a9adcea32a94e320db3a2467d65e41 100644 (file)
@@ -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
index f8c875092188260c3cf15ec6eebd68bfb975da9b..57afdce3c01ce9d64ed8ac879cff8d08d9c8c857 100644 (file)
@@ -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;
 }
-
-
index 519948e9b461b3e22d8a8d48f157f17fde7be580..0667ff64cf71c3d155fb5b4afde26265dd7eb6a4 100644 (file)
@@ -1,4 +1,5 @@
 int (*p)(void);
+int main(void) asm("main");
 
 int
 main ()