summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-03-25 23:46:19 +0000
committerFangrui Song <maskray@google.com>2019-03-25 23:46:19 +0000
commit210949a221fc7864c8330cb6763c62c88ecebc7f (patch)
treee9ad5c7b9653a37ec06b030cc06c7b5d1b8706f9
parent1d1f1ba3d240aa0109ed71e6c0aef1e5cf0e6a89 (diff)
downloadbcm5719-llvm-210949a221fc7864c8330cb6763c62c88ecebc7f.tar.gz
bcm5719-llvm-210949a221fc7864c8330cb6763c62c88ecebc7f.zip
[ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt))
Summary: This should address remaining issues discussed in PR36555. Currently R_GOT*_FROM_END are exclusively used by x86 and x86_64 to express relocations types relative to the GOT base. We have _GLOBAL_OFFSET_TABLE_ (GOT base) = start(.got.plt) but end(.got) != start(.got.plt) This can have problems when _GLOBAL_OFFSET_TABLE_ is used as a symbol, e.g. glibc dl_machine_dynamic assumes _GLOBAL_OFFSET_TABLE_ is start(.got.plt), which is not true. extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden; return _GLOBAL_OFFSET_TABLE_[0]; // R_X86_64_GOTPC32 In this patch, we * Change all GOT*_FROM_END to GOTPLT* to fix the problem. * Add HasGotPltOffRel to denote whether .got.plt should be kept even if the section is empty. * Simplify GotSection::empty and GotPltSection::empty by setting HasGotOffRel and HasGotPltOffRel according to GlobalOffsetTable early. The change of R_386_GOTPC makes X86::writePltHeader simpler as we don't have to compute the offset start(.got.plt) - Ebx (it is constant 0). We still diverge from ld.bfd (at least in most cases) and gold in that .got.plt and .got are not adjacent, but the advantage doing that is unclear. Reviewers: ruiu, sivachandra, espindola Subscribers: emaste, mehdi_amini, arichardson, dexonsmith, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59594 llvm-svn: 356968
-rw-r--r--lld/ELF/Arch/X86.cpp36
-rw-r--r--lld/ELF/Arch/X86_64.cpp6
-rw-r--r--lld/ELF/InputSection.cpp20
-rw-r--r--lld/ELF/Relocations.cpp26
-rw-r--r--lld/ELF/Relocations.h14
-rw-r--r--lld/ELF/SyntheticSections.cpp14
-rw-r--r--lld/ELF/SyntheticSections.h4
-rw-r--r--lld/ELF/Writer.cpp9
-rw-r--r--lld/test/ELF/got-i386.s14
-rw-r--r--lld/test/ELF/got32x-i386.s6
-rw-r--r--lld/test/ELF/i386-gotoff-shared.s16
-rw-r--r--lld/test/ELF/i386-gotpc-dynamic.s23
-rw-r--r--lld/test/ELF/i386-gotpc.s22
-rw-r--r--lld/test/ELF/i386-relax-reloc.s13
-rw-r--r--lld/test/ELF/i386-retpoline-pic-linkerscript.s8
-rw-r--r--lld/test/ELF/i386-retpoline-pic.s8
-rw-r--r--lld/test/ELF/plt-i686.s20
-rw-r--r--lld/test/ELF/relocation-i686.s24
-rw-r--r--lld/test/ELF/relocation.s4
-rw-r--r--lld/test/ELF/shared.s2
-rw-r--r--lld/test/ELF/tls-dynamic-i686.s2
-rw-r--r--lld/test/ELF/tls-opt-gdiele-i686.s6
-rw-r--r--lld/test/ELF/x86-64-reloc-gotoff64.s16
-rw-r--r--lld/test/ELF/x86-64-reloc-gotpc64.s6
24 files changed, 143 insertions, 176 deletions
diff --git a/lld/ELF/Arch/X86.cpp b/lld/ELF/Arch/X86.cpp
index 645e89c0678..b110abc1e0e 100644
--- a/lld/ELF/Arch/X86.cpp
+++ b/lld/ELF/Arch/X86.cpp
@@ -87,9 +87,9 @@ RelExpr X86::getRelExpr(RelType Type, const Symbol &S,
case R_386_TLS_LDO_32:
return R_ABS;
case R_386_TLS_GD:
- return R_TLSGD_GOT_FROM_END;
+ return R_TLSGD_GOTPLT;
case R_386_TLS_LDM:
- return R_TLSLD_GOT_FROM_END;
+ return R_TLSLD_GOTPLT;
case R_386_PLT32:
return R_PLT_PC;
case R_386_PC8:
@@ -97,7 +97,7 @@ RelExpr X86::getRelExpr(RelType Type, const Symbol &S,
case R_386_PC32:
return R_PC;
case R_386_GOTPC:
- return R_GOTONLY_PC_FROM_END;
+ return R_GOTPLTONLY_PC;
case R_386_TLS_IE:
return R_GOT;
case R_386_GOT32:
@@ -136,12 +136,12 @@ RelExpr X86::getRelExpr(RelType Type, const Symbol &S,
// of a displacement or an immediate field of a valid machine
// instruction. That means a ModRM byte is at Loc[-1]. By taking a look at
// the byte, we can determine whether the instruction uses the operand as an
- // absolute address (R_GOT) or a register-relative address (R_GOT_FROM_END).
- return (Loc[-1] & 0xc7) == 0x5 ? R_GOT : R_GOT_FROM_END;
+ // absolute address (R_GOT) or a register-relative address (R_GOTPLT).
+ return (Loc[-1] & 0xc7) == 0x5 ? R_GOT : R_GOTPLT;
case R_386_TLS_GOTIE:
- return R_GOT_FROM_END;
+ return R_GOTPLT;
case R_386_GOTOFF:
- return R_GOTREL_FROM_END;
+ return R_GOTPLTREL;
case R_386_TLS_LE:
return R_TLS;
case R_386_TLS_LE_32:
@@ -193,16 +193,11 @@ RelType X86::getDynRel(RelType Type) const {
void X86::writePltHeader(uint8_t *Buf) const {
if (Config->Pic) {
const uint8_t V[] = {
- 0xff, 0xb3, 0x04, 0x00, 0x00, 0x00, // pushl GOTPLT+4(%ebx)
- 0xff, 0xa3, 0x08, 0x00, 0x00, 0x00, // jmp *GOTPLT+8(%ebx)
+ 0xff, 0xb3, 0x04, 0x00, 0x00, 0x00, // pushl 4(%ebx)
+ 0xff, 0xa3, 0x08, 0x00, 0x00, 0x00, // jmp *8(%ebx)
0x90, 0x90, 0x90, 0x90 // nop
};
memcpy(Buf, V, sizeof(V));
-
- uint32_t Ebx = In.Got->getVA() + In.Got->getSize();
- uint32_t GotPlt = In.GotPlt->getVA() - Ebx;
- write32le(Buf + 2, GotPlt + 4);
- write32le(Buf + 8, GotPlt + 8);
return;
}
@@ -229,7 +224,7 @@ void X86::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr,
if (Config->Pic) {
// jmp *foo@GOT(%ebx)
- uint32_t Ebx = In.Got->getVA() + In.Got->getSize();
+ uint32_t Ebx = In.GotPlt->getVA();
Buf[1] = 0xa3;
write32le(Buf + 2, GotPltEntryAddr - Ebx);
} else {
@@ -445,9 +440,9 @@ void RetpolinePic::writeGotPlt(uint8_t *Buf, const Symbol &S) const {
void RetpolinePic::writePltHeader(uint8_t *Buf) const {
const uint8_t Insn[] = {
- 0xff, 0xb3, 0, 0, 0, 0, // 0: pushl GOTPLT+4(%ebx)
+ 0xff, 0xb3, 4, 0, 0, 0, // 0: pushl 4(%ebx)
0x50, // 6: pushl %eax
- 0x8b, 0x83, 0, 0, 0, 0, // 7: mov GOTPLT+8(%ebx), %eax
+ 0x8b, 0x83, 8, 0, 0, 0, // 7: mov 8(%ebx), %eax
0xe8, 0x0e, 0x00, 0x00, 0x00, // d: call next
0xf3, 0x90, // 12: loop: pause
0x0f, 0xae, 0xe8, // 14: lfence
@@ -462,11 +457,6 @@ void RetpolinePic::writePltHeader(uint8_t *Buf) const {
0xcc, // 2f: int3; padding
};
memcpy(Buf, Insn, sizeof(Insn));
-
- uint32_t Ebx = In.Got->getVA() + In.Got->getSize();
- uint32_t GotPlt = In.GotPlt->getVA() - Ebx;
- write32le(Buf + 2, GotPlt + 4);
- write32le(Buf + 9, GotPlt + 8);
}
void RetpolinePic::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr,
@@ -483,7 +473,7 @@ void RetpolinePic::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr,
};
memcpy(Buf, Insn, sizeof(Insn));
- uint32_t Ebx = In.Got->getVA() + In.Got->getSize();
+ uint32_t Ebx = In.GotPlt->getVA();
unsigned Off = getPltEntryOffset(Index);
write32le(Buf + 3, GotPltEntryAddr - Ebx);
write32le(Buf + 8, -Off - 12 + 32);
diff --git a/lld/ELF/Arch/X86_64.cpp b/lld/ELF/Arch/X86_64.cpp
index 05340f38c65..f9c731d270e 100644
--- a/lld/ELF/Arch/X86_64.cpp
+++ b/lld/ELF/Arch/X86_64.cpp
@@ -111,17 +111,17 @@ RelExpr X86_64<ELFT>::getRelExpr(RelType Type, const Symbol &S,
return R_PC;
case R_X86_64_GOT32:
case R_X86_64_GOT64:
- return R_GOT_FROM_END;
+ return R_GOTPLT;
case R_X86_64_GOTPCREL:
case R_X86_64_GOTPCRELX:
case R_X86_64_REX_GOTPCRELX:
case R_X86_64_GOTTPOFF:
return R_GOT_PC;
case R_X86_64_GOTOFF64:
- return R_GOTREL_FROM_END;
+ return R_GOTPLTREL;
case R_X86_64_GOTPC32:
case R_X86_64_GOTPC64:
- return R_GOTONLY_PC_FROM_END;
+ return R_GOTPLTONLY_PC;
case R_X86_64_NONE:
return R_NONE;
default:
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 7fcb279b8d3..88eccbe7e42 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -624,15 +624,15 @@ static uint64_t getRelocTargetVA(const InputFile *File, RelType Type, int64_t A,
return Sym.getGotVA() + A;
case R_GOTONLY_PC:
return In.Got->getVA() + A - P;
- case R_GOTONLY_PC_FROM_END:
- return In.Got->getVA() + A - P + In.Got->getSize();
+ case R_GOTPLTONLY_PC:
+ return In.GotPlt->getVA() + A - P;
case R_GOTREL:
return Sym.getVA(A) - In.Got->getVA();
- case R_GOTREL_FROM_END:
- return Sym.getVA(A) - In.Got->getVA() - In.Got->getSize();
- case R_GOT_FROM_END:
+ case R_GOTPLTREL:
+ return Sym.getVA(A) - In.GotPlt->getVA();
+ case R_GOTPLT:
case R_RELAX_TLS_GD_TO_IE_END:
- return Sym.getGotOffset() + A - In.Got->getSize();
+ return Sym.getGotVA() + A - In.GotPlt->getVA();
case R_TLSLD_GOT_OFF:
case R_GOT_OFF:
case R_RELAX_TLS_GD_TO_IE_GOT_OFF:
@@ -758,12 +758,12 @@ static uint64_t getRelocTargetVA(const InputFile *File, RelType Type, int64_t A,
getAArch64Page(P);
case R_TLSGD_GOT:
return In.Got->getGlobalDynOffset(Sym) + A;
- case R_TLSGD_GOT_FROM_END:
- return In.Got->getGlobalDynOffset(Sym) + A - In.Got->getSize();
+ case R_TLSGD_GOTPLT:
+ return In.Got->getVA() + In.Got->getGlobalDynOffset(Sym) + A - In.GotPlt->getVA();
case R_TLSGD_PC:
return In.Got->getGlobalDynAddr(Sym) + A - P;
- case R_TLSLD_GOT_FROM_END:
- return In.Got->getTlsIndexOff() + A - In.Got->getSize();
+ case R_TLSLD_GOTPLT:
+ return In.Got->getVA() + In.Got->getTlsIndexOff() + A - In.GotPlt->getVA();
case R_TLSLD_GOT:
return In.Got->getTlsIndexOff() + A;
case R_TLSLD_PC:
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index ceb9a8b91cc..354533504a6 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -229,7 +229,7 @@ handleTlsRelocation(RelType Type, Symbol &Sym, InputSectionBase &C,
return 1;
}
- if (oneof<R_TLSLD_GOT, R_TLSLD_GOT_FROM_END, R_TLSLD_PC, R_TLSLD_HINT>(
+ if (oneof<R_TLSLD_GOT, R_TLSLD_GOTPLT, R_TLSLD_PC, R_TLSLD_HINT>(
Expr)) {
// Local-Dynamic relocs can be relaxed to Local-Exec.
if (!Config->Shared) {
@@ -274,7 +274,7 @@ handleTlsRelocation(RelType Type, Symbol &Sym, InputSectionBase &C,
}
if (oneof<R_TLSDESC, R_AARCH64_TLSDESC_PAGE, R_TLSDESC_CALL, R_TLSGD_GOT,
- R_TLSGD_GOT_FROM_END, R_TLSGD_PC>(Expr)) {
+ R_TLSGD_GOTPLT, R_TLSGD_PC>(Expr)) {
if (Config->Shared) {
if (In.Got->addDynTlsEntry(Sym)) {
uint64_t Off = In.Got->getGlobalDynOffset(Sym);
@@ -314,7 +314,7 @@ handleTlsRelocation(RelType Type, Symbol &Sym, InputSectionBase &C,
// Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally
// defined.
- if (oneof<R_GOT, R_GOT_FROM_END, R_GOT_PC, R_AARCH64_GOT_PAGE_PC, R_GOT_OFF,
+ if (oneof<R_GOT, R_GOTPLT, R_GOT_PC, R_AARCH64_GOT_PAGE_PC, R_GOT_OFF,
R_TLSIE_HINT>(Expr) &&
!Config->Shared && !Sym.IsPreemptible) {
C.Relocations.push_back({R_RELAX_TLS_IE_TO_LE, Type, Offset, Addend, &Sym});
@@ -376,13 +376,13 @@ static bool needsPlt(RelExpr Expr) {
static bool needsGot(RelExpr Expr) {
return oneof<R_GOT, R_GOT_OFF, R_HEXAGON_GOT, R_MIPS_GOT_LOCAL_PAGE,
R_MIPS_GOT_OFF, R_MIPS_GOT_OFF32, R_AARCH64_GOT_PAGE_PC,
- R_GOT_PC, R_GOT_FROM_END>(Expr);
+ R_GOT_PC, R_GOTPLT>(Expr);
}
// True if this expression is of the form Sym - X, where X is a position in the
// file (PC, or GOT for example).
static bool isRelExpr(RelExpr Expr) {
- return oneof<R_PC, R_GOTREL, R_GOTREL_FROM_END, R_MIPS_GOTREL, R_PPC_CALL,
+ return oneof<R_PC, R_GOTREL, R_GOTPLTREL, R_MIPS_GOTREL, R_PPC_CALL,
R_PPC_CALL_PLT, R_AARCH64_PAGE_PC, R_RELAX_GOT_PC>(Expr);
}
@@ -398,11 +398,11 @@ static bool isRelExpr(RelExpr Expr) {
static bool isStaticLinkTimeConstant(RelExpr E, RelType Type, const Symbol &Sym,
InputSectionBase &S, uint64_t RelOff) {
// These expressions always compute a constant
- if (oneof<R_GOT_FROM_END, R_GOT_OFF, R_HEXAGON_GOT, R_TLSLD_GOT_OFF,
+ if (oneof<R_GOTPLT, R_GOT_OFF, R_HEXAGON_GOT, R_TLSLD_GOT_OFF,
R_MIPS_GOT_LOCAL_PAGE, R_MIPS_GOTREL, R_MIPS_GOT_OFF,
R_MIPS_GOT_OFF32, R_MIPS_GOT_GP_PC, R_MIPS_TLSGD,
R_AARCH64_GOT_PAGE_PC, R_GOT_PC, R_GOTONLY_PC,
- R_GOTONLY_PC_FROM_END, R_PLT_PC, R_TLSGD_GOT, R_TLSGD_GOT_FROM_END,
+ R_GOTPLTONLY_PC, R_PLT_PC, R_TLSGD_GOT, R_TLSGD_GOTPLT,
R_TLSGD_PC, R_PPC_CALL_PLT, R_TLSDESC_CALL, R_AARCH64_TLSDESC_PAGE,
R_HINT, R_TLSLD_HINT, R_TLSIE_HINT>(E))
return true;
@@ -1065,11 +1065,15 @@ static void scanReloc(InputSectionBase &Sec, OffsetGetter &GetOffset, RelTy *&I,
Expr = fromPlt(Expr);
}
- // This relocation does not require got entry, but it is relative to got and
- // needs it to be created. Here we request for that.
- if (oneof<R_GOTONLY_PC, R_GOTONLY_PC_FROM_END, R_GOTREL, R_GOTREL_FROM_END,
- R_PPC_TOC>(Expr))
+ // If the relocation does not emit a GOT or GOTPLT entry but its computation
+ // uses their addresses, we need GOT or GOTPLT to be created.
+ //
+ // The 4 types that relative GOTPLT are all x86 and x86-64 specific.
+ if (oneof<R_GOTPLTONLY_PC, R_GOTPLTREL, R_GOTPLT, R_TLSGD_GOTPLT>(Expr)) {
+ In.GotPlt->HasGotPltOffRel = true;
+ } else if (oneof<R_GOTONLY_PC, R_GOTREL, R_PPC_TOC>(Expr)) {
In.Got->HasGotOffRel = true;
+ }
// Read an addend.
int64_t Addend = computeAddend<ELFT>(Rel, End, Sec, Expr, Sym.isLocal());
diff --git a/lld/ELF/Relocations.h b/lld/ELF/Relocations.h
index b7de8a8367b..230fac0becd 100644
--- a/lld/ELF/Relocations.h
+++ b/lld/ELF/Relocations.h
@@ -32,13 +32,13 @@ enum RelExpr {
R_ABS,
R_ADDEND,
R_GOT,
- R_GOTONLY_PC,
- R_GOTONLY_PC_FROM_END,
- R_GOTREL,
- R_GOTREL_FROM_END,
- R_GOT_FROM_END,
R_GOT_OFF,
R_GOT_PC,
+ R_GOTONLY_PC,
+ R_GOTPLTONLY_PC,
+ R_GOTPLT,
+ R_GOTPLTREL,
+ R_GOTREL,
R_HINT,
R_NEG_TLS,
R_NONE,
@@ -61,11 +61,11 @@ enum RelExpr {
R_TLSDESC,
R_TLSDESC_CALL,
R_TLSGD_GOT,
- R_TLSGD_GOT_FROM_END,
+ R_TLSGD_GOTPLT,
R_TLSGD_PC,
R_TLSIE_HINT,
R_TLSLD_GOT,
- R_TLSLD_GOT_FROM_END,
+ R_TLSLD_GOTPLT,
R_TLSLD_GOT_OFF,
R_TLSLD_HINT,
R_TLSLD_PC,
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 52359397371..5e67610cbd3 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -650,10 +650,8 @@ void GotSection::finalizeContents() {
bool GotSection::empty() const {
// We need to emit a GOT even if it's empty if there's a relocation that is
- // relative to GOT(such as GOTOFFREL) or there's a symbol that points to a GOT
- // (i.e. _GLOBAL_OFFSET_TABLE_) that the target defines relative to the .got.
- return NumEntries == 0 && !HasGotOffRel &&
- !(ElfSym::GlobalOffsetTable && !Target->GotBaseSymInGotPlt);
+ // relative to GOT(such as GOTOFFREL).
+ return NumEntries == 0 && !HasGotOffRel;
}
void GotSection::writeTo(uint8_t *Buf) {
@@ -1114,11 +1112,9 @@ void GotPltSection::writeTo(uint8_t *Buf) {
}
bool GotPltSection::empty() const {
- // We need to emit a GOT.PLT even if it's empty if there's a symbol that
- // references the _GLOBAL_OFFSET_TABLE_ and the Target defines the symbol
- // relative to the .got.plt section.
- return Entries.empty() &&
- !(ElfSym::GlobalOffsetTable && Target->GotBaseSymInGotPlt);
+ // We need to emit GOTPLT even if it's empty if there's a relocation relative
+ // to it.
+ return Entries.empty() && !HasGotPltOffRel;
}
static StringRef getIgotPltName() {
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index c8dda4621d3..371be2ebada 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -363,6 +363,10 @@ public:
void writeTo(uint8_t *Buf) override;
bool empty() const override;
+ // Flag to force GotPlt to be in output if we have relocations
+ // that relies on its address.
+ bool HasGotPltOffRel = false;
+
private:
std::vector<const Symbol *> Entries;
};
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 2fdecaa7e7f..3ba80274a63 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -383,6 +383,15 @@ template <class ELFT> static void createSyntheticSections() {
In.IgotPlt = make<IgotPltSection>();
Add(In.IgotPlt);
+ // _GLOBAL_OFFSET_TABLE_ is defined relative to either .got.plt or .got. Treat
+ // it as a relocation and ensure the referenced section is created.
+ if (ElfSym::GlobalOffsetTable && Config->EMachine != EM_MIPS) {
+ if (Target->GotBaseSymInGotPlt)
+ In.GotPlt->HasGotPltOffRel = true;
+ else
+ In.Got->HasGotOffRel = true;
+ }
+
if (Config->GdbIndex)
Add(GdbIndexSection::create<ELFT>());
diff --git a/lld/test/ELF/got-i386.s b/lld/test/ELF/got-i386.s
index 3b2ef1a31c2..d01749db089 100644
--- a/lld/test/ELF/got-i386.s
+++ b/lld/test/ELF/got-i386.s
@@ -4,7 +4,7 @@
// RUN: llvm-readobj -s -r -t %t | FileCheck %s
// RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s
-// CHECK: Name: .got
+// CHECK: Name: .got.plt
// CHECK-NEXT: Type: SHT_PROGBITS
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
@@ -12,14 +12,14 @@
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x402000
// CHECK-NEXT: Offset:
-// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Size:
// CHECK-NEXT: Link:
// CHECK-NEXT: Info:
// CHECK-NEXT: AddressAlignment:
// CHECK: Symbol {
// CHECK: Name: bar
-// CHECK-NEXT: Value: 0x402000
+// CHECK-NEXT: Value: 0x40200C
// CHECK-NEXT: Size: 10
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Object
@@ -28,7 +28,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: obj
-// CHECK-NEXT: Value: 0x40200A
+// CHECK-NEXT: Value: 0x402016
// CHECK-NEXT: Size: 10
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: Object
@@ -41,9 +41,9 @@
// 0x40200A + 5 - 15 = addr(.got) = 0x402000
// DISASM: Disassembly of section .text:
// DISASM-NEXT: _start:
-// DISASM-NEXT: 401000: c7 81 00 00 00 00 01 00 00 00 movl $1, (%ecx)
-// DISASM-NEXT: 40100a: c7 81 0a 00 00 00 02 00 00 00 movl $2, 10(%ecx)
-// DISASM-NEXT: 401014: c7 81 0f 00 00 00 03 00 00 00 movl $3, 15(%ecx)
+// DISASM-NEXT: 401000: c7 81 0c 00 00 00 01 00 00 00 movl $1, 12(%ecx)
+// DISASM-NEXT: 40100a: c7 81 16 00 00 00 02 00 00 00 movl $2, 22(%ecx)
+// DISASM-NEXT: 401014: c7 81 1b 00 00 00 03 00 00 00 movl $3, 27(%ecx)
.global _start
_start:
diff --git a/lld/test/ELF/got32x-i386.s b/lld/test/ELF/got32x-i386.s
index f440deea373..0e601fe7498 100644
--- a/lld/test/ELF/got32x-i386.s
+++ b/lld/test/ELF/got32x-i386.s
@@ -35,11 +35,11 @@
# CHECK: _start:
# CHECK-NEXT: 401001: 8b 05 {{.*}} movl 4202496, %eax
# CHECK-NEXT: 401007: 8b 1d {{.*}} movl 4202496, %ebx
-# CHECK-NEXT: 40100d: 8b 80 {{.*}} movl -4(%eax), %eax
-# CHECK-NEXT: 401013: 8b 83 {{.*}} movl -4(%ebx), %eax
+# CHECK-NEXT: 40100d: 8b 80 {{.*}} movl -4096(%eax), %eax
+# CHECK-NEXT: 401013: 8b 83 {{.*}} movl -4096(%ebx), %eax
# CHECK: Sections:
# CHECK: Name Size VMA
-# CHECK: .got 00000004 0000000000402000
+# CHECK: .got.plt 0000000c 0000000000403000
# RUN: not ld.lld %S/Inputs/i386-got32x-baseless.elf -o %t1 -pie 2>&1 | \
# RUN: FileCheck %s --check-prefix=ERR
diff --git a/lld/test/ELF/i386-gotoff-shared.s b/lld/test/ELF/i386-gotoff-shared.s
index c22bd6dd5d7..59369b3e3f2 100644
--- a/lld/test/ELF/i386-gotoff-shared.s
+++ b/lld/test/ELF/i386-gotoff-shared.s
@@ -1,23 +1,15 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared
-// RUN: llvm-readobj -s %t.so | FileCheck %s
+// RUN: llvm-readelf -S %t.so | FileCheck %s
// RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=DISASM %s
bar:
movl bar@GOTOFF(%ebx), %eax
mov bar@GOT, %eax
-// CHECK: Name: .got
-// CHECK-NEXT: Type: SHT_PROGBITS
-// CHECK-NEXT: Flags [
-// CHECK-NEXT: SHF_ALLOC
-// CHECK-NEXT: SHF_WRITE
-// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x2050
-// CHECK-NEXT: Offset: 0x2050
-// CHECK-NEXT: Size: 4
+// CHECK: .got.plt PROGBITS 00003000
-// 0x1000 - (0x2050 + 4) = -4180
+// 0x1000 - 0x3000 (.got.plt) = -8192
-// DISASM: 1000: {{.*}} movl -4180(%ebx), %eax
+// DISASM: 1000: {{.*}} movl -8192(%ebx), %eax
diff --git a/lld/test/ELF/i386-gotpc-dynamic.s b/lld/test/ELF/i386-gotpc-dynamic.s
index 0ec737e701a..c75f0bef4a2 100644
--- a/lld/test/ELF/i386-gotpc-dynamic.s
+++ b/lld/test/ELF/i386-gotpc-dynamic.s
@@ -1,28 +1,13 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
# RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared
-# RUN: llvm-readobj -s %t.so | FileCheck %s
+# RUN: llvm-readelf -S %t.so | FileCheck %s
# RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=DISASM %s
-# CHECK: Section {
-# CHECK: Index: 7
-# CHECK-NEXT: Name: .got
-# CHECK-NEXT: Type: SHT_PROGBITS
-# CHECK-NEXT: Flags [
-# CHECK-NEXT: SHF_ALLOC
-# CHECK-NEXT: SHF_WRITE
-# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x2030
-# CHECK-NEXT: Offset:
-# CHECK-NEXT: Size:
-# CHECK-NEXT: Link:
-# CHECK-NEXT: Info:
-# CHECK-NEXT: AddressAlignment:
-# CHECK-NEXT: EntrySize:
-# CHECK-NEXT: }
+# CHECK: .got.plt PROGBITS 00003000
-## 0x1000 + 4144 = 0x2030
-# DISASM: 1000: {{.*}} movl $4144, %eax
+## 0x3000 - 0x1000 = 8192
+# DISASM: 1000: {{.*}} movl $8192, %eax
.section .foo,"ax",@progbits
foo:
diff --git a/lld/test/ELF/i386-gotpc.s b/lld/test/ELF/i386-gotpc.s
index e53a688f740..780c3efe95a 100644
--- a/lld/test/ELF/i386-gotpc.s
+++ b/lld/test/ELF/i386-gotpc.s
@@ -1,28 +1,14 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared
-// RUN: llvm-readobj -s %t.so | FileCheck %s
+// RUN: llvm-readelf -S %t.so | FileCheck %s
// RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=DISASM %s
movl $_GLOBAL_OFFSET_TABLE_, %eax
-// CHECK: Name: .got
-// CHECK-NEXT: Type: SHT_PROGBITS
-// CHECK-NEXT: Flags [
-// CHECK-NEXT: SHF_ALLOC
-// CHECK-NEXT: SHF_WRITE
-// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x2030
-
-// CHECK: Name: .got.plt
-// CHECK-NEXT: Type: SHT_PROGBITS
-// CHECK-NEXT: Flags [
-// CHECK-NEXT: SHF_ALLOC
-// CHECK-NEXT: SHF_WRITE
-// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x3000
+// CHECK: .got.plt PROGBITS 00003000
// DISASM: Disassembly of section .text:
// DISASM-NEXT: .text:
-// DISASM-NEXT: 1000: {{.*}} movl $4144, %eax
-// 0x2030 - 0x1000 = 0x1030
+// DISASM-NEXT: 1000: {{.*}} movl $8192, %eax
+// 0x3000 (.got.plt) - 0x1000 = 8192
diff --git a/lld/test/ELF/i386-relax-reloc.s b/lld/test/ELF/i386-relax-reloc.s
index a7fdc404cec..8aeb53fa9b6 100644
--- a/lld/test/ELF/i386-relax-reloc.s
+++ b/lld/test/ELF/i386-relax-reloc.s
@@ -1,12 +1,17 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o -relax-relocations
// RUN: ld.lld -shared %t.o -o %t.so
+// RUN: llvm-readelf -S %t.so | FileCheck --check-prefix=SEC %s
// RUN: llvm-objdump -d %t.so | FileCheck %s
+// SEC: .got PROGBITS 00002050
+// SEC-NEXT: .got.plt PROGBITS 00003000
+
+// 0x2050 - 0x3000 = -4016
+// CHECK: foo:
+// CHECK-NEXT: movl -4016(%ebx), %eax
+// CHECK-NEXT: movl -4008(%ebx), %eax
+
foo:
movl bar@GOT(%ebx), %eax
movl bar+8@GOT(%ebx), %eax
-
-// CHECK: foo:
-// CHECK-NEXT: movl -4(%ebx), %eax
-// CHECK-NEXT: movl 4(%ebx), %eax
diff --git a/lld/test/ELF/i386-retpoline-pic-linkerscript.s b/lld/test/ELF/i386-retpoline-pic-linkerscript.s
index 56ab19e1af6..cddc206cbe9 100644
--- a/lld/test/ELF/i386-retpoline-pic-linkerscript.s
+++ b/lld/test/ELF/i386-retpoline-pic-linkerscript.s
@@ -14,9 +14,9 @@
// CHECK: Disassembly of section .plt:
// CHECK-NEXT: .plt:
-// CHECK-NEXT: 10: ff b3 ec 00 00 00 pushl 236(%ebx)
+// CHECK-NEXT: 10: ff b3 04 00 00 00 pushl 4(%ebx)
// CHECK-NEXT: 16: 50 pushl %eax
-// CHECK-NEXT: 17: 8b 83 f0 00 00 00 movl 240(%ebx), %eax
+// CHECK-NEXT: 17: 8b 83 08 00 00 00 movl 8(%ebx), %eax
// CHECK-NEXT: 1d: e8 0e 00 00 00 calll 14 <.plt+0x20>
// CHECK-NEXT: 22: f3 90 pause
// CHECK-NEXT: 24: 0f ae e8 lfence
@@ -36,7 +36,7 @@
// CHECK-NEXT: 3e: c3 retl
// CHECK-NEXT: 3f: cc int3
// CHECK-NEXT: 40: 50 pushl %eax
-// CHECK-NEXT: 41: 8b 83 f4 00 00 00 movl 244(%ebx), %eax
+// CHECK-NEXT: 41: 8b 83 0c 00 00 00 movl 12(%ebx), %eax
// CHECK-NEXT: 47: e8 e4 ff ff ff calll -28 <.plt+0x20>
// CHECK-NEXT: 4c: e9 d1 ff ff ff jmp -47 <.plt+0x12>
// CHECK-NEXT: 51: 68 00 00 00 00 pushl $0
@@ -47,7 +47,7 @@
// CHECK-NEXT: 5e: cc int3
// CHECK-NEXT: 5f: cc int3
// CHECK-NEXT: 60: 50 pushl %eax
-// CHECK-NEXT: 61: 8b 83 f8 00 00 00 movl 248(%ebx), %eax
+// CHECK-NEXT: 61: 8b 83 10 00 00 00 movl 16(%ebx), %eax
// CHECK-NEXT: 67: e8 c4 ff ff ff calll -60 <.plt+0x20>
// CHECK-NEXT: 6c: e9 b1 ff ff ff jmp -79 <.plt+0x12>
// CHECK-NEXT: 71: 68 08 00 00 00 pushl $8
diff --git a/lld/test/ELF/i386-retpoline-pic.s b/lld/test/ELF/i386-retpoline-pic.s
index f625ab79308..28a993f04eb 100644
--- a/lld/test/ELF/i386-retpoline-pic.s
+++ b/lld/test/ELF/i386-retpoline-pic.s
@@ -8,9 +8,9 @@
// CHECK: Disassembly of section .plt:
// CHECK-NEXT: .plt:
-// CHECK-NEXT: 1010: ff b3 04 30 00 00 pushl 12292(%ebx)
+// CHECK-NEXT: 1010: ff b3 04 00 00 00 pushl 4(%ebx)
// CHECK-NEXT: 1016: 50 pushl %eax
-// CHECK-NEXT: 1017: 8b 83 08 30 00 00 movl 12296(%ebx), %eax
+// CHECK-NEXT: 1017: 8b 83 08 00 00 00 movl 8(%ebx), %eax
// CHECK-NEXT: 101d: e8 0e 00 00 00 calll 14 <.plt+0x20>
// CHECK-NEXT: 1022: f3 90 pause
// CHECK-NEXT: 1024: 0f ae e8 lfence
@@ -30,7 +30,7 @@
// CHECK-NEXT: 103e: c3 retl
// CHECK-NEXT: 103f: cc int3
// CHECK-NEXT: 1040: 50 pushl %eax
-// CHECK-NEXT: 1041: 8b 83 0c 30 00 00 movl 12300(%ebx), %eax
+// CHECK-NEXT: 1041: 8b 83 0c 00 00 00 movl 12(%ebx), %eax
// CHECK-NEXT: 1047: e8 e4 ff ff ff calll -28 <.plt+0x20>
// CHECK-NEXT: 104c: e9 d1 ff ff ff jmp -47 <.plt+0x12>
// CHECK-NEXT: 1051: 68 00 00 00 00 pushl $0
@@ -41,7 +41,7 @@
// CHECK-NEXT: 105e: cc int3
// CHECK-NEXT: 105f: cc int3
// CHECK-NEXT: 1060: 50 pushl %eax
-// CHECK-NEXT: 1061: 8b 83 10 30 00 00 movl 12304(%ebx), %eax
+// CHECK-NEXT: 1061: 8b 83 10 00 00 00 movl 16(%ebx), %eax
// CHECK-NEXT: 1067: e8 c4 ff ff ff calll -60 <.plt+0x20>
// CHECK-NEXT: 106c: e9 b1 ff ff ff jmp -79 <.plt+0x12>
// CHECK-NEXT: 1071: 68 08 00 00 00 pushl $8
diff --git a/lld/test/ELF/plt-i686.s b/lld/test/ELF/plt-i686.s
index 8e0a6db8c7e..a32a2a3f949 100644
--- a/lld/test/ELF/plt-i686.s
+++ b/lld/test/ELF/plt-i686.s
@@ -139,31 +139,35 @@
// DISASMSHARED-NEXT: 1013: e9 e8 ff ff ff jmp -24
// DISASMSHARED-NEXT: Disassembly of section .plt:
// DISASMSHARED-NEXT: .plt:
-// DISASMSHARED-NEXT: 1020: ff b3 04 30 00 00 pushl 12292(%ebx)
-// DISASMSHARED-NEXT: 1026: ff a3 08 30 00 00 jmpl *12296(%ebx)
+// DISASMSHARED-NEXT: 1020: ff b3 04 00 00 00 pushl 4(%ebx)
+// DISASMSHARED-NEXT: 1026: ff a3 08 00 00 00 jmpl *8(%ebx)
// DISASMSHARED-NEXT: 102c: 90 nop
// DISASMSHARED-NEXT: 102d: 90 nop
// DISASMSHARED-NEXT: 102e: 90 nop
// DISASMSHARED-NEXT: 102f: 90 nop
-// DISASMSHARED-NEXT: 1030: ff a3 0c 30 00 00 jmpl *12300(%ebx)
+// DISASMSHARED: bar@plt:
+// DISASMSHARED-NEXT: 1030: ff a3 0c 00 00 00 jmpl *12(%ebx)
// DISASMSHARED-NEXT: 1036: 68 00 00 00 00 pushl $0
// DISASMSHARED-NEXT: 103b: e9 e0 ff ff ff jmp -32 <.plt>
-// DISASMSHARED-NEXT: 1040: ff a3 10 30 00 00 jmpl *12304(%ebx)
+// DISASMSHARED: zed@plt:
+// DISASMSHARED-NEXT: 1040: ff a3 10 00 00 00 jmpl *16(%ebx)
// DISASMSHARED-NEXT: 1046: 68 08 00 00 00 pushl $8
// DISASMSHARED-NEXT: 104b: e9 d0 ff ff ff jmp -48 <.plt>
// DISASMPIE: Disassembly of section .plt:
// DISASMPIE-NEXT: .plt:
-// DISASMPIE-NEXT: 1020: ff b3 04 30 00 00 pushl 12292(%ebx)
-// DISASMPIE-NEXT: 1026: ff a3 08 30 00 00 jmpl *12296(%ebx)
+// DISASMPIE-NEXT: 1020: ff b3 04 00 00 00 pushl 4(%ebx)
+// DISASMPIE-NEXT: 1026: ff a3 08 00 00 00 jmpl *8(%ebx)
// DISASMPIE-NEXT: 102c: 90 nop
// DISASMPIE-NEXT: 102d: 90 nop
// DISASMPIE-NEXT: 102e: 90 nop
// DISASMPIE-NEXT: 102f: 90 nop
-// DISASMPIE-NEXT: 1030: ff a3 0c 30 00 00 jmpl *12300(%ebx)
+// DISASMPIE: bar@plt:
+// DISASMPIE-NEXT: 1030: ff a3 0c 00 00 00 jmpl *12(%ebx)
// DISASMPIE-NEXT: 1036: 68 00 00 00 00 pushl $0
// DISASMPIE-NEXT: 103b: e9 e0 ff ff ff jmp -32 <.plt>
-// DISASMPIE-NEXT: 1040: ff a3 10 30 00 00 jmpl *12304(%ebx)
+// DISASMPIE: zed@plt:
+// DISASMPIE-NEXT: 1040: ff a3 10 00 00 00 jmpl *16(%ebx)
// DISASMPIE-NEXT: 1046: 68 08 00 00 00 pushl $8
// DISASMPIE-NEXT: 104b: e9 d0 ff ff ff jmp -48 <.plt>
diff --git a/lld/test/ELF/relocation-i686.s b/lld/test/ELF/relocation-i686.s
index efcb9beb96a..904248d308f 100644
--- a/lld/test/ELF/relocation-i686.s
+++ b/lld/test/ELF/relocation-i686.s
@@ -49,25 +49,25 @@ movl bar@GOT, %eax
// ADDR-NEXT: Offset: 0x1040
// ADDR-NEXT: Size: 32
-// ADDR: Name: .got (
+// ADDR: Name: .got.plt (
// ADDR-NEXT: Type: SHT_PROGBITS
// ADDR-NEXT: Flags [
// ADDR-NEXT: SHF_ALLOC
// ADDR-NEXT: SHF_WRITE
// ADDR-NEXT: ]
-// ADDR-NEXT: Address: 0x402078
+// ADDR-NEXT: Address: 0x403000
// ADDR-NEXT: Offset:
-// ADDR-NEXT: Size: 8
+// ADDR-NEXT: Size:
.section .R_386_GOTPC,"ax",@progbits
R_386_GOTPC:
movl $_GLOBAL_OFFSET_TABLE_, %eax
-// 0x402078 + 8 - 0x401014 = 8300
+// 0x403000 (.got.plt) - 0x401014 = 8300
// CHECK: Disassembly of section .R_386_GOTPC:
// CHECK-NEXT: R_386_GOTPC:
-// CHECK-NEXT: 401014: {{.*}} movl $4204, %eax
+// CHECK-NEXT: 401014: {{.*}} movl $8172, %eax
.section .dynamic_reloc, "ax",@progbits
call bar
@@ -84,13 +84,11 @@ R_386_GOT32:
movl bar+8@GOT, %eax
movl zed+4@GOT, %eax
-// 4294967288 = 0xFFFFFFF8 = got[0](0x402070) - .got(0x402070) - sizeof(.got)(8)
-// 4294967292 = 0xFFFFFFFC = got[1](0x402074) - .got(0x402070) - sizeof(.got)(8)
-// 0xFFFFFFF8 + 8 = 0
-// 0xFFFFFFFC + 4 = 0
+// 4294963320 = 0xfffff078 = got[0](0x402078) - .got.plt(0x403000)
+// 4294963324 = 0xfffff07c = got[1](0x40207c) - .got(0x403000)
// CHECK: Disassembly of section .R_386_GOT32:
// CHECK-NEXT: R_386_GOT32:
-// CHECK-NEXT: 40101e: a1 f8 ff ff ff movl 4294967288, %eax
-// CHECK-NEXT: 401023: a1 fc ff ff ff movl 4294967292, %eax
-// CHECK-NEXT: 401028: a1 00 00 00 00 movl 0, %eax
-// CHECK-NEXT: 40102d: a1 00 00 00 00 movl 0, %eax
+// CHECK-NEXT: 40101e: a1 78 f0 ff ff movl 4294963320, %eax
+// CHECK-NEXT: 401023: a1 7c f0 ff ff movl 4294963324, %eax
+// CHECK-NEXT: 401028: a1 80 f0 ff ff movl 4294963328, %eax
+// CHECK-NEXT: 40102d: a1 80 f0 ff ff movl 4294963328, %eax
diff --git a/lld/test/ELF/relocation.s b/lld/test/ELF/relocation.s
index 034ebe56547..5a843bef41a 100644
--- a/lld/test/ELF/relocation.s
+++ b/lld/test/ELF/relocation.s
@@ -130,11 +130,11 @@ R_X86_64_GOT32:
.long zed@got
// CHECK: Contents of section .R_X86_64_GOT32:
-// CHECK-NEXT: f8ffffff
+// CHECK-NEXT: f0f0ffff
// CHECK: Contents of section .R_X86_64_GOT64:
-// CHECK-NEXT: f8ffffff ffffffff
+// CHECK-NEXT: f0f0ffff ffffffff
.section .R_X86_64_GOT64,"a",@progbits
.global R_X86_64_GOT64
R_X86_64_GOT64:
diff --git a/lld/test/ELF/shared.s b/lld/test/ELF/shared.s
index e00dd9937ff..7b107a21a90 100644
--- a/lld/test/ELF/shared.s
+++ b/lld/test/ELF/shared.s
@@ -46,7 +46,7 @@
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: ]
// CHECK-NEXT: Address: [[DYNSYMADDR:.*]]
-// CHECK-NEXT: Offset: 0x150
+// CHECK-NEXT: Offset: 0x170
// CHECK-NEXT: Size:
// CHECK-NEXT: Link: [[DYNSTR:.*]]
// CHECK-NEXT: Info: 1
diff --git a/lld/test/ELF/tls-dynamic-i686.s b/lld/test/ELF/tls-dynamic-i686.s
index 9ad624c2982..0eec98c6161 100644
--- a/lld/test/ELF/tls-dynamic-i686.s
+++ b/lld/test/ELF/tls-dynamic-i686.s
@@ -1,6 +1,6 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t
-// RUN: ld.lld --hash-style=sysv -shared %t -o %tout
+// RUN: ld.lld --hash-style=sysv -shared -z norelro %t -o %tout
// RUN: llvm-readobj -sections -relocations %tout | FileCheck %s
// RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DIS
diff --git a/lld/test/ELF/tls-opt-gdiele-i686.s b/lld/test/ELF/tls-opt-gdiele-i686.s
index 1baaf111cbf..a1aa0947b5f 100644
--- a/lld/test/ELF/tls-opt-gdiele-i686.s
+++ b/lld/test/ELF/tls-opt-gdiele-i686.s
@@ -16,9 +16,9 @@
// DISASM: Disassembly of section .text:
// DISASM-NEXT: _start:
// DISASM-NEXT: 401000: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 401006: 03 83 f8 ff ff ff addl -8(%ebx), %eax
+// DISASM-NEXT: 401006: 03 83 58 f0 ff ff addl -4008(%ebx), %eax
// DISASM-NEXT: 40100c: 65 a1 00 00 00 00 movl %gs:0, %eax
-// DISASM-NEXT: 401012: 03 83 fc ff ff ff addl -4(%ebx), %eax
+// DISASM-NEXT: 401012: 03 83 5c f0 ff ff addl -4004(%ebx), %eax
// DISASM-NEXT: 401018: 65 a1 00 00 00 00 movl %gs:0, %eax
// DISASM-NEXT: 40101e: 81 e8 08 00 00 00 subl $8, %eax
// DISASM-NEXT: 401024: 65 a1 00 00 00 00 movl %gs:0, %eax
@@ -53,7 +53,7 @@ leal tlsshared0@tlsgd(,%ebx,1),%eax
call ___tls_get_addr@plt
leal tlsshared1@tlsgd(,%ebx,1),%eax
call ___tls_get_addr@plt
-//GD->IE
+//GD->LE
leal tlsexe1@tlsgd(,%ebx,1),%eax
call ___tls_get_addr@plt
leal tlsexe2@tlsgd(,%ebx,1),%eax
diff --git a/lld/test/ELF/x86-64-reloc-gotoff64.s b/lld/test/ELF/x86-64-reloc-gotoff64.s
index 285d7b9f0ea..9cc9dd7d948 100644
--- a/lld/test/ELF/x86-64-reloc-gotoff64.s
+++ b/lld/test/ELF/x86-64-reloc-gotoff64.s
@@ -5,13 +5,7 @@
// RUN: llvm-objdump -d %t.so | FileCheck %s
// SECTION: .dynamic DYNAMIC 0000000000002000
-// SECTION: .got PROGBITS 0000000000002070 002070 000000
-
-// All the _GLOBAL_OFFSET_TABLE_ occurrences below refer to the address
-// of GOT base, not the address of the symbol _GLOBAL_OFFSET_TABLE_. These
-// instructions are special and produce GOT base relative relocations. We
-// currently use .got end as the GOT base, which is not equal to
-// the address of the special symbol _GLOBAL_OFFSET_TABLE_.
+// SECTION: .got.plt PROGBITS 0000000000003000 003000 000018
// The assembly is generated by
// gcc -O2 -S -mcmodel=medium -fPIC a.c
@@ -20,10 +14,10 @@
// extern long _DYNAMIC[] __attribute__((visibility("hidden")));
// long* dynamic() { return _DYNAMIC; }
-// 0x2070 (.got end) - 0x1007 = 4201
-// 0x2000 (_DYNAMIC) - 0x2070 (.got end) = -112
-// CHECK: 1000: {{.*}} leaq 4201(%rip), %rdx
-// CHECK-NEXT: 1007: {{.*}} movabsq $-112, %rax
+// 0x3000 (.got.plt) - 0x1007 = 8185
+// 0x2000 (_DYNAMIC) - 0x3000 (.got.plt) = -4096
+// CHECK: 1000: {{.*}} leaq 8185(%rip), %rdx
+// CHECK-NEXT: 1007: {{.*}} movabsq $-4096, %rax
.global dynamic
dynamic:
leaq _GLOBAL_OFFSET_TABLE_(%rip), %rdx
diff --git a/lld/test/ELF/x86-64-reloc-gotpc64.s b/lld/test/ELF/x86-64-reloc-gotpc64.s
index 64604995821..cbd8a3acfe5 100644
--- a/lld/test/ELF/x86-64-reloc-gotpc64.s
+++ b/lld/test/ELF/x86-64-reloc-gotpc64.s
@@ -4,11 +4,11 @@
// RUN: llvm-readelf -S %t.so | FileCheck %s -check-prefix=SECTION
// RUN: llvm-objdump -d %t.so | FileCheck %s
-// SECTION: .got PROGBITS 0000000000002070 002070 000000
+// SECTION: .got.plt PROGBITS 0000000000003000 003000 000018
-// 0x2070 (.got end) - 0x1000 = 4208
+// 0x3000 (.got.plt) - 0x1000 = 8192
// CHECK: gotpc64:
-// CHECK-NEXT: 1000: {{.*}} movabsq $4208, %r11
+// CHECK-NEXT: 1000: {{.*}} movabsq $8192, %r11
.global gotpc64
gotpc64:
movabsq $_GLOBAL_OFFSET_TABLE_-., %r11
OpenPOWER on IntegriCloud