[lld] r249518 - Skip entries handled by the dynamic linker.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 6 20:56:06 PDT 2015


Author: rafael
Date: Tue Oct  6 22:56:05 2015
New Revision: 249518

URL: http://llvm.org/viewvc/llvm-project?rev=249518&view=rev
Log:
Skip entries handled by the dynamic linker.

We were writing got entries in the first positions, not in the positions
corresponding to locally defined symbols.

Modified:
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/test/elf2/local-got.s

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=249518&r1=249517&r2=249518&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Oct  6 22:56:05 2015
@@ -51,11 +51,12 @@ GotSection<ELFT>::getEntryAddr(const Sym
 
 template <class ELFT> void GotSection<ELFT>::writeTo(uint8_t *Buf) {
   for (const SymbolBody *B : Entries) {
+    uint8_t *Entry = Buf;
+    Buf += sizeof(uintX_t);
     if (canBePreempted(B))
       continue; // The dynamic linker will take care of it.
     uintX_t VA = getSymVA(*B, BssSec);
-    write<uintX_t, ELFT::TargetEndianness, sizeof(uintX_t)>(Buf, VA);
-    Buf += sizeof(uintX_t);
+    write<uintX_t, ELFT::TargetEndianness, sizeof(uintX_t)>(Entry, VA);
   }
 }
 

Modified: lld/trunk/test/elf2/local-got.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/local-got.s?rev=249518&r1=249517&r2=249518&view=diff
==============================================================================
--- lld/trunk/test/elf2/local-got.s (original)
+++ lld/trunk/test/elf2/local-got.s Tue Oct  6 22:56:05 2015
@@ -1,22 +1,27 @@
 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-// RUN: lld -flavor gnu2 %t.o -o %t
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o
+// RUN: ld.lld2 -shared %t2.o -o %t2.so
+// RUN: lld -flavor gnu2 %t.o %t2.so -o %t
 // RUN: llvm-readobj -s -r -section-data %t | FileCheck %s
 // RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s
 
         .globl _start
 _start:
+	call bar at gotpcrel
 	call foo at gotpcrel
 
         .global foo
 foo:
         nop
 
-// 0x12000 - 0x11000 - 5 = 4091
+// 0x130A0 - 0x12000 - 5 =  4251
+// 0x130A8 - 0x12005 - 5 =  4254
 // DISASM:      _start:
-// DISASM-NEXT:   11000: {{.*}} callq 4091
+// DISASM-NEXT:   12000: {{.*}} callq 4251
+// DISASM-NEXT:   12005: {{.*}} callq 4254
 
 // DISASM:      foo:
-// DISASM-NEXT:   11005: {{.*}} nop
+// DISASM-NEXT:   1200a: {{.*}} nop
 
 // CHECK:      Name: .got
 // CHECK-NEXT: Type: SHT_PROGBITS
@@ -24,17 +29,20 @@ foo:
 // CHECK-NEXT:   SHF_ALLOC
 // CHECK-NEXT:   SHF_WRITE
 // CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x12000
+// CHECK-NEXT: Address: 0x130A0
 // CHECK-NEXT: Offset:
-// CHECK-NEXT: Size: 8
+// CHECK-NEXT: Size: 16
 // CHECK-NEXT: Link: 0
 // CHECK-NEXT: Info: 0
 // CHECK-NEXT: AddressAlignment: 8
 // CHECK-NEXT: EntrySize: 0
 // CHECK-NEXT: SectionData (
-// 0x11005 in little endian
-// CHECK-NEXT:   0000: 05100100 00000000                    |........|
+// 0x1200a in little endian
+// CHECK-NEXT:   0000:  00000000 00000000 0A200100 00000000
 // CHECK-NEXT: )
 
 // CHECK:      Relocations [
+// CHECK-NEXT:   Section ({{.*}}) .rela.dyn {
+// CHECK-NEXT:     0x130A0 R_X86_64_GLOB_DAT bar 0x0
+// CHECK-NEXT:   }
 // CHECK-NEXT: ]




More information about the llvm-commits mailing list