#1142174 sh4-linux-gnu-gcc does not produce big-endian binaries

Package:
gcc-15-sh4-linux-gnu
Source:
gcc-15-sh4-linux-gnu
Description:
GNU C compiler for the sh4-linux-gnu architecture
Submitter:
Michael Tokarev
Date:
2026-07-18 04:05:01 UTC
Severity:
normal
#1142174#5
Date:
2026-07-16 08:22:04 UTC
From:
To:
When trying to build an sh4eb binary, there's a failure at the link stage:

 sh4-linux-gnu-gcc -mb vdso.S [other options]
 ...
 sh4-linux-gnu-ld.bfd: unrecognised emulation mode: shelf_linux
 Supported emulations: shlelf_linux shlelf_fd

From the specs:

 *link_emul_prefix:
 sh%{!mb:l}elf

I dunno if this is supposed to be valid or not, and whenever this is a
gcc bug (specs file) or missing support in binutils.

as gets --big option correctly.

Also, using

 sh4-linux-gnu-gcc -Wl,-EB -Wa,--big vdso.S

produces a binary, but I dunno (yet) if it is the right one or not.

This is needed for qemu, as it now ships vdso for sh4eb (in assembly
form, so it does not need anything extra) which has to be compiled.

Thanks,

/mjt

#1142174#10
Date:
2026-07-17 19:42:57 UTC
From:
To:
I built big endian binaries fine with 15.1.

I.E.
https://landley.net/bin/toolchains/19-06-2026/sh4eb-linux-musl-cross.tar.xz
built https://landley.net/bin/mkroot/0.8.14/sh4eb.tgz and booted it
under QEMU.

I admit I haven't tried to do a multilib or glibc compiler in ages...

https://landley.net/bin/toolchains/19-06-2026/README

I was using qemu 11.0.0 with my patch to provide 200 megs of memory to
qemu's r2d board:

https://lists.gnu.org/archive/html/qemu-devel/2026-01/msg06318.html

Rob

#1142174#15
Date:
2026-07-17 19:42:57 UTC
From:
To:
I built big endian binaries fine with 15.1.

I.E.
https://landley.net/bin/toolchains/19-06-2026/sh4eb-linux-musl-cross.tar.xz
built https://landley.net/bin/mkroot/0.8.14/sh4eb.tgz and booted it
under QEMU.

I admit I haven't tried to do a multilib or glibc compiler in ages...

https://landley.net/bin/toolchains/19-06-2026/README

I was using qemu 11.0.0 with my patch to provide 200 megs of memory to
qemu's r2d board:

https://lists.gnu.org/archive/html/qemu-devel/2026-01/msg06318.html

Rob

#1142174#20
Date:
2026-07-18 04:03:48 UTC
From:
To:
The problem here is different.

You built a separate compiler (or whole toolchain) especially for sh4eb.

However, this bug report says about sh4-linux-gnu-gcc, not sh4eb-*.
As documented, this compiler has -mb option, to produce big-endian code.
And this option does not work, with very minor omission which prevents
it from working.  Everything else seems to be here, just filling small
gap will let things work, without the need to build separate toolchain
especially for sh4beb.

Maybe I should retitle this bug report somehow to make this clear.

Thanks,

/mjt

#1142174#25
Date:
2026-07-18 04:03:48 UTC
From:
To:
The problem here is different.

You built a separate compiler (or whole toolchain) especially for sh4eb.

However, this bug report says about sh4-linux-gnu-gcc, not sh4eb-*.
As documented, this compiler has -mb option, to produce big-endian code.
And this option does not work, with very minor omission which prevents
it from working.  Everything else seems to be here, just filling small
gap will let things work, without the need to build separate toolchain
especially for sh4beb.

Maybe I should retitle this bug report somehow to make this clear.

Thanks,

/mjt