Re: [POC][RFC][PATCH] build: Make weak functions visible in kallsyms
From: Linus Torvalds
Date: Thu Dec 26 2024 - 22:35:50 EST
On Thu, 26 Dec 2024 at 13:49, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> But then, when the linker removes these functions because they were
> overridden, the code does not disappear, leaving the pointers in the
> __mcount_loc locations.
Btw, does this actually happen when the compiler does the mcount thing for us?
It *feels* like this might be a bug in the FTRACE_MCOUNT_USE_OBJTOOL
logic interacting with --gc-setions.
Is the problem that --gc-sections removed the function section that
contained the weak function that was then never used, but the objtool
thing with create_mcount_loc_sections() would generate that
mcount_loc_list and nothing realized that it's no longer there?
Or does it happen even with the compiler-generated case (ie with the
-mrecord-mcount and FTRACE_MCOUNT_USE_CC)?
We can disable LD_DEAD_CODE_DATA_ELIMINATION, if that's what triggers it.
It's marked as experimental, and it does smell like either
--gc-sections is buggy, or we're doing something wrong to trigger it
(and I could easily see objtool rewriting object files being that
trigger...)
Linus