https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102953
--- Comment #7 from Andrew Cooper <andrew.cooper3 at citrix dot com> --- Thankyou. I've tried these two patches and they do appear to be behaving as intended. I've put together a slightly extended version of the original test. Compile with gcc -Wall -fno-pic -Os -fcf-protection=branch -mmanual-endbr -fcf-check-attribute=no static void __attribute__((noinline)) a(void) { asm volatile ("sti":::"memory"); } void __attribute__((nocf_check, noinline)) b(void) { asm volatile ("std":::"memory"); } void __attribute__((cf_check, noinline)) c(void) { asm volatile ("cmc":::"memory"); } void (*ptr_a)(void) = a; // Now raises a diagnostic void (*ptr_b)(void) = b; // Did diagnose previously, still does void (*ptr_c)(void) = c; int test(void) { ptr_a(); ptr_b(); ptr_c(); a(); b(); c(); // When fully linked, does skip c's ENDBR64 instruction return 0; } int main(void) { return 0; } I'll try applying this to a bigger codebase now.