<p dir="ltr"><br>
On Nov 25, 2015 2:17 PM, "George Rimar via llvm-commits" <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: grimar<br>
> Date: Wed Nov 25 16:15:01 2015<br>
> New Revision: 254105<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=254105&view=rev">http://llvm.org/viewvc/llvm-project?rev=254105&view=rev</a><br>
> Log:<br>
> Reapply r254098.</p>
<p dir="ltr">It's helpful to include the original commit message when recommitting a patch so it stands alone/is informative.</p>
<p dir="ltr">><br>
> Fix is (OutputSections.cpp):<br>
> for (std::pair<const SymbolBody *, size_t> &I : Entries) {<br>
> =><br>
> for (std::pair<const SymbolBody *, unsigned> &I : Entries) {</p>
<p dir="ltr">It might be best to use 'auto' to avoid this bug</p>
<p dir="ltr">><br>
> Modified:<br>
> lld/trunk/ELF/OutputSections.cpp<br>
> lld/trunk/ELF/OutputSections.h<br>
> lld/trunk/ELF/Target.cpp<br>
> lld/trunk/ELF/Target.h<br>
> lld/trunk/test/ELF/plt-i686.s<br>
> lld/trunk/test/ELF/relocation-i686.s<br>
><br>
> Modified: lld/trunk/ELF/OutputSections.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=254105&r1=254104&r2=254105&view=diff">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=254105&r1=254104&r2=254105&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/ELF/OutputSections.cpp (original)<br>
> +++ lld/trunk/ELF/OutputSections.cpp Wed Nov 25 16:15:01 2015<br>
> @@ -150,18 +150,25 @@ template <class ELFT> void PltSection<EL<br>
> Target->writePltZeroEntry(Buf, Out<ELFT>::GotPlt->getVA(), this->getVA());<br>
> Off += Target->getPltZeroEntrySize();<br>
> }<br>
> - for (const SymbolBody *E : Entries) {<br>
> - uint64_t Got = LazyReloc ? Out<ELFT>::GotPlt->getEntryAddr(*E)<br>
> - : Out<ELFT>::Got->getEntryAddr(*E);<br>
> + for (std::pair<const SymbolBody *, unsigned> &I : Entries) {<br>
> + const SymbolBody *E = I.first;<br>
> + unsigned RelOff = I.second;<br>
> + uint64_t GotVA =<br>
> + LazyReloc ? Out<ELFT>::GotPlt->getVA() : Out<ELFT>::Got->getVA();<br>
> + uint64_t GotE = LazyReloc ? Out<ELFT>::GotPlt->getEntryAddr(*E)<br>
> + : Out<ELFT>::Got->getEntryAddr(*E);<br>
> uint64_t Plt = this->getVA() + Off;<br>
> - Target->writePltEntry(Buf + Off, Got, Plt, E->PltIndex);<br>
> + Target->writePltEntry(Buf + Off, GotVA, GotE, Plt, E->PltIndex, RelOff);<br>
> Off += Target->getPltEntrySize();<br>
> }<br>
> }<br>
><br>
> template <class ELFT> void PltSection<ELFT>::addEntry(SymbolBody *Sym) {<br>
> Sym->PltIndex = Entries.size();<br>
> - Entries.push_back(Sym);<br>
> + unsigned RelOff = Target->supportsLazyRelocations()<br>
> + ? Out<ELFT>::RelaPlt->getRelocOffset()<br>
> + : Out<ELFT>::RelaDyn->getRelocOffset();<br>
> + Entries.push_back(std::make_pair(Sym, RelOff));<br>
> }<br>
><br>
> template <class ELFT><br>
> @@ -281,6 +288,11 @@ template <class ELFT> void RelocationSec<br>
> }<br>
> }<br>
><br>
> +template <class ELFT> unsigned RelocationSection<ELFT>::getRelocOffset() {<br>
> + const unsigned EntrySize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);<br>
> + return EntrySize * Relocs.size();<br>
> +}<br>
> +<br>
> template <class ELFT> void RelocationSection<ELFT>::finalize() {<br>
> this->Header.sh_link = Out<ELFT>::DynSymTab->SectionIndex;<br>
> this->Header.sh_size = Relocs.size() * this->Header.sh_entsize;<br>
><br>
> Modified: lld/trunk/ELF/OutputSections.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=254105&r1=254104&r2=254105&view=diff">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=254105&r1=254104&r2=254105&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/ELF/OutputSections.h (original)<br>
> +++ lld/trunk/ELF/OutputSections.h Wed Nov 25 16:15:01 2015<br>
> @@ -166,7 +166,7 @@ public:<br>
> uintX_t getEntryAddr(const SymbolBody &B) const;<br>
><br>
> private:<br>
> - std::vector<const SymbolBody *> Entries;<br>
> + std::vector<std::pair<const SymbolBody *, unsigned>> Entries;<br>
> };<br>
><br>
> template <class ELFT> struct DynamicReloc {<br>
> @@ -216,6 +216,7 @@ class RelocationSection final : public O<br>
> public:<br>
> RelocationSection(StringRef Name, bool IsRela);<br>
> void addReloc(const DynamicReloc<ELFT> &Reloc) { Relocs.push_back(Reloc); }<br>
> + unsigned getRelocOffset();<br>
> void finalize() override;<br>
> void writeTo(uint8_t *Buf) override;<br>
> bool hasRelocs() const { return !Relocs.empty(); }<br>
><br>
> Modified: lld/trunk/ELF/Target.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=254105&r1=254104&r2=254105&view=diff">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=254105&r1=254104&r2=254105&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/ELF/Target.cpp (original)<br>
> +++ lld/trunk/ELF/Target.cpp Wed Nov 25 16:15:01 2015<br>
> @@ -46,13 +46,15 @@ namespace {<br>
> class X86TargetInfo final : public TargetInfo {<br>
> public:<br>
> X86TargetInfo();<br>
> + void writeGotPltHeaderEntries(uint8_t *Buf) const override;<br>
> unsigned getDynReloc(unsigned Type) const override;<br>
> bool isTlsDynReloc(unsigned Type) const override;<br>
> void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const override;<br>
> void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> uint64_t PltEntryAddr) const override;<br>
> - void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr, int32_t Index) const override;<br>
> + void writePltEntry(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr,<br>
> + uint64_t PltEntryAddr, int32_t Index,<br>
> + unsigned RelOff) const override;<br>
> bool relocNeedsCopy(uint32_t Type, const SymbolBody &S) const override;<br>
> bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;<br>
> bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;<br>
> @@ -69,8 +71,9 @@ public:<br>
> void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const override;<br>
> void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> uint64_t PltEntryAddr) const override;<br>
> - void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr, int32_t Index) const override;<br>
> + void writePltEntry(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr,<br>
> + uint64_t PltEntryAddr, int32_t Index,<br>
> + unsigned RelOff) const override;<br>
> bool relocNeedsCopy(uint32_t Type, const SymbolBody &S) const override;<br>
> bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;<br>
> bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;<br>
> @@ -96,8 +99,9 @@ public:<br>
> void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const override;<br>
> void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> uint64_t PltEntryAddr) const override;<br>
> - void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr, int32_t Index) const override;<br>
> + void writePltEntry(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr,<br>
> + uint64_t PltEntryAddr, int32_t Index,<br>
> + unsigned RelOff) const override;<br>
> bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;<br>
> bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;<br>
> void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P,<br>
> @@ -113,8 +117,9 @@ public:<br>
> void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const override;<br>
> void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> uint64_t PltEntryAddr) const override;<br>
> - void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr, int32_t Index) const override;<br>
> + void writePltEntry(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr,<br>
> + uint64_t PltEntryAddr, int32_t Index,<br>
> + unsigned RelOff) const override;<br>
> bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;<br>
> bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;<br>
> void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P,<br>
> @@ -129,8 +134,9 @@ public:<br>
> void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const override;<br>
> void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> uint64_t PltEntryAddr) const override;<br>
> - void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr, int32_t Index) const override;<br>
> + void writePltEntry(uint8_t *Buf, uint64_t GotAddr, uint64_t GotEntryAddr,<br>
> + uint64_t PltEntryAddr, int32_t Index,<br>
> + unsigned RelOff) const override;<br>
> bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const override;<br>
> bool relocNeedsPlt(uint32_t Type, const SymbolBody &S) const override;<br>
> void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P,<br>
> @@ -195,6 +201,18 @@ X86TargetInfo::X86TargetInfo() {<br>
> GotReloc = R_386_GLOB_DAT;<br>
> GotRefReloc = R_386_GOT32;<br>
> PltReloc = R_386_JUMP_SLOT;<br>
> + LazyRelocations = true;<br>
> + PltEntrySize = 16;<br>
> + PltZeroEntrySize = 16;<br>
> +}<br>
> +<br>
> +void X86TargetInfo::writeGotPltHeaderEntries(uint8_t *Buf) const {<br>
> + write32le(Buf, Out<ELF32LE>::Dynamic->getVA());<br>
> +}<br>
> +<br>
> +void X86TargetInfo::writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const {<br>
> + // Skip 6 bytes of "pushl (GOT+4)"<br>
> + write32le(Buf, Plt + 6);<br>
> }<br>
><br>
> unsigned X86TargetInfo::getDynReloc(unsigned Type) const {<br>
> @@ -211,17 +229,44 @@ bool X86TargetInfo::isTlsDynReloc(unsign<br>
> return false;<br>
> }<br>
><br>
> -void X86TargetInfo::writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const {}<br>
> void X86TargetInfo::writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr) const {}<br>
> + uint64_t PltEntryAddr) const {<br>
> + // Executable files and shared object files have<br>
> + // separate procedure linkage tables.<br>
> + if (Config->Shared) {<br>
> + const uint8_t V[] = {<br>
> + 0xff, 0xb3, 0x04, 0x00, 0x00, 0x00, // pushl 4(%ebx<br>
> + 0xff, 0xa3, 0x08, 0x00, 0x00, 0x00, // jmp *8(%ebx)<br>
> + 0x90, 0x90, 0x90, 0x90 // nop;nop;nop;nop<br>
> + };<br>
> + memcpy(Buf, V, sizeof(V));<br>
> + return;<br>
> + }<br>
><br>
> -void X86TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr, int32_t Index) const {<br>
> - // jmpl *val; nop; nop<br>
> - const uint8_t Inst[] = {0xff, 0x25, 0, 0, 0, 0, 0x90, 0x90};<br>
> + const uint8_t PltData[] = {<br>
> + 0xff, 0x35, 0x00, 0x00, 0x00, 0x00, // pushl (GOT+4)<br>
> + 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, // jmp *(GOT+8)<br>
> + 0x90, 0x90, 0x90, 0x90 // nop;nop;nop;nop<br>
> + };<br>
> + memcpy(Buf, PltData, sizeof(PltData));<br>
> + write32le(Buf + 2, GotEntryAddr + 4); // GOT+4<br>
> + write32le(Buf + 8, GotEntryAddr + 8); // GOT+8<br>
> +}<br>
> +<br>
> +void X86TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotAddr,<br>
> + uint64_t GotEntryAddr, uint64_t PltEntryAddr,<br>
> + int32_t Index, unsigned RelOff) const {<br>
> + const uint8_t Inst[] = {<br>
> + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, // jmp *foo_in_GOT|*foo@GOT(%ebx)<br>
> + 0x68, 0x00, 0x00, 0x00, 0x00, // pushl $reloc_offset<br>
> + 0xe9, 0x00, 0x00, 0x00, 0x00 // jmp .PLT0@PC<br>
> + };<br>
> memcpy(Buf, Inst, sizeof(Inst));<br>
> - assert(isUInt<32>(GotEntryAddr));<br>
> - write32le(Buf + 2, GotEntryAddr);<br>
> + // jmp *foo@GOT(%ebx) or jmp *foo_in_GOT<br>
> + Buf[1] = Config->Shared ? 0xa3 : 0x25;<br>
> + write32le(Buf + 2, Config->Shared ? (GotEntryAddr - GotAddr) : GotEntryAddr);<br>
> + write32le(Buf + 7, RelOff);<br>
> + write32le(Buf + 12, -Index * PltEntrySize - PltZeroEntrySize - 16);<br>
> }<br>
><br>
> bool X86TargetInfo::relocNeedsCopy(uint32_t Type, const SymbolBody &S) const {<br>
> @@ -303,9 +348,10 @@ void X86_64TargetInfo::writePltZeroEntry<br>
> write32le(Buf + 8, GotEntryAddr - PltEntryAddr + 4); // GOT+16<br>
> }<br>
><br>
> -void X86_64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr,<br>
> - int32_t Index) const {<br>
> +void X86_64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotAddr,<br>
> + uint64_t GotEntryAddr,<br>
> + uint64_t PltEntryAddr, int32_t Index,<br>
> + unsigned RelOff) const {<br>
> const uint8_t Inst[] = {<br>
> 0xff, 0x25, 0x00, 0x00, 0x00, 0x00, // jmpq *got(%rip)<br>
> 0x68, 0x00, 0x00, 0x00, 0x00, // pushq <relocation index><br>
> @@ -604,8 +650,10 @@ uint64_t getPPC64TocBase() {<br>
> void PPC64TargetInfo::writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const {}<br>
> void PPC64TargetInfo::writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> uint64_t PltEntryAddr) const {}<br>
> -void PPC64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr, int32_t Index) const {<br>
> +void PPC64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotAddr,<br>
> + uint64_t GotEntryAddr,<br>
> + uint64_t PltEntryAddr, int32_t Index,<br>
> + unsigned RelOff) const {<br>
> uint64_t Off = GotEntryAddr - getPPC64TocBase();<br>
><br>
> // FIXME: What we should do, in theory, is get the offset of the function<br>
> @@ -816,9 +864,10 @@ void AArch64TargetInfo::writePltZeroEntr<br>
> GotEntryAddr + 16);<br>
> }<br>
><br>
> -void AArch64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr,<br>
> - int32_t Index) const {<br>
> +void AArch64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotAddr,<br>
> + uint64_t GotEntryAddr,<br>
> + uint64_t PltEntryAddr, int32_t Index,<br>
> + unsigned RelOff) const {<br>
> const uint8_t Inst[] = {<br>
> 0x10, 0x00, 0x00, 0x90, // adrp x16, Page(&(.plt.got[n]))<br>
> 0x11, 0x02, 0x40, 0xf9, // ldr x17, [x16, Offset(&(.plt.got[n]))]<br>
> @@ -977,8 +1026,10 @@ template <class ELFT><br>
> void MipsTargetInfo<ELFT>::writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> uint64_t PltEntryAddr) const {}<br>
> template <class ELFT><br>
> -void MipsTargetInfo<ELFT>::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr, int32_t Index) const {}<br>
> +void MipsTargetInfo<ELFT>::writePltEntry(uint8_t *Buf, uint64_t GotAddr,<br>
> + uint64_t GotEntryAddr,<br>
> + uint64_t PltEntryAddr, int32_t Index,<br>
> + unsigned RelOff) const {}<br>
><br>
> template <class ELFT><br>
> bool MipsTargetInfo<ELFT>::relocNeedsGot(uint32_t Type,<br>
><br>
> Modified: lld/trunk/ELF/Target.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=254105&r1=254104&r2=254105&view=diff">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=254105&r1=254104&r2=254105&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/ELF/Target.h (original)<br>
> +++ lld/trunk/ELF/Target.h Wed Nov 25 16:15:01 2015<br>
> @@ -50,8 +50,9 @@ public:<br>
> virtual void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const = 0;<br>
> virtual void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> uint64_t PltEntryAddr) const = 0;<br>
> - virtual void writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,<br>
> - uint64_t PltEntryAddr, int32_t Index) const = 0;<br>
> + virtual void writePltEntry(uint8_t *Buf, uint64_t GotAddr,<br>
> + uint64_t GotEntryAddr, uint64_t PltEntryAddr,<br>
> + int32_t Index, unsigned RelOff) const = 0;<br>
> virtual bool isRelRelative(uint32_t Type) const;<br>
> virtual bool relocNeedsCopy(uint32_t Type, const SymbolBody &S) const;<br>
> virtual bool relocNeedsGot(uint32_t Type, const SymbolBody &S) const = 0;<br>
><br>
> Modified: lld/trunk/test/ELF/plt-i686.s<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/plt-i686.s?rev=254105&r1=254104&r2=254105&view=diff">http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/plt-i686.s?rev=254105&r1=254104&r2=254105&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/test/ELF/plt-i686.s (original)<br>
> +++ lld/trunk/test/ELF/plt-i686.s Wed Nov 25 16:15:01 2015<br>
> @@ -2,8 +2,12 @@<br>
> // RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared.s -o %t2.o<br>
> // RUN: ld.lld -shared %t2.o -o %t2.so<br>
> // RUN: ld.lld %t.o %t2.so -o %t<br>
> -// RUN: llvm-readobj -s -r %t | FileCheck %s<br>
> +// RUN: llvm-readobj -s -r %t | FileCheck --check-prefix=CHECK %s<br>
> // RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s<br>
> +// RUN: ld.lld -shared %t.o %t2.so -o %t<br>
> +// RUN: llvm-readobj -s -r %t | FileCheck --check-prefix=CHECKSHARED %s<br>
> +// RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASMSHARED %s<br>
> +<br>
> // REQUIRES: x86<br>
><br>
> // CHECK: Name: .plt<br>
> @@ -14,41 +18,124 @@<br>
> // CHECK-NEXT: ]<br>
> // CHECK-NEXT: Address: 0x11010<br>
> // CHECK-NEXT: Offset:<br>
> -// CHECK-NEXT: Size: 16<br>
> +// CHECK-NEXT: Size: 48<br>
> // CHECK-NEXT: Link: 0<br>
> // CHECK-NEXT: Info: 0<br>
> // CHECK-NEXT: AddressAlignment: 16<br>
><br>
> +// CHECK: Name: .got.plt<br>
> +// CHECK-NEXT: Type: SHT_PROGBITS<br>
> +// CHECK-NEXT: Flags [<br>
> +// CHECK-NEXT: SHF_ALLOC<br>
> +// CHECK-NEXT: SHF_WRITE<br>
> +// CHECK-NEXT: ]<br>
> +// CHECK-NEXT: Address: 0x12058<br>
> +// CHECK-NEXT: Offset: 0x2058<br>
> +// CHECK-NEXT: Size: 20<br>
> +// CHECK-NEXT: Link: 0<br>
> +// CHECK-NEXT: Info: 0<br>
> +// CHECK-NEXT: AddressAlignment: 4<br>
> +// CHECK-NEXT: EntrySize: 0<br>
> +<br>
> +// 0x12058 + got.plt.reserved(12) = 0x12064<br>
> +// 0x12058 + got.plt.reserved(12) + 4 = 0x12068<br>
> // CHECK: Relocations [<br>
> -// CHECK-NEXT: Section ({{.*}}) .rel.dyn {<br>
> -// CHECK-NEXT: 0x12050 R_386_GLOB_DAT bar 0x0<br>
> -// CHECK-NEXT: 0x12054 R_386_GLOB_DAT zed 0x0<br>
> +// CHECK-NEXT: Section ({{.*}}) .rel.plt {<br>
> +// CHECK-NEXT: 0x12064 R_386_JUMP_SLOT bar 0x0<br>
> +// CHECK-NEXT: 0x12068 R_386_JUMP_SLOT zed 0x0<br>
> // CHECK-NEXT: }<br>
> // CHECK-NEXT: ]<br>
><br>
> // Unfortunately FileCheck can't do math, so we have to check for explicit<br>
> // values:<br>
><br>
> -// 0x11010 - (0x11000 + 1) - 4 = 11<br>
> -// 0x11010 - (0x11005 + 1) - 4 = 2<br>
> -// 0x11018 - (0x1100a + 1) - 4 = 9<br>
> +// 16 is the size of PLT[0]<br>
> +// (0x11010 + 16) - (0x11000 + 1) - 4 = 27<br>
> +// (0x11010 + 16) - (0x11005 + 1) - 4 = 22<br>
> +// (0x11020 + 16) - (0x1100a + 1) - 4 = 33<br>
><br>
> // DISASM: _start:<br>
> -// DISASM-NEXT: 11000: e9 0b 00 00 00 jmp 11<br>
> -// DISASM-NEXT: 11005: e9 06 00 00 00 jmp 6<br>
> -// DISASM-NEXT: 1100a: e9 09 00 00 00 jmp 9<br>
> -<br>
> -// 0x12050 = 73808<br>
> -// 0x12054 = 73812<br>
> -<br>
> +// DISASM-NEXT: 11000: e9 1b 00 00 00 jmp 27<br>
> +// DISASM-NEXT: 11005: e9 16 00 00 00 jmp 22<br>
> +// DISASM-NEXT: 1100a: e9 21 00 00 00 jmp 33<br>
> +<br>
> +// 0x11010 - 0x1102b - 5 = -32<br>
> +// 0x11010 - 0x1103b - 5 = -48<br>
> +// 73820 = 0x1205C = .got.plt (0x12058) + 4<br>
> +// 73824 = 0x12060 = .got.plt (0x12058) + 8<br>
> +// 73828 = 0x12064 = .got.plt (0x12058) + got.plt.reserved(12)<br>
> +// 73832 = 0x12068 = .got.plt (0x12058) + got.plt.reserved(12) + 4<br>
> // DISASM: Disassembly of section .plt:<br>
> // DISASM-NEXT: .plt:<br>
> -// DISASM-NEXT: 11010: ff 25 {{.*}} jmpl *73808<br>
> -// DISASM-NEXT: 11016: 90 nop<br>
> -// DISASM-NEXT: 11017: 90 nop<br>
> -// DISASM-NEXT: 11018: ff 25 {{.*}} jmpl *73812<br>
> -// DISASM-NEXT: 1101e: 90 nop<br>
> -// DISASM-NEXT: 1101f: 90 nop<br>
> +// DISASM-NEXT: 11010: ff 35 5c 20 01 00 pushl 73820<br>
> +// DISASM-NEXT: 11016: ff 25 60 20 01 00 jmpl *73824<br>
> +// DISASM-NEXT: 1101c: 90 nop<br>
> +// DISASM-NEXT: 1101d: 90 nop<br>
> +// DISASM-NEXT: 1101e: 90 nop<br>
> +// DISASM-NEXT: 1101f: 90 nop<br>
> +// DISASM-NEXT: 11020: ff 25 64 20 01 00 jmpl *73828<br>
> +// DISASM-NEXT: 11026: 68 00 00 00 00 pushl $0<br>
> +// DISASM-NEXT: 1102b: e9 e0 ff ff ff jmp -32 <.plt><br>
> +// DISASM-NEXT: 11030: ff 25 68 20 01 00 jmpl *73832<br>
> +// DISASM-NEXT: 11036: 68 08 00 00 00 pushl $8<br>
> +// DISASM-NEXT: 1103b: e9 d0 ff ff ff jmp -48 <.plt><br>
> +<br>
> +// CHECKSHARED: Name: .plt<br>
> +// CHECKSHARED-NEXT: Type: SHT_PROGBITS<br>
> +// CHECKSHARED-NEXT: Flags [<br>
> +// CHECKSHARED-NEXT: SHF_ALLOC<br>
> +// CHECKSHARED-NEXT: SHF_EXECINSTR<br>
> +// CHECKSHARED-NEXT: ]<br>
> +// CHECKSHARED-NEXT: Address: 0x1010<br>
> +// CHECKSHARED-NEXT: Offset: 0x1010<br>
> +// CHECKSHARED-NEXT: Size: 48<br>
> +// CHECKSHARED-NEXT: Link: 0<br>
> +// CHECKSHARED-NEXT: Info: 0<br>
> +// CHECKSHARED-NEXT: AddressAlignment: 16<br>
> +// CHECKSHARED-NEXT: EntrySize: 0<br>
> +// CHECKSHARED-NEXT: }<br>
> +// CHECKSHARED: Name: .got.plt<br>
> +// CHECKSHARED-NEXT: Type: SHT_PROGBITS<br>
> +// CHECKSHARED-NEXT: Flags [<br>
> +// CHECKSHARED-NEXT: SHF_ALLOC<br>
> +// CHECKSHARED-NEXT: SHF_WRITE<br>
> +// CHECKSHARED-NEXT: ]<br>
> +// CHECKSHARED-NEXT: Address: 0x2058<br>
> +// CHECKSHARED-NEXT: Offset: 0x2058<br>
> +// CHECKSHARED-NEXT: Size: 20<br>
> +// CHECKSHARED-NEXT: Link: 0<br>
> +// CHECKSHARED-NEXT: Info: 0<br>
> +// CHECKSHARED-NEXT: AddressAlignment: 4<br>
> +// CHECKSHARED-NEXT: EntrySize: 0<br>
> +// CHECKSHARED-NEXT: }<br>
> +<br>
> +// 0x2058 + got.plt.reserved(12) = 0x2064<br>
> +// 0x2058 + got.plt.reserved(12) + 4 = 0x2068<br>
> +// CHECKSHARED: Relocations [<br>
> +// CHECKSHARED-NEXT: Section ({{.*}}) .rel.plt {<br>
> +// CHECKSHARED-NEXT: 0x2064 R_386_JUMP_SLOT bar 0x0<br>
> +// CHECKSHARED-NEXT: 0x2068 R_386_JUMP_SLOT zed 0x0<br>
> +// CHECKSHARED-NEXT: }<br>
> +// CHECKSHARED-NEXT: ]<br>
> +<br>
> +// DISASMSHARED: _start:<br>
> +// DISASMSHARED-NEXT: 1000: e9 1b 00 00 00 jmp 27<br>
> +// DISASMSHARED-NEXT: 1005: e9 16 00 00 00 jmp 22<br>
> +// DISASMSHARED-NEXT: 100a: e9 21 00 00 00 jmp 33<br>
> +// DISASMSHARED-NEXT: Disassembly of section .plt:<br>
> +// DISASMSHARED-NEXT: .plt:<br>
> +// DISASMSHARED-NEXT: 1010: ff b3 04 00 00 00 pushl 4(%ebx)<br>
> +// DISASMSHARED-NEXT: 1016: ff a3 08 00 00 00 jmpl *8(%ebx)<br>
> +// DISASMSHARED-NEXT: 101c: 90 nop<br>
> +// DISASMSHARED-NEXT: 101d: 90 nop<br>
> +// DISASMSHARED-NEXT: 101e: 90 nop<br>
> +// DISASMSHARED-NEXT: 101f: 90 nop<br>
> +// DISASMSHARED-NEXT: 1020: ff a3 0c 00 00 00 jmpl *12(%ebx)<br>
> +// DISASMSHARED-NEXT: 1026: 68 00 00 00 00 pushl $0<br>
> +// DISASMSHARED-NEXT: 102b: e9 e0 ff ff ff jmp -32 <.plt><br>
> +// DISASMSHARED-NEXT: 1030: ff a3 10 00 00 00 jmpl *16(%ebx)<br>
> +// DISASMSHARED: 1036: 68 08 00 00 00 pushl $8<br>
> +// DISASMSHARED: 103b: e9 d0 ff ff ff jmp -48 <.plt><br>
><br>
> .global _start<br>
> _start:<br>
><br>
> Modified: lld/trunk/test/ELF/relocation-i686.s<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-i686.s?rev=254105&r1=254104&r2=254105&view=diff">http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/relocation-i686.s?rev=254105&r1=254104&r2=254105&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/test/ELF/relocation-i686.s (original)<br>
> +++ lld/trunk/test/ELF/relocation-i686.s Wed Nov 25 16:15:01 2015<br>
> @@ -47,7 +47,7 @@ movl bar@GOT, %eax<br>
> // ADDR-NEXT: ]<br>
> // ADDR-NEXT: Address: 0x11030<br>
> // ADDR-NEXT: Offset: 0x1030<br>
> -// ADDR-NEXT: Size: 8<br>
> +// ADDR-NEXT: Size: 32<br>
><br>
> // ADDR: Name: .got<br>
> // ADDR-NEXT: Type: SHT_PROGBITS<br>
> @@ -55,7 +55,7 @@ movl bar@GOT, %eax<br>
> // ADDR-NEXT: SHF_ALLOC<br>
> // ADDR-NEXT: SHF_WRITE<br>
> // ADDR-NEXT: ]<br>
> -// ADDR-NEXT: Address: 0x12050<br>
> +// ADDR-NEXT: Address: 0x12070<br>
><br>
> .section .R_386_GOTPC,"ax",@progbits<br>
> R_386_GOTPC:<br>
> @@ -65,14 +65,14 @@ R_386_GOTPC:<br>
><br>
> // CHECK: Disassembly of section .R_386_GOTPC:<br>
> // CHECK-NEXT: R_386_GOTPC:<br>
> -// CHECK-NEXT: 11014: {{.*}} movl $4156, %eax<br>
> +// CHECK-NEXT: 11014: {{.*}} movl $4188, %eax<br>
><br>
> .section .dynamic_reloc, "ax",@progbits<br>
> call bar<br>
> // 0x11030 - (0x11019 + 5) = 18<br>
> // CHECK: Disassembly of section .dynamic_reloc:<br>
> // CHECK-NEXT: .dynamic_reloc:<br>
> -// CHECK-NEXT: 11019: e8 12 00 00 00 calll 18<br>
> +// CHECK-NEXT: 11019: e8 22 00 00 00 calll 34<br>
><br>
> .section .R_386_GOT32,"ax",@progbits<br>
> .global R_386_GOT32<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</p>