[llvmlinux] Functions marked with __weak directives are linked in after the _etext symbol

PaX Team pageexec at freemail.hu
Wed Nov 19 02:37:03 UTC 2014

On 18 Nov 2014 at 23:23, Renato Golin wrote:

> The _etext and _edata symbols seem to be implemented in many variants
> of Unix, though I'm not sure that's in the ELF standard. It may just
> be that Clang never had to deal with that before because it's only now
> that we're compiling the kernel... :)

_etext/_edata are usually defined by the linker script which in turn
means that they're associated with whatever section they're defined
after/in. for linux/x86 they're in arch/x86/kernel/vmlinux.lds.S and
it seems that that llvm emits the weak symbols into different sections
than gcc (e.g., .text.functionname vs. .text) that the linker script
doesn't seem to take care of. iirc there used to be a catch-all inclusion
of .text.* sections in .text but that was changed some years ago for
supporting i-forget-what feature...

More information about the LLVMLinux mailing list