From: Jeff Law <jeffreyalaw@gmail.com>
To: Mikael Pettersson <mikpelinux@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] wrong code on m68k with -mlong-jump-table-offsets and -malign-int (PR target/112413)
Date: Mon, 11 Dec 2023 08:42:14 -0700 [thread overview]
Message-ID: <06720f7e-547a-4129-bd63-e4d8c2befab0@gmail.com> (raw)
In-Reply-To: <20231211125158.2872910-2-mikpelinux@gmail.com>
On 12/11/23 05:51, Mikael Pettersson wrote:
> On m68k the compiler assumes that the PC-relative jump-via-jump-table
> instruction and the jump table are adjacent with no padding in between.
>
> When -mlong-jump-table-offsets is combined with -malign-int, a 2-byte
> nop may be inserted before the jump table, causing the jump to add the
> fetched offset to the wrong PC base and thus jump to the wrong address.
>
> Fixed by referencing the jump table via its label. On the test case
> in the PR the object code change is (the moveal at 16 is the nop):
>
> a: 6536 bcss 42 <f+0x42>
> c: e588 lsll #2,%d0
> e: 203b 0808 movel %pc@(18 <f+0x18>,%d0:l),%d0
> - 12: 4efb 0802 jmp %pc@(16 <f+0x16>,%d0:l)
> + 12: 4efb 0804 jmp %pc@(18 <f+0x18>,%d0:l)
> 16: 284c moveal %a4,%a4
> 18: 0000 0020 orib #32,%d0
> 1c: 0000 002c orib #44,%d0
>
> Bootstrapped and tested on m68k-linux-gnu, no regressions.
>
> Note: I don't have commit rights to I would need assistance applying this.
>
> 2023-12-11 Mikael Pettersson <mikpelinux@gmail.com>
>
> PR target/112413
> * config/m68k/linux.h (ASM_RETURN_CASE_JUMP): For
> TARGET_LONG_JUMP_TABLE_OFFSETS, reference the jump table
> via its label.
> * config/m68k/m68kelf.h (ASM_RETURN_CASE_JUMP: Likewise.
> * config/m68k/netbsd-elf.h (ASM_RETURN_CASE_JUMP): Likewise.
THanks. Installed.
jeff
prev parent reply other threads:[~2023-12-11 15:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 12:51 Mikael Pettersson
2023-12-11 15:42 ` Jeff Law [this message]
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=06720f7e-547a-4129-bd63-e4d8c2befab0@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=mikpelinux@gmail.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).