elf: support ELF binaries in noMMU
commit74d5b684253ce61404c1b72f2726599f00eb0a14
authorGreg Ungerer <gerg@kernel.org>
Tue, 28 Nov 2023 13:29:43 +0000 (28 23:29 +1000)
committerWaldemar Brodkorb <wbx@openadk.org>
Tue, 12 Dec 2023 04:51:34 +0000 (12 05:51 +0100)
tree6aab797e63c89b3c9575c2df35440499a35f5b00
parent75a5fc9e5033f47e955406e300a070004c14b8ae
elf: support ELF binaries in noMMU

The Linux kernels ELF-FDPIC binfmt program loader can support loading and
running conventional ELF format binaries on noMMU kernels when compiled
appropriately. That is when they are constant displacement binaries such
as generated using the -pie compile option.

Add a configure option to allow selecting ELF binary support in noMMU
mode configurations on architectures that support this. The main
requirement is to generate the ldso run-time loader to perform relocation
at load time. These configurations do not support shared libraries, so
there is no need to generate a full shared library, only the static
version is required.

The use of ELF format binaries does mean a slightly simpler toolchain
generation (does not require a -uclinux- for some architectures) and does
not require an extra tool like elf2flt.

This initial support targets M68K, ARM and RISC-V architectures. No kernel
changes are required, the required support for this is already in mainline
kernels (certainly as of linux-6.6).

Note that for the M68K and ARM architectures that the initialized
registers and stack layout at process startup is slightly different for
the flat format loader and the ELF/ELF-FDPIC loaders. So we need some
changes to the startup code (crt1.S) for them.

I have not done extensive testing outside of M68K, ARM and RISC-V.
I had to make changes to a couple of the dl-startup.h architecture files
to get them to build for this noMMU case. I did not dig down too deep on
the reasons, but they still seem ok for the MMU case as well.

Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
12 files changed:
Makerules
Rules.mak
extra/Configs/Config.in
extra/Configs/Config.in.arch
ldso/include/dl-defs.h
ldso/include/ldso.h
ldso/ldso/arm/dl-startup.h
ldso/ldso/m68k/dl-startup.h
ldso/ldso/m68k/dl-sysdep.h
ldso/ldso/riscv64/dl-startup.h
libc/sysdeps/linux/arm/crt1.S
libc/sysdeps/linux/m68k/crt1.S