From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2E6E73858402; Wed, 27 Oct 2021 18:50:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E6E73858402 From: "andrew.cooper3 at citrix dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/102953] Improvements to CET-IBT and ENDBR generation Date: Wed, 27 Oct 2021 18:50:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: andrew.cooper3 at citrix dot com X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: hjl.tools at gmail dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Oct 2021 18:50:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102953 --- Comment #7 from Andrew Cooper --- 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=3Dbranch -mmanual-endbr -fcf-check-attribute=3Dno 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) =3D a; // Now raises a diagnostic void (*ptr_b)(void) =3D b; // Did diagnose previously, still does void (*ptr_c)(void) =3D 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.=