[PATCH] D62052: [ELF] -r: fix R_*_NONE to section symbols on Elf*_Rel targets

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 05:57:42 PDT 2019


MaskRay updated this revision to Diff 200027.
MaskRay retitled this revision from "[ELF] -r: fix R_*_NONE on Elf*_Rel targets" to "[ELF] -r: fix R_*_NONE to section symbols on Elf*_Rel targets".
MaskRay edited the summary of this revision.
MaskRay added a comment.

Update description


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62052/new/

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.200027.patch
Type: text/x-patch
Size: 1448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190517/cb33857e/attachment.bin>


More information about the llvm-commits mailing list