diff options
author | gkoehler <gkoehler@openbsd.org> | 2020-10-18 01:29:43 +0000 |
---|---|---|
committer | gkoehler <gkoehler@openbsd.org> | 2020-10-18 01:29:43 +0000 |
commit | 281fc861f1643ad20868f1a996ca9689e28c0b9d (patch) | |
tree | 44185bcdd6c328b2626c6d9fc188911212348203 /gnu | |
parent | Avoid potential infinite loop in pmap_vp_destroy(). (diff) | |
download | wireguard-openbsd-281fc861f1643ad20868f1a996ca9689e28c0b9d.tar.xz wireguard-openbsd-281fc861f1643ad20868f1a996ca9689e28c0b9d.zip |
Use all 64 bits of the RETGUARD cookie on powerpc64
Change the 64-bit target to use "ld" (load 64-bit doubleword) for the
cookie. The 32-bit target stays with "lwz" (load 32-bit word).
ok mortimer@
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/llvm/llvm/lib/Target/PowerPC/PPCReturnProtectorLowering.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/gnu/llvm/llvm/lib/Target/PowerPC/PPCReturnProtectorLowering.cpp b/gnu/llvm/llvm/lib/Target/PowerPC/PPCReturnProtectorLowering.cpp index ef7a9430adc..c132f5eed00 100644 --- a/gnu/llvm/llvm/lib/Target/PowerPC/PPCReturnProtectorLowering.cpp +++ b/gnu/llvm/llvm/lib/Target/PowerPC/PPCReturnProtectorLowering.cpp @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#include "PPC.h" #include "PPCInstrInfo.h" #include "PPCMachineFunctionInfo.h" #include "PPCReturnProtectorLowering.h" @@ -62,16 +63,12 @@ void PPCReturnProtectorLowering::insertReturnProtectorPrologue( llvm_unreachable("ppc64 retguard requires ELFv2"); // Get the return address into LRReg BuildMI(MBB, MI, MBBDL, TII->get(MFLR), LRReg); - // Get the random cookie address into REG + // Load the random cookie value into REG BuildMI(MBB, MI, MBBDL, TII->get(PPC::ADDIStocHA8), REG) .addReg(TOCReg) .addGlobalAddress(cookie); - BuildMI(MBB, MI, MBBDL, TII->get(PPC::ADDItocL), REG) - .addReg(REG) - .addGlobalAddress(cookie); - // Now load the random cookie value - BuildMI(MBB, MI, MBBDL, TII->get(PPC::LWZ), REG) - .addImm(0) + BuildMI(MBB, MI, MBBDL, TII->get(PPC::LD), REG) + .addGlobalAddress(cookie, 0, PPCII::MO_TOC_LO) .addReg(REG); // XOR cookie ^ random = retguard cookie BuildMI(MBB, MI, MBBDL, TII->get(XOR), REG) @@ -158,16 +155,12 @@ void PPCReturnProtectorLowering::insertReturnProtectorEpilogue( BuildMI(MBB, MI, MBBDL, TII->get(XOR), REG) .addReg(REG) .addReg(LRReg); - // Get the random cookie address into RGReg + // Load the random cookie value into RGReg BuildMI(MBB, MI, MBBDL, TII->get(PPC::ADDIStocHA8), RGReg) .addReg(TOCReg) .addGlobalAddress(cookie); - BuildMI(MBB, MI, MBBDL, TII->get(PPC::ADDItocL), RGReg) - .addReg(RGReg) - .addGlobalAddress(cookie); - // Load the cookie random balue - BuildMI(MBB, MI, MBBDL, TII->get(PPC::LWZ), RGReg) - .addImm(0) + BuildMI(MBB, MI, MBBDL, TII->get(PPC::LD), RGReg) + .addGlobalAddress(cookie, 0, PPCII::MO_TOC_LO) .addReg(RGReg); // Trap if they don't compare BuildMI(MBB, MI, MBBDL, TII->get(TRAP)) |