Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -855,35 +855,12 @@ AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no) ]) ;; -i?86) - AC_MSG_CHECKING(for endbr32) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([], [ - __asm__ __volatile__ ("endbr32"); - ]) - ], [ - AC_DEFINE(HAVE_ENDBR32, 1, [Whether we have endbr32]) - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - ]) - ;; -x86_64) - AC_MSG_CHECKING(for endbr64) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([], [ - __asm__ __volatile__ ("endbr64"); - ]) - ], [ - AC_DEFINE(HAVE_ENDBR64, 1, [Whether we have endbr64]) - AC_MSG_RESULT(yes) - ], [ - AC_MSG_RESULT(no) - ]) +i?86 | x86_64) + AC_CHECK_HEADERS(cet.h) ;; esac AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm") AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex") Index: src/forwarding/apple-forwarding-amd64.S ================================================================== --- src/forwarding/apple-forwarding-amd64.S +++ src/forwarding/apple-forwarding-amd64.S @@ -12,10 +12,16 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#ifdef HAVE_CET_H +# include +#else +# define _CET_ENDBR +#endif .globl _OFForward .globl _OFForward_stret .section __TEXT, __objc_methname, cstring_literals @@ -29,13 +35,11 @@ .section __DATA, __objc_imageinfo, regular, no_dead_strip .long 0, 0 .section __TEXT, __text, regular, pure_instructions _OFForward: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ @@ -106,13 +110,11 @@ popq %rbp jmp _OFMethodNotFound _OFForward_stret: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ Index: src/forwarding/apple-forwarding-x86.S ================================================================== --- src/forwarding/apple-forwarding-x86.S +++ src/forwarding/apple-forwarding-x86.S @@ -12,10 +12,16 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#ifdef HAVE_CET_H +# include +#else +# define _CET_ENDBR +#endif .globl _OFForward .globl _OFForward_stret .section __TEXT, __cstring, cstring_literals @@ -29,13 +35,11 @@ .section __OBJC, __image_info .long 0, 0 .section __TEXT, __text, regular, pure_instructions _OFForward: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx @@ -83,13 +87,11 @@ popl %ebp jmp _OFMethodNotFound _OFForward_stret: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx Index: src/forwarding/forwarding-amd64-elf.S ================================================================== --- src/forwarding/forwarding-amd64-elf.S +++ src/forwarding/forwarding-amd64-elf.S @@ -14,19 +14,23 @@ */ #include "config.h" #include "platform.h" + +#ifdef HAVE_CET_H +# include +#else +# define _CET_ENDBR +#endif .globl OFForward .globl OFForward_stret .section .text OFForward: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ @@ -109,13 +113,11 @@ jmp OFMethodNotFound@PLT .type OFForward, %function .size OFForward, .-OFForward OFForward_stret: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ @@ -200,13 +202,11 @@ jmp OFMethodNotFound_stret@PLT .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret init: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR leaq module(%rip), %rdi jmp __objc_exec_class@PLT #ifdef OF_SOLARIS Index: src/forwarding/forwarding-amd64-macho.S ================================================================== --- src/forwarding/forwarding-amd64-macho.S +++ src/forwarding/forwarding-amd64-macho.S @@ -14,19 +14,23 @@ */ #include "config.h" #include "platform.h" + +#ifdef HAVE_CET_H +# include +#else +# define _CET_ENDBR +#endif .globl _OFForward .globl _OFForward_stret .section __TEXT, __text, regular, pure_instructions _OFForward: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ @@ -107,13 +111,11 @@ popq %rbp jmp _OFMethodNotFound _OFForward_stret: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ @@ -196,13 +198,11 @@ popq %rbp jmp _OFMethodNotFound_stret init: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR leaq module(%rip), %rdi jmp ___objc_exec_class .section __DATA, __mod_init_func, mod_init_funcs Index: src/forwarding/forwarding-amd64-win64.S ================================================================== --- src/forwarding/forwarding-amd64-win64.S +++ src/forwarding/forwarding-amd64-win64.S @@ -12,19 +12,23 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#ifdef HAVE_CET_H +# include +#else +# define _CET_ENDBR +#endif .globl OFForward .globl OFForward_stret .section .text OFForward: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ @@ -97,13 +101,11 @@ .scl 2 .type 32 .endef OFForward_stret: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR pushq %rbp movq %rsp, %rbp /* Save all arguments */ @@ -178,13 +180,11 @@ .scl 2 .type 32 .endef init: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR leaq module(%rip), %rcx jmp __objc_exec_class .section .ctors, "aw" Index: src/forwarding/forwarding-x86-elf.S ================================================================== --- src/forwarding/forwarding-x86-elf.S +++ src/forwarding/forwarding-x86-elf.S @@ -14,19 +14,23 @@ */ #include "config.h" #include "platform.h" + +#ifdef HAVE_CET_H +# include +#else +# define _CET_ENDBR +#endif .globl OFForward .globl OFForward_stret .section .text OFForward: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx @@ -88,13 +92,11 @@ jmp *%eax .type OFForward, %function .size OFForward, .-OFForward OFForward_stret: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx @@ -156,13 +158,11 @@ jmp *%eax .type OFForward_stret, %function .size OFForward_stret, .-OFForward_stret init: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx Index: src/forwarding/forwarding-x86-win32.S ================================================================== --- src/forwarding/forwarding-x86-win32.S +++ src/forwarding/forwarding-x86-win32.S @@ -15,16 +15,20 @@ #include "config.h" .globl _OFForward .globl _OFForward_stret + +#ifdef HAVE_CET_H +# include +#else +# define _CET_ENDBR +#endif .section .text _OFForward: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx @@ -83,13 +87,11 @@ .scl 2 .type 32 .endef _OFForward_stret: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx @@ -148,13 +150,11 @@ .scl 2 .type 32 .endef init: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR pushl %ebp movl %esp, %ebp pushl %ebx Index: src/runtime/lookup-asm/lookup-asm-amd64-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-amd64-elf.S +++ src/runtime/lookup-asm/lookup-asm-amd64-elf.S @@ -14,22 +14,26 @@ */ #include "config.h" #include "platform.h" + +#ifdef HAVE_CET_H +# include +#else +# define _CET_ENDBR +#endif .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR testq %rdi, %rdi jz returnNilMethod testb $1, %dil @@ -70,13 +74,11 @@ .size \name, .-\name .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR movq %rdi, %r8 movq (%rdi), %rdi testq %rdi, %rdi jz returnNilMethod Index: src/runtime/lookup-asm/lookup-asm-amd64-win64.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-amd64-win64.S +++ src/runtime/lookup-asm/lookup-asm-amd64-win64.S @@ -12,22 +12,26 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#ifdef HAVE_CET_H +# include +#else +# define _CET_ENDBR +#endif .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR testq %rcx, %rcx jz returnNilMethod testb $1, %cl @@ -77,13 +81,11 @@ .endef .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: -#ifdef HAVE_ENDBR64 - endbr64 -#endif + _CET_ENDBR movq %rcx, %r8 movq (%rcx), %rcx testq %rcx, %rcx jz returnNilMethod Index: src/runtime/lookup-asm/lookup-asm-x86-elf.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86-elf.S +++ src/runtime/lookup-asm/lookup-asm-x86-elf.S @@ -14,22 +14,26 @@ */ #include "config.h" #include "platform.h" + +#ifdef HAVE_CET_H +# include +#else +# define _CET_ENDBR +#endif .globl objc_msg_lookup .globl objc_msg_lookup_stret .globl objc_msg_lookup_super .globl objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR movl 4(%esp), %edx testl %edx, %edx jz returnNilMethod @@ -80,13 +84,11 @@ .size \name, .-\name .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR movl 4(%esp), %edx movl (%edx), %eax testl %eax, %eax jz returnNilMethod Index: src/runtime/lookup-asm/lookup-asm-x86-win32.S ================================================================== --- src/runtime/lookup-asm/lookup-asm-x86-win32.S +++ src/runtime/lookup-asm/lookup-asm-x86-win32.S @@ -12,22 +12,26 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#ifdef HAVE_CET_H +# include +#else +# define _CET_ENDBR +#endif .globl _objc_msg_lookup .globl _objc_msg_lookup_stret .globl _objc_msg_lookup_super .globl _objc_msg_lookup_super_stret .section .text .macro GENERATE_LOOKUP name notFound \name: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR movl 4(%esp), %edx testl %edx, %edx jz returnNilMethod @@ -69,13 +73,11 @@ .endef .endm .macro GENERATE_LOOKUP_SUPER name lookup \name: -#ifdef HAVE_ENDBR32 - endbr32 -#endif + _CET_ENDBR movl 4(%esp), %edx movl (%edx), %eax test %eax, %eax jz returnNilMethod