diff --git a/cli/trampolines/trampolines_i686.S b/cli/trampolines/trampolines_i686.S index 28298468e77b1..3b2be2bfd8c28 100644 --- a/cli/trampolines/trampolines_i686.S +++ b/cli/trampolines/trampolines_i686.S @@ -12,12 +12,18 @@ #define DEBUGINFO(name) #endif +#if defined(__CET__) && __CET__ & 1 != 0 +#define CET_START() endbr32 +#else +#define CET_START() +#endif + #define XX(name) \ DEBUGINFO(name); \ .global name; \ .cfi_startproc; \ name##:; \ - endbr32; \ + CET_START(); \ jmpl *(CNAME(name##_addr)); \ ud2; \ .cfi_endproc; \ diff --git a/cli/trampolines/trampolines_x86_64.S b/cli/trampolines/trampolines_x86_64.S index 8e3a5271680a1..8f51a1eca35b0 100644 --- a/cli/trampolines/trampolines_x86_64.S +++ b/cli/trampolines/trampolines_x86_64.S @@ -26,6 +26,12 @@ #define SEH_END() #endif +#if defined(__CET__) && __CET__ & 1 != 0 +#define CET_START() endbr64 +#else +#define CET_START() +#endif + #define XX(name) \ DEBUGINFO(name); \ .global name; \ @@ -33,7 +39,7 @@ DEBUGINFO(name); \ SEH_START1(name); \ name##:; \ SEH_START2(); \ - endbr64; \ + CET_START(); \ mov CNAME(name##_addr)(%rip),%rax; \ jmpq *%rax; \ ud2; \