sh: Fix linker errors by applying __USER_LABEL_PREFIX__ in CNAME (#953)
The CNAME macro in src/sh/sysv.S was defined as a no-op (#define CNAME(x) x),
which ignores __USER_LABEL_PREFIX__. On targets where this prefix is set (e.g.
an underscore on some platforms), the assembler emits symbols without the
expected prefix, causing linker errors when C code references them.
Fix this by using the C1/C2 two-level macro concatenation pattern (as used in
x86/sysv.S) to properly prepend __USER_LABEL_PREFIX__ to symbol names.
This replaces the approach proposed in #809.
Co-authored-by: bobo215 <266481280+bobo215@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
diff --git a/src/sh/sysv.S b/src/sh/sysv.S
index 5be7516..4834492 100644
--- a/src/sh/sysv.S
+++ b/src/sh/sysv.S
@@ -31,7 +31,9 @@
#include <machine/asm.h>
#else
/* XXX these lose for some platforms, I'm sure. */
-#define CNAME(x) x
+#define C2(X, Y) X ## Y
+#define C1(X, Y) C2(X, Y)
+#define CNAME(x) C1(__USER_LABEL_PREFIX__, x)
#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
#endif