Thread (11 messages) 11 messages, 4 authors, 2025-01-03

Re: [POC][RFC][PATCH] build: Make weak functions visible in kallsyms

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2024-12-27 03:35:39
Also in: bpf, linux-kbuild, lkml

On Thu, 26 Dec 2024 at 13:49, Steven Rostedt [off-list ref] 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help