public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "luto at kernel dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/98997] New: Linking mismatched -fcf-protection objects generates incorrect code Date: Mon, 08 Feb 2021 06:15:36 +0000 [thread overview] Message-ID: <bug-98997-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98997 Bug ID: 98997 Summary: Linking mismatched -fcf-protection objects generates incorrect code Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: luto at kernel dot org Target Milestone: --- $ gcc --version gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9) Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ cat cet1.c #include <setjmp.h> void test(jmp_buf buf) { __builtin_longjmp(buf, 1); } $ cat cet2.c #include <setjmp.h> void test(jmp_buf buf); int main() { jmp_buf buf; if (__builtin_setjmp(buf) == 0) test(buf); return 0; } $ gcc -c -O2 cet1.c -fcf-protection=full $ gcc -c -O2 cet2.c $ gcc -o cet -O2 cet1.o cet2.o $ ./cet Illegal instruction (core dumped) Presumably the magic CET fixup in the builtin setjmp/longjmp requires that matching code is generated for both. I'm testing on a non-CET system. I haven't even tried to figure out if anything sensible happens to the CET GNU property, but I think the current GCC behavior is impolite at best. I think GCC should do one of a few things: 1. Generate working code. 2. Fail to link. 3. At least document this pitfall very clearly. I really hope this doesn't affect shared objects.
next reply other threads:[~2021-02-08 6:15 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-08 6:15 luto at kernel dot org [this message] 2021-02-08 9:38 ` [Bug target/98997] " rguenth at gcc dot gnu.org 2021-02-08 12:54 ` hjl.tools at gmail dot com 2021-02-08 17:38 ` luto at kernel dot org 2021-02-08 17:42 ` luto at kernel dot org 2021-02-08 18:43 ` hjl.tools at gmail dot com 2021-02-08 18:44 ` hjl.tools at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-98997-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).