[PATCH] D62052: [ELF] -r: fix R_*_NONE on Elf*_Rel targets
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 16 23:21:32 PDT 2019
MaskRay created this revision.
MaskRay added reviewers: grimar, peter.smith, rprichard, ruiu.
Herald added subscribers: llvm-commits, kristof.beyls, arichardson, javed.absar, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
We should not add a R_ABS relocation to evaluate the symbol.
This affects X86 and ARM (their relocateOne do not handle R_*_NONE).
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D62052
Files:
ELF/InputSection.cpp
test/ELF/relocation-none-arm.s
test/ELF/relocation-none-i386.s
Index: test/ELF/relocation-none-i386.s
===================================================================
--- test/ELF/relocation-none-i386.s
+++ test/ELF/relocation-none-i386.s
@@ -8,6 +8,13 @@
# CHECK: .data
# CHECK: There are no relocations in this file.
+# RUN: ld.lld -r %t.o -o %t
+# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s
+
+# RELOC: Section ({{.*}}) .rel.text {
+# RELOC-NEXT: 0x0 R_386_NONE .data 0x0
+# RELOC-NEXT: }
+
.globl _start
_start:
ret
Index: test/ELF/relocation-none-arm.s
===================================================================
--- test/ELF/relocation-none-arm.s
+++ test/ELF/relocation-none-arm.s
@@ -8,6 +8,13 @@
# CHECK: .data
# CHECK: There are no relocations in this file.
+# RUN: ld.lld -r %t.o -o %t
+# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s
+
+# RELOC: Section ({{.*}}) .rel.text {
+# RELOC-NEXT: 0x0 R_ARM_NONE .data 0x0
+# RELOC-NEXT: }
+
.globl _start
_start:
nop
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -470,7 +470,7 @@
if (RelTy::IsRela)
P->r_addend = Sym.getVA(Addend) - Section->getOutputSection()->Addr;
- else if (Config->Relocatable)
+ else if (Config->Relocatable && Type != Target->NoneRel)
Sec->Relocations.push_back({R_ABS, Type, Rel.r_offset, Addend, &Sym});
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62052.199978.patch
Type: text/x-patch
Size: 1448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190517/74f700f6/attachment.bin>
More information about the llvm-commits
mailing list