[lld] r295143 - Set the correct r_offset even when creating a R_*_NONE.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 14 17:53:24 PST 2017


Author: rafael
Date: Tue Feb 14 19:53:23 2017
New Revision: 295143

URL: http://llvm.org/viewvc/llvm-project?rev=295143&view=rev
Log:
Set the correct r_offset even when creating a R_*_NONE.

With this lld can use its own -r output when a fde is discarded.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/test/ELF/relocatable-eh-frame.s

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=295143&r1=295142&r2=295143&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Feb 14 19:53:23 2017
@@ -236,6 +236,13 @@ void InputSection<ELFT>::copyRelocations
     if (Config->Rela)
       P->r_addend = getAddend<ELFT>(Rel);
 
+    // Output section VA is zero for -r, so r_offset is an offset within the
+    // section, but for --emit-relocs it is an virtual address.
+    P->r_offset = RelocatedSection->OutSec->Addr +
+                  RelocatedSection->getOffset(Rel.r_offset);
+    P->setSymbolAndType(In<ELFT>::SymTab->getSymbolIndex(&Body), Type,
+                        Config->Mips64EL);
+
     if (Body.Type == STT_SECTION) {
       // We combine multiple section symbols into only one per
       // section. This means we have to update the addend. That is
@@ -263,12 +270,6 @@ void InputSection<ELFT>::copyRelocations
       }
     }
 
-    // Output section VA is zero for -r, so r_offset is an offset within the
-    // section, but for --emit-relocs it is an virtual address.
-    P->r_offset = RelocatedSection->OutSec->Addr +
-                  RelocatedSection->getOffset(Rel.r_offset);
-    P->setSymbolAndType(In<ELFT>::SymTab->getSymbolIndex(&Body), Type,
-                        Config->Mips64EL);
   }
 }
 

Modified: lld/trunk/test/ELF/relocatable-eh-frame.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocatable-eh-frame.s?rev=295143&r1=295142&r2=295143&view=diff
==============================================================================
--- lld/trunk/test/ELF/relocatable-eh-frame.s (original)
+++ lld/trunk/test/ELF/relocatable-eh-frame.s Tue Feb 14 19:53:23 2017
@@ -2,11 +2,15 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
 # RUN: ld.lld -r %t.o %t.o -o %t
 # RUN: llvm-readobj -r %t | FileCheck %s
+# RUN: ld.lld %t -o %t.so -shared
+# RUN: llvm-objdump -h %t.so | FileCheck --check-prefix=DSO %s
+
+# DSO: .eh_frame     00000030
 
 # CHECK:      Relocations [
 # CHECK-NEXT:   Section ({{.*}}) .rela.eh_frame {
 # CHECK-NEXT:     0x20 R_X86_64_PC32 .foo 0x0
-# CHECK-NEXT:     0x0 R_X86_64_NONE - 0x0
+# CHECK-NEXT:     0x50 R_X86_64_NONE - 0x0
 # CHECK-NEXT:   }
 # CHECK-NEXT: ]
 




More information about the llvm-commits mailing list