This is not a bug, lld is completely correct. You are explicitly asking
for a read-only section and the choosen relocation is position
dependent, so yes, it correctly bails out.
Joerg
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
I think this is just a difference in defaults. If you pass "-z notext"
to lld it should work.
Cheers,
Rafael
Thanks, this helps! Any reason why the defaults are different to gold and
presumably bfd-ld?
I don't understand much of what is happening behind the scenes, but on
loading time, couldn't the rodata section just be mapped read-only, and
still the relocation be applied to the text section, pointing to wherever
rodata was mapped? No modification should be necessary to the rodata
section.
Thanks and Best regards,
Martin
Yes. Releocations in .rodata are undesirable. This way the
programming errors or compiler bugs that cause them get caught.
> I don't understand much of what is happening behind the scenes, but on
> loading time, couldn't the rodata section just be mapped read-only, and
> still the relocation be applied to the text section, pointing to wherever
> rodata was mapped? No modification should be necessary to the rodata
> section.
The dynamic linker can patch these up. But doing so kills the
"shared" aspect of the object as the pages in question will no longer
be shared between processes.
Your .rodata contains a vector of addresses, and we don't know the actual addresses until load-time, because your .so file can be loaded to anywhere in your address space. Thus, we cannot fix .rodata contents at link-time. So your .so needs load-time modifications to the .rodata section. (Does this answer your question?)I think our default choice of forbidding relocations against read-only sections is reasonable, because most programs don't need text relocations,
and if that happens, it is with a high probability a mistake instead of an intentional behavior.