Skip to contentSkip to conversation

sparc: Export mcount for Clang-built modules

PATCH In review Rosen Penev 2 participants 2 messages Jun 12 – Jun 15 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sparc: Export mcount for Clang-built modules

Clang emits calls to mcount for -pg on sparc64, while the existing ftrace support only exports the _mcount name. With FUNCTION_TRACER enabled, modules can therefore keep relocations against mcount and fail during modpost:

ERROR: modpost: "mcount" [arch/sparc/kernel/chmc.ko] undefined!

_mcount and mcount are aliases in arch/sparc/lib/mcount.S. Export the plain mcount alias as well so Clang-built modules can resolve their profiling call target.

Assisted-by Codex:GPT-5

---
v2: add declaration in asm-prototypes.h

 arch/sparc/include/asm/asm-prototypes.h | 1 +
 arch/sparc/lib/mcount.S                 | 1 +
 2 files changed, 2 insertions(+)
arch/sparc/include/asm/asm-prototypes.h +1 -0
index 270c51017212..a39a24c53216 100644
@@ -26,6 +26,7 @@ void *memset(void *s, int c, size_t n);
 typedef int TItype __attribute__((mode(TI)));
 TItype __multi3(TItype a, TItype b);
 void _mcount(void);
+void mcount(void);
 
 s64 __ashldi3(s64, int);
 s64 __lshrdi3(s64, int);
arch/sparc/lib/mcount.S +1 -0
index f7f7910eb41e..0309ba2c4712 100644
@@ -21,6 +21,7 @@
 	EXPORT_SYMBOL(_mcount)
 	.globl		mcount
 	.type		mcount,#function
+	EXPORT_SYMBOL(mcount)
 _mcount:
 mcount:
 #ifdef CONFIG_FUNCTION_TRACER

--
2.54.0

maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 44 lines · Rosen Penev

Clang emits calls to mcount for -pg on sparc64, while the existing ftrace support only exports the _mcount name. With FUNCTION_TRACER enabled, modules can therefore keep relocations against mcount and fail during modpost:

ERROR: modpost: "mcount" [arch/sparc/kernel/chmc.ko] undefined!

_mcount and mcount are aliases in arch/sparc/lib/mcount.S. Export the plain mcount alias as well so Clang-built modules can resolve their profiling call target.

Assisted-by Codex:GPT-5

---
v2: add declaration in asm-prototypes.h

 arch/sparc/include/asm/asm-prototypes.h | 1 +
 arch/sparc/lib/mcount.S                 | 1 +
 2 files changed, 2 insertions(+)
arch/sparc/include/asm/asm-prototypes.h +1 -0
index 270c51017212..a39a24c53216 100644
@@ -26,6 +26,7 @@ void *memset(void *s, int c, size_t n);
 typedef int TItype __attribute__((mode(TI)));
 TItype __multi3(TItype a, TItype b);
 void _mcount(void);
+void mcount(void);
 
 s64 __ashldi3(s64, int);
 s64 __lshrdi3(s64, int);
arch/sparc/lib/mcount.S +1 -1
index f7f7910eb41e..0309ba2c4712 100644
@@ -21,6 +21,7 @@
 	EXPORT_SYMBOL(_mcount)
 	.globl		mcount
 	.type		mcount,#function
+	EXPORT_SYMBOL(mcount)
 _mcount:
 mcount:
 #ifdef CONFIG_FUNCTION_TRACER
--
Quoted 2 lines

2.54.0

Picking this up to my for-next.

Thanks,
Andreas