From: guenther Date: Tue, 30 May 2023 02:02:00 +0000 (+0000) Subject: Add IBT support to the retpoline+znow PLTs X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=398b5afe266f9c6c25a34f6d7627bc2fc9a97bc4;p=openbsd Add IBT support to the retpoline+znow PLTs ok kettenis@ --- diff --git a/gnu/llvm/lld/ELF/Arch/X86_64.cpp b/gnu/llvm/lld/ELF/Arch/X86_64.cpp index 271558c6599..0ecdfe5f1a5 100644 --- a/gnu/llvm/lld/ELF/Arch/X86_64.cpp +++ b/gnu/llvm/lld/ELF/Arch/X86_64.cpp @@ -1122,14 +1122,14 @@ void RetpolineZNow::writePltHeader(uint8_t *buf) const { void RetpolineZNow::writePlt(uint8_t *buf, const Symbol &sym, uint64_t pltEntryAddr) const { const uint8_t insn[] = { - 0x4c, 0x8b, 0x1d, 0, 0, 0, 0, // mov foo@GOTPLT(%rip), %r11 - 0xe9, 0, 0, 0, 0, // jmp plt+0 - 0xcc, 0xcc, 0xcc, 0xcc, // int3; padding + 0xf3, 0x0f, 0x1e, 0xfa, // 0: endbr64 + 0x4c, 0x8b, 0x1d, 0, 0, 0, 0, // 4: mov foo@GOTPLT(%rip), %r11 + 0xe9, 0, 0, 0, 0, // b: jmp plt+0 }; memcpy(buf, insn, sizeof(insn)); - write32le(buf + 3, sym.getGotPltVA() - pltEntryAddr - 7); - write32le(buf + 8, in.plt->getVA() - pltEntryAddr - 12); + write32le(buf + 7, sym.getGotPltVA() - pltEntryAddr - 11); + write32le(buf + 12, in.plt->getVA() - pltEntryAddr - 16); } static TargetInfo *getTargetInfo() {