Skip to content

Commit 9bc30a6

Browse files
guenthermordak
authored andcommitted
Add IBT support to the retpoline+znow PLTs
ok kettenis@
1 parent 37dc063 commit 9bc30a6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lld/ELF/Arch/X86_64.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,14 +1166,14 @@ void RetpolineZNow::writePltHeader(uint8_t *buf) const {
11661166
void RetpolineZNow::writePlt(uint8_t *buf, const Symbol &sym,
11671167
uint64_t pltEntryAddr) const {
11681168
const uint8_t insn[] = {
1169-
0x4c, 0x8b, 0x1d, 0, 0, 0, 0, // mov foo@GOTPLT(%rip), %r11
1170-
0xe9, 0, 0, 0, 0, // jmp plt+0
1171-
0xcc, 0xcc, 0xcc, 0xcc, // int3; padding
1169+
0xf3, 0x0f, 0x1e, 0xfa, // 0: endbr64
1170+
0x4c, 0x8b, 0x1d, 0, 0, 0, 0, // 4: mov foo@GOTPLT(%rip), %r11
1171+
0xe9, 0, 0, 0, 0, // b: jmp plt+0
11721172
};
11731173
memcpy(buf, insn, sizeof(insn));
11741174

1175-
write32le(buf + 3, sym.getGotPltVA() - pltEntryAddr - 7);
1176-
write32le(buf + 8, in.plt->getVA() - pltEntryAddr - 12);
1175+
write32le(buf + 7, sym.getGotPltVA() - pltEntryAddr - 11);
1176+
write32le(buf + 12, in.plt->getVA() - pltEntryAddr - 16);
11771177
}
11781178

11791179
static TargetInfo *getTargetInfo() {

0 commit comments

Comments
 (0)