diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-10-07 03:56:05 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-10-07 03:56:05 +0000 |
| commit | e782f673a88b0decbba4a25c5572f3a1ffeb7725 (patch) | |
| tree | d3f763e61addf58fdb3fd973ba5da52c327edfe8 | |
| parent | 5af04a4d015a481fa1b91faf0d2ee5b43d064296 (diff) | |
| download | bcm5719-llvm-e782f673a88b0decbba4a25c5572f3a1ffeb7725.tar.gz bcm5719-llvm-e782f673a88b0decbba4a25c5572f3a1ffeb7725.zip | |
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.
llvm-svn: 249518
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 5 | ||||
| -rw-r--r-- | lld/test/elf2/local-got.s | 24 |
2 files changed, 19 insertions, 10 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 1bc6e6bd99d..6caf99069b4 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -51,11 +51,12 @@ GotSection<ELFT>::getEntryAddr(const SymbolBody &B) const { 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); } } diff --git a/lld/test/elf2/local-got.s b/lld/test/elf2/local-got.s index bc7edae004a..e1e78ec5c3e 100644 --- a/lld/test/elf2/local-got.s +++ b/lld/test/elf2/local-got.s @@ -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@gotpcrel call foo@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: ] |

