diff options
Diffstat (limited to 'lld/ELF/Arch/X86.cpp')
| -rw-r--r-- | lld/ELF/Arch/X86.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/lld/ELF/Arch/X86.cpp b/lld/ELF/Arch/X86.cpp index 8d54e7e6b3f..1e8a10cfce7 100644 --- a/lld/ELF/Arch/X86.cpp +++ b/lld/ELF/Arch/X86.cpp @@ -33,8 +33,8 @@ public: void writeGotPlt(uint8_t *buf, const Symbol &s) const override; void writeIgotPlt(uint8_t *buf, const Symbol &s) const override; void writePltHeader(uint8_t *buf) const override; - void writePlt(uint8_t *buf, uint64_t gotPltEntryAddr, uint64_t pltEntryAddr, - int32_t index) const override; + void writePlt(uint8_t *buf, const Symbol &sym, + uint64_t pltEntryAddr) const override; void relocateOne(uint8_t *loc, RelType type, uint64_t val) const override; RelExpr adjustRelaxExpr(RelType type, const uint8_t *data, @@ -214,9 +214,9 @@ void X86::writePltHeader(uint8_t *buf) const { write32le(buf + 8, gotPlt + 8); } -void X86::writePlt(uint8_t *buf, uint64_t gotPltEntryAddr, - uint64_t pltEntryAddr, int32_t index) const { - unsigned relOff = in.relaPlt->entsize * index; +void X86::writePlt(uint8_t *buf, const Symbol &sym, + uint64_t pltEntryAddr) const { + unsigned relOff = in.relaPlt->entsize * sym.pltIndex; if (config->isPic) { const uint8_t inst[] = { 0xff, 0xa3, 0, 0, 0, 0, // jmp *foo@GOT(%ebx) @@ -224,7 +224,7 @@ void X86::writePlt(uint8_t *buf, uint64_t gotPltEntryAddr, 0xe9, 0, 0, 0, 0, // jmp .PLT0@PC }; memcpy(buf, inst, sizeof(inst)); - write32le(buf + 2, gotPltEntryAddr - in.gotPlt->getVA()); + write32le(buf + 2, sym.getGotPltVA() - in.gotPlt->getVA()); } else { const uint8_t inst[] = { 0xff, 0x25, 0, 0, 0, 0, // jmp *foo@GOT @@ -232,7 +232,7 @@ void X86::writePlt(uint8_t *buf, uint64_t gotPltEntryAddr, 0xe9, 0, 0, 0, 0, // jmp .PLT0@PC }; memcpy(buf, inst, sizeof(inst)); - write32le(buf + 2, gotPltEntryAddr); + write32le(buf + 2, sym.getGotPltVA()); } write32le(buf + 7, relOff); @@ -416,8 +416,8 @@ public: RetpolinePic(); void writeGotPlt(uint8_t *buf, const Symbol &s) const override; void writePltHeader(uint8_t *buf) const override; - void writePlt(uint8_t *buf, uint64_t gotPltEntryAddr, uint64_t pltEntryAddr, - int32_t index) const override; + void writePlt(uint8_t *buf, const Symbol &sym, + uint64_t pltEntryAddr) const override; }; class RetpolineNoPic : public X86 { @@ -425,8 +425,8 @@ public: RetpolineNoPic(); void writeGotPlt(uint8_t *buf, const Symbol &s) const override; void writePltHeader(uint8_t *buf) const override; - void writePlt(uint8_t *buf, uint64_t gotPltEntryAddr, uint64_t pltEntryAddr, - int32_t index) const override; + void writePlt(uint8_t *buf, const Symbol &sym, + uint64_t pltEntryAddr) const override; }; } // namespace @@ -461,9 +461,9 @@ void RetpolinePic::writePltHeader(uint8_t *buf) const { memcpy(buf, insn, sizeof(insn)); } -void RetpolinePic::writePlt(uint8_t *buf, uint64_t gotPltEntryAddr, - uint64_t pltEntryAddr, int32_t index) const { - unsigned relOff = in.relaPlt->entsize * index; +void RetpolinePic::writePlt(uint8_t *buf, const Symbol &sym, + uint64_t pltEntryAddr) const { + unsigned relOff = in.relaPlt->entsize * sym.pltIndex; const uint8_t insn[] = { 0x50, // pushl %eax 0x8b, 0x83, 0, 0, 0, 0, // mov foo@GOT(%ebx), %eax @@ -477,7 +477,7 @@ void RetpolinePic::writePlt(uint8_t *buf, uint64_t gotPltEntryAddr, uint32_t ebx = in.gotPlt->getVA(); unsigned off = pltEntryAddr - in.plt->getVA(); - write32le(buf + 3, gotPltEntryAddr - ebx); + write32le(buf + 3, sym.getGotPltVA() - ebx); write32le(buf + 8, -off - 12 + 32); write32le(buf + 13, -off - 17 + 18); write32le(buf + 18, relOff); @@ -520,9 +520,9 @@ void RetpolineNoPic::writePltHeader(uint8_t *buf) const { write32le(buf + 8, gotPlt + 8); } -void RetpolineNoPic::writePlt(uint8_t *buf, uint64_t gotPltEntryAddr, - uint64_t pltEntryAddr, int32_t index) const { - unsigned relOff = in.relaPlt->entsize * index; +void RetpolineNoPic::writePlt(uint8_t *buf, const Symbol &sym, + uint64_t pltEntryAddr) const { + unsigned relOff = in.relaPlt->entsize * sym.pltIndex; const uint8_t insn[] = { 0x50, // 0: pushl %eax 0xa1, 0, 0, 0, 0, // 1: mov foo_in_GOT, %eax @@ -536,7 +536,7 @@ void RetpolineNoPic::writePlt(uint8_t *buf, uint64_t gotPltEntryAddr, memcpy(buf, insn, sizeof(insn)); unsigned off = pltEntryAddr - in.plt->getVA(); - write32le(buf + 2, gotPltEntryAddr); + write32le(buf + 2, sym.getGotPltVA()); write32le(buf + 7, -off - 11 + 32); write32le(buf + 12, -off - 16 + 17); write32le(buf + 17, relOff); |

