Hi Thomas,
On Mon, 2025-06-23 at 23:15 +0200, Thomas Weißschuh wrote:
> Add support for SuperH/"sh" to nolibc.
> Only sh4 is tested for now.
>
> This is only tested on QEMU so far.
> Additional testing would be very welcome.
> Test instructions:
> $ cd tools/testings/selftests/nolibc/
> $ make -f Makefile.nolibc ARCH=sh CROSS_COMPILE=sh4-linux- nolibc-test
> $ file nolibc-test
> nolibc-test: ELF 32-bit LSB executable, Renesas SH, version 1 (SYSV),
> statically linked, not stripped
> $ ./nolibc-test
> Running test 'startup'
> 0 argc = 1[OK]
> ...
> Total number of errors: 0
> Exiting with status 0
Here is the testrun of the nolibc-test on my SH7785LCR evaluation board:
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc$ cat /proc/cpuinfo
machine : SH7785LCR
processor : 0
cpu family : sh4a
cpu type: SH7785
cut : 7.x
cpu flags : fpu perfctr llsc
cache type : split (harvard)
icache size : 32KiB (4-way)
dcache size : 32KiB (4-way)
address sizes : 32 bits physical
bogomips: 599.99
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc$ uname -a
Linux tirpitz.buildd.org 6.5.0-rc2 #1 PREEMPT Mon Jul 17 14:17:32 UTC 2023 sh4a
GNU/Linux
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc$ cd tools/testing/selftests/nolibc/
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc/tools/testing/selftests/nolibc$
make -f Makefile.nolibc ARCH=sh nolibc-test
MKDIR sysroot/sh/include
make[1]: Entering directory '/srv/glaubitz/linux-nolibc'
make[2]: Nothing to be done for 'outputmakefile'.
make[1]: Leaving directory '/srv/glaubitz/linux-nolibc'
make[1]: Entering directory '/srv/glaubitz/linux-nolibc/tools/include/nolibc'
make[2]: Entering directory '/srv/glaubitz/linux-nolibc'
UPD include/generated/uapi/linux/version.h
HOSTCC scripts/basic/fixdep
HOSTCC scripts/unifdef
WRAParch/sh/include/generated/uapi/asm/ucontext.h
WRAParch/sh/include/generated/uapi/asm/bitsperlong.h
WRAParch/sh/include/generated/uapi/asm/bpf_perf_event.h
WRAParch/sh/include/generated/uapi/asm/errno.h
WRAParch/sh/include/generated/uapi/asm/fcntl.h
WRAParch/sh/include/generated/uapi/asm/ioctl.h
WRAParch/sh/include/generated/uapi/asm/ipcbuf.h
WRAParch/sh/include/generated/uapi/asm/mman.h
(...)
HDRINST usr/include/asm/statfs.h
HDRINST usr/include/asm/types.h
HDRINST usr/include/asm/setup.h
HDRINST usr/include/asm/resource.h
HDRINST usr/include/asm/termios.h
HDRINST usr/include/asm/poll.h
make[2]: Leaving directory '/srv/glaubitz/linux-nolibc'
make[2]: Entering directory '/srv/glaubitz/linux-nolibc'
INSTALL
/srv/glaubitz/linux-nolibc/tools/testing/selftests/nolibc/sysroot/sysroot/include
make[2]: Leaving directory '/srv/glaubitz/linux-nolibc'
make[1]: Leaving directory '/srv/glaubitz/linux-nolibc/tools/include/nolibc'
CC nolibc-test
In file included from sysroot/sh/include/arch.h:11,
from sysroot/sh/include/nolibc.h:96,
from sysroot/sh/include/stdio.h:8,
from nolibc-test.c:12:
sysroot/sh/include/crt.h:34:1: warning: ‘function’ attribute directive ignored
[-Wattributes]
34 | {
| ^
In file included from sysroot/sh/include/arch.h:11,
from sysroot/sh/include/nolibc.h:96,
from sysroot/sh/include/errno.h:8,
from nolibc-test-linkage.c:5:
sysroot/sh/include/crt.h:34:1: warning: ‘function’ attribute directive ignored
[-Wattributes]
34 | {
| ^
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc/tools/testing/selftests/nolibc$
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc/tools/testing/selftests/nolibc$
file ./nolibc-test
./nolibc-test: ELF 32-bit LSB executable, Renesas SH, version 1 (SYSV),
statically linked, BuildID[sha1]=b23b591a8deeb8b746636128821be1b577f3266b, not
stripped
glaubitz@tirpitz:/srv/glaubitz/linux-nolibc/tools/testing/selftests/nolibc$
./nolibc-test
Running test 'startup'
0 argc = 1[OK]
1 argv_addr = <0x7bd4b074>[OK]
2 argv_environ = <0x7bd4b074> [OK]
3 argv_total = 1 [OK]
4 argv0_addr = <0x7bd4b1c2> [OK]
5 argv0_str = <./nolibc-test> [OK]
6 argv0_len = 13 [OK]
7 environ_addr = <0x7bd4b07c> [OK]
8 environ_envp = <0x7bd4b07c> [OK]
9 environ_auxv = <0x7bd4b07c> [OK]
10 environ_total = 111[OK]
11 environ_HOME = <0x7bd4b672>[OK]
12 auxv_addr = <0x7bd4b0ec> [OK]
13 auxv_AT_UID = 1000 [OK]
14 constructor