[ELF2/PPC64] Fix the TOC save in the .plt stub

The comment was right, but the encoding was wrong (and, it seems, I forgot a
test case for the .plt stub).

llvm-svn: 250230
This commit is contained in:
Hal Finkel 2015-10-13 21:47:34 +00:00
parent 355cc52292
commit fa92f686bc
2 changed files with 9 additions and 2 deletions

View File

@ -271,7 +271,7 @@ void PPC64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
// be a pointer to the function descriptor in the .opd section. Using
// this scheme is simpler, but requires an extra indirection per PLT dispatch.
write32be(Buf, 0xf8410000); // std %r2, 40(%r1)
write32be(Buf, 0xf8410028); // std %r2, 40(%r1)
write32be(Buf + 4, 0x3d620000 | applyPPCHa(Off)); // addis %r11, %r2, X@ha
write32be(Buf + 8, 0xe98b0000 | applyPPCLo(Off)); // ld %r12, X@l(%r11)
write32be(Buf + 12, 0xe96c0000); // ld %r11,0(%r12)

View File

@ -52,4 +52,11 @@ last:
// CHECK: Disassembly of section .plt:
// CHECK: .plt:
// CHECK: 20020:
// CHECK: 20020: f8 41 00 28 std 2, 40(1)
// CHECK: 20024: 3d 62 00 00 addis 11, 2, 0
// CHECK: 20028: e9 8b 80 00 ld 12, -32768(11)
// CHECK: 2002c: e9 6c 00 00 ld 11, 0(12)
// CHECK: 20030: 7d 69 03 a6 mtctr 11
// CHECK: 20034: e8 4c 00 08 ld 2, 8(12)
// CHECK: 20038: e9 6c 00 10 ld 11, 16(12)
// CHECK: 2003c: 4e 80 04 20 bctr