From: Xi Ruoyao <xry111@xry111.site>
To: Tiezhu Yang <yangtiezhu@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Rui <wangrui@loongson.cn>,
loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] LoongArch: Add -fno-isolate-erroneous-paths-dereference in Makefile
Date: Tue, 23 Sep 2025 20:39:25 +0800 [thread overview]
Message-ID: <53b3b0e4c12f048d17e95111ac97b59fa35dea23.camel@xry111.site> (raw)
In-Reply-To: <20250923061722.24457-1-yangtiezhu@loongson.cn>
On Tue, 2025-09-23 at 14:17 +0800, Tiezhu Yang wrote:
> Currently, when compiling with GCC, there is no "break 0x7" instruction
> for zero division due to using the option -mno-check-zero-division, but
> the compiler still generates "break 0x0" instruction for zero division.
>
> Here is a simple example:
>
> $ cat test.c
> int div(int a)
> {
> return a / 0;
> }
> $ gcc -O2 -S test.c -o test.s
>
> GCC generates "break 0" On LoongArch and "ud2" on x86, objtool decodes
> "ud2" as INSN_BUG for x86, so decode "break 0" as INSN_BUG can fix the
> objtool warnings for LoongArch, but this is not the intention.
>
> When decoding "break 0" as INSN_TRAP in the previous commit, the aim is
> to handle "break 0" as a trap. The generated "break 0" for zero division
> by GCC is not proper, it should generate a break instruction with proper
> bug type, so add the GCC option -fno-isolate-erroneous-paths-dereference
> to avoid generating the unexpected "break 0" instruction for now.
I just proposed GCC to use the same "documented undefined instruction"
as Clang:
https://gcc.gnu.org/pipermail/gcc-patches/2025-September/695981.html.
--
Xi Ruoyao <xry111@xry111.site>
next prev parent reply other threads:[~2025-09-23 12:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 6:17 Tiezhu Yang
2025-09-23 12:39 ` Xi Ruoyao [this message]
2025-09-28 12:52 ` Huacai Chen
2025-09-23 14:32 ` Huacai Chen
2025-09-28 8:39 ` Tiezhu Yang
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=53b3b0e4c12f048d17e95111ac97b59fa35dea23.camel@xry111.site \
--to=xry111@xry111.site \
--cc=chenhuacai@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=wangrui@loongson.cn \
--cc=yangtiezhu@loongson.cn \
/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: link
Be 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
all inboxes | Powered by JetHome®