Skip to content

riscv: support ELF format binaries in nommu mode

Greg Ungerer linux-mm linux-riscv lkml 2 versions – Applied

Status from this message: This series was applied to riscv/linux.git (for-next)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 8 repliesApplied 2/2
  2. v12 patches 15 repliesSuperseded

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2binfmt_elf_fdpic: support 64-bit systemsfs/binfmt_elf_fdpic.c include/linux/elf-fdpic.h include/uapi/linux/elf-fdpic.h+47 -201 replyApplied
2/2riscv: support the elf-fdpic binfmt loaderarch/riscv/include/asm/elf.h arch/riscv/include/asm/mmu.h arch/riscv/include/uapi/asm/ptrace.h +1 more+20 -27 repliesApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchKees Cook
1/2A-b
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] riscv: support ELF format binaries in nommu mode

The following changes add the ability to run ELF format binaries when running RISC-V in nommu mode. That support is actually part of the ELF-FDPIC loader, so these changes are all about making that work on RISC-V.

The first issue to deal with is making the ELF-FDPIC loader capable of handling 64-bit ELF files. As coded right now it only supports 32-bit ELF files.

Secondly some changes are required to enable and compile the ELF-FDPIC loader on RISC-V and to pass the ELF-FDPIC mapping addresses through to user space when execing the new program.

These changes have not been used to run actual ELF-FDPIC binaries. It is used to load and run normal ELF - compiled -pie format. Though the underlying changes are expected to work with full ELF-FDPIC binaries if or when that is supported on RISC-V in gcc.

To avoid needing changes to the C-library (tested with uClibc-ng currently) there is a simple runtime dynamic loader (interpreter) available to do the final relocations, https://github.com/gregungerer/uldso.
The nice thing about doing it this way is that the same program binary can also be loaded with the usual ELF loader in MMU linux.

The motivation here is to provide an easy to use alternative to the flat format binaries normally used for RISC-V nommu based systems.

---
v1->v2: rebase onto 6.5-rc1

 arch/riscv/include/asm/elf.h         |   11 +++++++++-
 arch/riscv/include/asm/mmu.h         |    4 +++
 arch/riscv/include/uapi/asm/ptrace.h |    5 ++++
 fs/Kconfig.binfmt                    |    2 -
 fs/binfmt_elf_fdpic.c                |   38 +++++++++++++++++------------------
 include/linux/elf-fdpic.h            |   14 +++++++++++-
 include/uapi/linux/elf-fdpic.h       |   15 +++++++++++++
 7 files changed, 67 insertions(+), 22 deletions(-)