Martin Richtarsky via llvm-dev
2017-Mar-23 12:23 UTC
[llvm-dev] [LLD] Can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment
Hi, the attached example works with bfd-ld and with gold, but not with lld: $ cat rodatareloc.s ... .align 16 leaq .JTab(%rip), %r10 jmp *(%r10, %rdx, 8) ... .section .rodata .JTab: .quad .L00, .L01, .L02, .L03, .L04, .L05, .L06, .L07 .quad .L08, .L09, .L10, .L11, .L12, .L13, .L14, .L15, .L16 $ 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? Best regards, Martin -------------- next part -------------- A non-text attachment was scrubbed... Name: lld_rodata_dynamic_relro.tar.gz Type: application/x-gzip Size: 807 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170323/2aaf9665/attachment.bin>
Joerg Sonnenberger via llvm-dev
2017-Mar-23 14:14 UTC
[llvm-dev] [LLD] Can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment
On Thu, Mar 23, 2017 at 01:23:24PM +0100, Martin Richtarsky via llvm-dev wrote:> 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?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
Rui Ueyama via llvm-dev
2017-Mar-23 15:14 UTC
[llvm-dev] [LLD] Can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment
Yes, this is correct and expected behavior. But why do you want to make it work? On Thu, Mar 23, 2017 at 7:14 AM, Joerg Sonnenberger via llvm-dev < llvm-dev at lists.llvm.org> wrote:> On Thu, Mar 23, 2017 at 01:23:24PM +0100, Martin Richtarsky via llvm-dev > wrote: > > 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? > > 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-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170323/c19e853d/attachment.html>
Rafael Avila de Espindola via llvm-dev
2017-Mar-23 15:23 UTC
[llvm-dev] [LLD] Can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment
Martin Richtarsky via llvm-dev <llvm-dev at lists.llvm.org> writes:> Hi, > > the attached example works with bfd-ld and with gold, but not with lld: > > $ cat rodatareloc.s > ... > .align 16 > leaq .JTab(%rip), %r10 > jmp *(%r10, %rdx, 8) > ... > .section .rodata > .JTab: > .quad .L00, .L01, .L02, .L03, .L04, .L05, .L06, .L07 > .quad .L08, .L09, .L10, .L11, .L12, .L13, .L14, .L15, .L16 > > $ 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. Cheers, Rafael
Martin Richtarsky via llvm-dev
2017-Mar-23 15:47 UTC
[llvm-dev] [LLD] Can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment
Rafael Avila de Espindola wrote:>> $ 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? 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
Apparently Analagous Threads
- [LLD] Can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment
- [LLVMdev] [cfe-dev] LLVM 3.6 Release
- lld write wrong symbol value in .data section if enable -pie
- lld write wrong symbol value in .data section if enable -pie
- lld write wrong symbol value in .data section if enable -pie