diff options
author | Zaara Syeda <syzaara@ca.ibm.com> | 2018-04-23 15:01:24 +0000 |
---|---|---|
committer | Zaara Syeda <syzaara@ca.ibm.com> | 2018-04-23 15:01:24 +0000 |
commit | 4b0e88f29b3d9c20270bb4fb5c553e85313c369b (patch) | |
tree | 046b18b3d139166279956d820b6d1d90804ca315 /lld/ELF/InputSection.cpp | |
parent | 2f0ca092d38e8a55ceb091cefe489276bb2aca92 (diff) |
[PPC64] Fix toc restore nops offset for V2 ABI
The PPC64 V2 ABI restores the toc base by loading from an offset of 24 from r1.
This patch fixes the offset and updates the testcases from V1 to V2. It also
issues an error when a nop is missing after a call to an external function.
Differential Revision: https://reviews.llvm.org/D45892
Diffstat (limited to 'lld/ELF/InputSection.cpp')
-rw-r--r-- | lld/ELF/InputSection.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 4604253bc00..dfe8f5003bd 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -740,8 +740,12 @@ void InputSectionBase::relocateAlloc(uint8_t *Buf, uint8_t *BufEnd) { break; case R_PPC_PLT_OPD: // Patch a nop (0x60000000) to a ld. - if (BufLoc + 8 <= BufEnd && read32be(BufLoc + 4) == 0x60000000) - write32be(BufLoc + 4, 0xe8410028); // ld %r2, 40(%r1) + if (BufLoc + 8 <= BufEnd && read32(BufLoc + 4) == 0x60000000) { + write32(BufLoc + 4, 0xe8410018); // ld %r2, 24(%r1) + } else { + error(getErrorLocation(BufLoc) + "error: call lacks nop, can't restore toc."); + return; + } LLVM_FALLTHROUGH; default: Target->relocateOne(BufLoc, Type, TargetVA); |