[llvm-dev] [LLD] Can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment
Mark Kettenis via llvm-dev
llvm-dev at lists.llvm.org
Thu Mar 23 09:08:49 PDT 2017
> Date: Thu, 23 Mar 2017 16:47:11 +0100
> From: Martin Richtarsky via llvm-dev <llvm-dev at lists.llvm.org>
>
> >> $ gcc -o rodatareloc.s.o -c rodatareloc.s
> >> $ lld -o rodatareloc.so -shared rodatareloc.s.o
> >>
> >> ld: error: rodatareloc.s.o:(.rodata+0x0): can't create dynamic
> >> relocation
> >> R_X86_64_64 against local symbol in readonly segment defined in
> >> rodatareloc.s.o
> >>
> >>
> >> Changing the section from .rodata to .data fixes it, but I guess this
> >> should be supported also for .rodata. Should I open a bug?
> >
> > I think this is just a difference in defaults. If you pass "-z notext"
> > to lld it should work.
>
> Thanks, this helps! Any reason why the defaults are different to gold and
> presumably bfd-ld?
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.
More information about the llvm-dev
mailing list