[lld] r356968 - [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt))
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 25 16:46:20 PDT 2019
Author: maskray
Date: Mon Mar 25 16:46:19 2019
New Revision: 356968
URL: http://llvm.org/viewvc/llvm-project?rev=356968&view=rev
Log:
[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
Modified:
lld/trunk/ELF/Arch/X86.cpp
lld/trunk/ELF/Arch/X86_64.cpp
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/Relocations.cpp
lld/trunk/ELF/Relocations.h
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/ELF/SyntheticSections.h
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/got-i386.s
lld/trunk/test/ELF/got32x-i386.s
lld/trunk/test/ELF/i386-gotoff-shared.s
lld/trunk/test/ELF/i386-gotpc-dynamic.s
lld/trunk/test/ELF/i386-gotpc.s
lld/trunk/test/ELF/i386-relax-reloc.s
lld/trunk/test/ELF/i386-retpoline-pic-linkerscript.s
lld/trunk/test/ELF/i386-retpoline-pic.s
lld/trunk/test/ELF/plt-i686.s
lld/trunk/test/ELF/relocation-i686.s
lld/trunk/test/ELF/relocation.s
lld/trunk/test/ELF/shared.s
lld/trunk/test/ELF/tls-dynamic-i686.s
lld/trunk/test/ELF/tls-opt-gdiele-i686.s
lld/trunk/test/ELF/x86-64-reloc-gotoff64.s
lld/trunk/test/ELF/x86-64-reloc-gotpc64.s
Modified: lld/trunk/ELF/Arch/X86.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/X86.cpp?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/X86.cpp (original)
+++ lld/trunk/ELF/Arch/X86.cpp Mon Mar 25 16:46:19 2019
@@ -87,9 +87,9 @@ RelExpr X86::getRelExpr(RelType Type, co
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, co
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, co
// 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) con
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_
if (Config->Pic) {
// jmp *foo at 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 *
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_
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
};
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);
Modified: lld/trunk/ELF/Arch/X86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/X86_64.cpp?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/X86_64.cpp (original)
+++ lld/trunk/ELF/Arch/X86_64.cpp Mon Mar 25 16:46:19 2019
@@ -111,17 +111,17 @@ RelExpr X86_64<ELFT>::getRelExpr(RelType
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:
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Mon Mar 25 16:46:19 2019
@@ -624,15 +624,15 @@ static uint64_t getRelocTargetVA(const I
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 I
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:
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Mon Mar 25 16:46:19 2019
@@ -229,7 +229,7 @@ handleTlsRelocation(RelType Type, Symbol
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
}
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
// 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 &
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());
Modified: lld/trunk/ELF/Relocations.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.h?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.h (original)
+++ lld/trunk/ELF/Relocations.h Mon Mar 25 16:46:19 2019
@@ -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,
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Mon Mar 25 16:46:19 2019
@@ -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() {
Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Mon Mar 25 16:46:19 2019
@@ -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;
};
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Mar 25 16:46:19 2019
@@ -383,6 +383,15 @@ template <class ELFT> static void create
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>());
Modified: lld/trunk/test/ELF/got-i386.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/got-i386.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/got-i386.s (original)
+++ lld/trunk/test/ELF/got-i386.s Mon Mar 25 16:46:19 2019
@@ -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:
Modified: lld/trunk/test/ELF/got32x-i386.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/got32x-i386.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/got32x-i386.s (original)
+++ lld/trunk/test/ELF/got32x-i386.s Mon Mar 25 16:46:19 2019
@@ -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
Modified: lld/trunk/test/ELF/i386-gotoff-shared.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/i386-gotoff-shared.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/i386-gotoff-shared.s (original)
+++ lld/trunk/test/ELF/i386-gotoff-shared.s Mon Mar 25 16:46:19 2019
@@ -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 at GOTOFF(%ebx), %eax
mov bar at 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
Modified: lld/trunk/test/ELF/i386-gotpc-dynamic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/i386-gotpc-dynamic.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/i386-gotpc-dynamic.s (original)
+++ lld/trunk/test/ELF/i386-gotpc-dynamic.s Mon Mar 25 16:46:19 2019
@@ -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", at progbits
foo:
Modified: lld/trunk/test/ELF/i386-gotpc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/i386-gotpc.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/i386-gotpc.s (original)
+++ lld/trunk/test/ELF/i386-gotpc.s Mon Mar 25 16:46:19 2019
@@ -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
Modified: lld/trunk/test/ELF/i386-relax-reloc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/i386-relax-reloc.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/i386-relax-reloc.s (original)
+++ lld/trunk/test/ELF/i386-relax-reloc.s Mon Mar 25 16:46:19 2019
@@ -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 at GOT(%ebx), %eax
movl bar+8 at GOT(%ebx), %eax
-
-// CHECK: foo:
-// CHECK-NEXT: movl -4(%ebx), %eax
-// CHECK-NEXT: movl 4(%ebx), %eax
Modified: lld/trunk/test/ELF/i386-retpoline-pic-linkerscript.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/i386-retpoline-pic-linkerscript.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/i386-retpoline-pic-linkerscript.s (original)
+++ lld/trunk/test/ELF/i386-retpoline-pic-linkerscript.s Mon Mar 25 16:46:19 2019
@@ -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
Modified: lld/trunk/test/ELF/i386-retpoline-pic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/i386-retpoline-pic.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/i386-retpoline-pic.s (original)
+++ lld/trunk/test/ELF/i386-retpoline-pic.s Mon Mar 25 16:46:19 2019
@@ -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
Modified: lld/trunk/test/ELF/plt-i686.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/plt-i686.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/plt-i686.s (original)
+++ lld/trunk/test/ELF/plt-i686.s Mon Mar 25 16:46:19 2019
@@ -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 at 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 at 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 at 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 at 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>
Modified: lld/trunk/test/ELF/relocation-i686.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-i686.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/relocation-i686.s (original)
+++ lld/trunk/test/ELF/relocation-i686.s Mon Mar 25 16:46:19 2019
@@ -49,25 +49,25 @@ movl bar at 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", at 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", at progbits
call bar
@@ -84,13 +84,11 @@ R_386_GOT32:
movl bar+8 at GOT, %eax
movl zed+4 at 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
Modified: lld/trunk/test/ELF/relocation.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/relocation.s (original)
+++ lld/trunk/test/ELF/relocation.s Mon Mar 25 16:46:19 2019
@@ -130,11 +130,11 @@ R_X86_64_GOT32:
.long zed at 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", at progbits
.global R_X86_64_GOT64
R_X86_64_GOT64:
Modified: lld/trunk/test/ELF/shared.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/shared.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/shared.s (original)
+++ lld/trunk/test/ELF/shared.s Mon Mar 25 16:46:19 2019
@@ -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
Modified: lld/trunk/test/ELF/tls-dynamic-i686.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/tls-dynamic-i686.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/tls-dynamic-i686.s (original)
+++ lld/trunk/test/ELF/tls-dynamic-i686.s Mon Mar 25 16:46:19 2019
@@ -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
Modified: lld/trunk/test/ELF/tls-opt-gdiele-i686.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/tls-opt-gdiele-i686.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/tls-opt-gdiele-i686.s (original)
+++ lld/trunk/test/ELF/tls-opt-gdiele-i686.s Mon Mar 25 16:46:19 2019
@@ -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 at tlsgd(,%ebx,1),%eax
call ___tls_get_addr at plt
leal tlsshared1 at tlsgd(,%ebx,1),%eax
call ___tls_get_addr at plt
-//GD->IE
+//GD->LE
leal tlsexe1 at tlsgd(,%ebx,1),%eax
call ___tls_get_addr at plt
leal tlsexe2 at tlsgd(,%ebx,1),%eax
Modified: lld/trunk/test/ELF/x86-64-reloc-gotoff64.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-gotoff64.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-gotoff64.s (original)
+++ lld/trunk/test/ELF/x86-64-reloc-gotoff64.s Mon Mar 25 16:46:19 2019
@@ -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
Modified: lld/trunk/test/ELF/x86-64-reloc-gotpc64.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-gotpc64.s?rev=356968&r1=356967&r2=356968&view=diff
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-gotpc64.s (original)
+++ lld/trunk/test/ELF/x86-64-reloc-gotpc64.s Mon Mar 25 16:46:19 2019
@@ -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
More information about the llvm-commits
mailing list