1From 3ac265d5c0e038e324bae29131dbc4bacb4935ea Mon Sep 17 00:00:00 2001 2From: hjl-tools <hjl.tools@gmail.com> 3Date: Sun, 15 May 2022 18:43:56 -0700 4Subject: [PATCH] x86-64: Always double jump table slot size for CET (#710) 5 (#711) 6 7When CET is enabled, double jump table slot size to add 4 bytes of ENDBR64 8for CET. Since CET enabled clang doesn't have the LLVM assembler bug: 9 10https://bugs.llvm.org/show_bug.cgi?id=21501 11 12fixed by 13 14commit 04d39260d64e08b8bfb3844109ad43d4055b2e8d 15Author: Rafael Espindola <rafael.espindola@gmail.com> 16Date: Wed Nov 4 23:50:29 2015 +0000 17 18 Simplify .org processing and make it a bit more powerful. 19 20we can use .org to allocate jump table slot size to 16 bytes. 21 22Conflict:NA 23Reference:https://github.com/libffi/libffi/commit/3ac265d5c0e038e324bae29131dbc4bacb4935ea 24--- 25 src/x86/unix64.S | 11 +++++------ 26 1 file changed, 5 insertions(+), 6 deletions(-) 27 28diff --git a/src/x86/unix64.S b/src/x86/unix64.S 29index 8cf3a23..d9c5bd4 100644 30--- a/src/x86/unix64.S 31+++ b/src/x86/unix64.S 32@@ -39,14 +39,13 @@ 33 actual table. The entry points into the table are all 8 bytes. 34 The use of ORG asserts that we're at the correct location. */ 35 /* ??? The clang assembler doesn't handle .org with symbolic expressions. */ 36-#if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__)) 37+#ifdef __CET__ 38+/* Double slot size to 16 byte to add 4 bytes of ENDBR64. */ 39+# define E(BASE, X) .balign 8; .org BASE + X * 16 40+#elif defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__)) 41 # define E(BASE, X) .balign 8 42 #else 43-# ifdef __CET__ 44-# define E(BASE, X) .balign 8; .org BASE + X * 16 45-# else 46-# define E(BASE, X) .balign 8; .org BASE + X * 8 47-# endif 48+# define E(BASE, X) .balign 8; .org BASE + X * 8 49 #endif 50 51 /* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, 52-- 532.23.0 54