[PATCH] D63121: [ELF] Make the rule to create relative relocations in a writable section stricter
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 10 22:35:37 PDT 2019
MaskRay created this revision.
MaskRay added reviewers: grimar, ruiu.
Herald added subscribers: llvm-commits, jsji, atanasyan, jrtc27, fedor.sergeev, kbarton, arichardson, javed.absar, nhaehnle, jvesely, nemanjai, sdardis, emaste, jyknight.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
The current rule is loose: `!Sym.IsPreemptible || Expr == R_GOT`.
When the symbol is non-preemptable, this allows absolute relocation
types with smaller numbers of bits, e.g. R_X86_64_{8,16,32}. They are
disallowed by ld.bfd and gold, e.g.
ld.bfd: a.o: relocation R_X86_64_8 against `.text' can not be used when making a shared object; recompile with -fPIC
This patch:
a) Add TargetInfo::SymbolicRel to represent relocation types that resolve to a
symbol value (e.g. R_AARCH_ABS64, R_386_32, R_X86_64_64).
As a side benefit, we currently (ab)use GotRel (R_*_GLOB_DAT) to resolve
GOT slots that are link-time constants. Since we now use Target->SymbolRel
to do the job, we can remove R_*_GLOB_DAT from relocateOne() for all targets.
R_*_GLOB_DAT cannot be used as static relocation types.
b) Change the condition to `!Sym.IsPreemptible && Type != Target->SymbolicRel || Expr == R_GOT`.
Some tests are caught by the improved error checking (ld.bfd/gold also
issue errors on them). Many misuse .long where .quad should be used
instead.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D63121
Files:
ELF/Arch/AArch64.cpp
ELF/Arch/AMDGPU.cpp
ELF/Arch/ARM.cpp
ELF/Arch/Hexagon.cpp
ELF/Arch/Mips.cpp
ELF/Arch/PPC.cpp
ELF/Arch/PPC64.cpp
ELF/Arch/SPARCV9.cpp
ELF/Arch/X86.cpp
ELF/Arch/X86_64.cpp
ELF/Relocations.cpp
ELF/SyntheticSections.cpp
ELF/Target.h
test/ELF/linkerscript/visibility.s
test/ELF/merge-string-error.s
test/ELF/pack-dyn-relocs-loop.s
test/ELF/relocation-before-merge-start.s
test/ELF/relocation-past-merge-end.s
test/ELF/x86-64-dyn-rel-error5.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63121.203976.patch
Type: text/x-patch
Size: 10821 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190611/72cbb439/attachment.bin>
More information about the llvm-commits
mailing list