[llvm-bugs] [Bug 49810] New: ld.lld doesn't permit read-only relocations (-z text) as default compared to ld.bfd and ld.gold
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Apr 1 14:08:33 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=49810
Bug ID: 49810
Summary: ld.lld doesn't permit read-only relocations (-z text)
as default compared to ld.bfd and ld.gold
Product: lld
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: ELF
Assignee: unassignedbugs at nondot.org
Reporter: axel.y.rivera at intel.com
CC: llvm-bugs at lists.llvm.org, smithp352 at googlemail.com
I noticed that lld doesn't allow to relocate read-only sections by default (-z
text), while ld.bfd and ld.gold does (-z notext). This behavior was mentioned
in the following changes: https://reviews.llvm.org/D30530 . This is the example
from the same code review but modified for 32bits.
test2> cat simple.s
foo:
.long foo
test2> llvm-mc -filetype=obj -triple=i386-pc-linux simple.s -o simple.o
test2> ld.lld -m elf_i386 simple.o -o simple -shared
ld.lld: error: can't create dynamic relocation R_386_32 against local symbol in
readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to
allow text relocations in the output
>>> defined in simple.o
>>> referenced by simple.o:(.text+0x0)
But it links successfully for ld.bfd and ld.gold:
test2> ld.bfd -m elf_i386 simple.o -o simple -shared
test2> ld.gold -m elf_i386 simple.o -o simple -shared
If I add -z text to ld.bfd and ld.gold then I get the same failure:
test2> ld.bfd -z text -m elf_i386 simple.o -o simple -shared
ld.bfd: simple.o: warning: relocation in read-only section `.text'
ld.bfd: read-only segment has dynamic relocations.
test2> ld.gold -z text -m elf_i386 simple.o -o simple -shared
ld.gold: error: read-only segment has dynamic relocations
As mentioned in the test case, I can use -z notext and link in lld:
test2> ld.lld -z notext -m elf_i386 simple.o -o simple -shared
Is there a reason why lld doesn't permit the relocation for read-only sections
by default compared to bfd and gold?
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210401/267a2fe1/attachment.html>
More information about the llvm-bugs
mailing list