[lld] r333312 - Add a comment for retpoline PLT.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri May 25 14:02:47 PDT 2018


Author: ruiu
Date: Fri May 25 14:02:47 2018
New Revision: 333312

URL: http://llvm.org/viewvc/llvm-project?rev=333312&view=rev
Log:
Add a comment for retpoline PLT.

Modified:
    lld/trunk/ELF/Arch/X86_64.cpp

Modified: lld/trunk/ELF/Arch/X86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/X86_64.cpp?rev=333312&r1=333311&r2=333312&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/X86_64.cpp (original)
+++ lld/trunk/ELF/Arch/X86_64.cpp Fri May 25 14:02:47 2018
@@ -461,6 +461,15 @@ void X86_64<ELFT>::relaxGot(uint8_t *Loc
   write32le(Loc - 1, Val + 1);
 }
 
+// These nonstandard PLT entries are to migtigate Spectre v2 security
+// vulnerability. In order to mitigate Spectre v2, we want to avoid indirect
+// branch instructions such as `jmp *GOTPLT(%rip)`. So, in the following PLT
+// entries, we use a CALL followed by MOV and RET to do the same thing as an
+// indirect jump. That instruction sequence is so-called "retpoline".
+//
+// We have two types of retpoline PLTs as a size optimization. If `-z now`
+// is specified, all dynamic symbols are resolved at load-time. Thus, when
+// that option is given, we can omit code for symbol lazy resolution.
 namespace {
 template <class ELFT> class Retpoline : public X86_64<ELFT> {
 public:




More information about the llvm-commits mailing list