On Thu, Dec 26, 2024 at 07:35:18PM -0800, Linus Torvalds wrote: > Btw, does this actually happen when the compiler does the mcount thing for us? Yeah, so the linker literally just drops the symbol name on the floor, nothing else. So all the section information -- either compiler generated like mcount locations, or manually inserted like alternatives -- stick around for the 'dead' code. The only time the toolchain has enough visibility to do the right thing is when doing a full LTO build, at that point can the compiler see the weak function is actually unused and do 'normal' DCE, including all the resulting extra section stuff.