public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/9] nolibc: Add static-pie support
@ 2026-01-31  7:44 Daniel Palmer
  2026-01-31  7:44 ` [RFC PATCH 1/9] elf: Add relocation types used by nolibc Daniel Palmer
                   ` (9 more replies)
  0 siblings, 10 replies; 19+ messages in thread
From: Daniel Palmer @ 2026-01-31  7:44 UTC (permalink / raw)
  To: linux, w; +Cc: kees, linux-kernel, Daniel Palmer

For more background see:
https://lore.kernel.org/lkml/20260116122812.2421621-1-daniel@thingy.jp/

Basically I am trying to run normal ELF binaries created with
nolibc on nommu (m68k, 68000). To make this work without an external
linker nolibc needs code to do the relocation.

The following is my attempt at doing this by hacking just enough
together that static-pie binaries work on a few archs.
The ones that work have a patch in this series.

Answers to questions you might have:
Q: Don't we need to handle more relocation types?
A: Maybe, everything exception sparc only had R_x_RELATIVE in
   the nolibc test binary. sparc emits R_SPARC_NONE as well.

Q: Don't we need to make some sections writable for this to
   work.
A: Maybe, I tried to get most of the supported archs working.
   The only one that had relocations on a non-writable section
   was arm64 and I think I can fix it so it doesn't need that.

Q: Why can't you just pass -static-pie to gcc?
A: Only x86 seemed to actually produce static PIE binaries doing
   that. Everything else produced normal static ones. Maybe this
   is a compiler version thing?

There are probably things I'm missing, things I have done totally
wrong. Please feel free to grill me.

Daniel Palmer (9):
  elf: Add relocation types used by nolibc
  tools/nolibc: crt: Split _start_c() into stack-only and normal part
  tools/nolibc: Add basic ELF self-relocation support for static PIE
  tools/nolibc: m68k: Add relocation support
  tools/nolibc: x86: Add relocation support for x86_64
  tools/nolibc: riscv: Add relocation support
  tools/nolibc: arm: Add relocation support
  selftests/nolibc: Add option for building with -static-pie
  fs/binfmt_elf_fdpic: Reflect that PIE binaries also work in KConfig
    help

 fs/Kconfig.binfmt                             |  10 +
 include/uapi/linux/elf-r.h                    |  27 ++
 include/uapi/linux/elf.h                      |   1 +
 tools/include/nolibc/Makefile                 |   1 +
 tools/include/nolibc/arch-arm.h               |  17 ++
 tools/include/nolibc/arch-m68k.h              |  20 +-
 tools/include/nolibc/arch-riscv.h             |  18 ++
 tools/include/nolibc/arch-x86.h               |  35 +++
 tools/include/nolibc/crt.h                    |  62 +++--
 tools/include/nolibc/reloc.h                  | 240 ++++++++++++++++++
 tools/testing/selftests/nolibc/Makefile       |   2 +-
 .../testing/selftests/nolibc/Makefile.nolibc  |   8 +-
 tools/testing/selftests/nolibc/run-tests.sh   |  10 +-
 13 files changed, 423 insertions(+), 28 deletions(-)
 create mode 100644 include/uapi/linux/elf-r.h
 create mode 100644 tools/include/nolibc/reloc.h

-- 
2.51.0


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-02-01 21:55 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-31  7:44 [RFC PATCH 0/9] nolibc: Add static-pie support Daniel Palmer
2026-01-31  7:44 ` [RFC PATCH 1/9] elf: Add relocation types used by nolibc Daniel Palmer
2026-02-01 16:25   ` Thomas Weißschuh
2026-01-31  7:44 ` [RFC PATCH 2/9] tools/nolibc: crt: Split _start_c() into stack-only and normal part Daniel Palmer
2026-02-01 16:33   ` Thomas Weißschuh
2026-01-31  7:44 ` [RFC PATCH 3/9] tools/nolibc: Add basic ELF self-relocation support for static PIE Daniel Palmer
2026-02-01 16:42   ` Thomas Weißschuh
2026-02-01 21:54     ` Daniel Palmer
2026-01-31  7:44 ` [RFC PATCH 4/9] tools/nolibc: m68k: Add relocation support Daniel Palmer
2026-01-31  7:44 ` [RFC PATCH 5/9] tools/nolibc: x86: Add relocation support for x86_64 Daniel Palmer
2026-02-01 17:56   ` Willy Tarreau
2026-01-31  7:44 ` [RFC PATCH 6/9] tools/nolibc: riscv: Add relocation support Daniel Palmer
2026-01-31  7:44 ` [RFC PATCH 7/9] tools/nolibc: arm: " Daniel Palmer
2026-01-31  7:44 ` [RFC PATCH 8/9] selftests/nolibc: Add option for building with -static-pie Daniel Palmer
2026-01-31  7:44 ` [RFC PATCH 9/9] fs/binfmt_elf_fdpic: Reflect that PIE binaries also work in KConfig help Daniel Palmer
2026-02-01 16:27   ` Thomas Weißschuh
2026-02-01 18:14 ` [RFC PATCH 0/9] nolibc: Add static-pie support Willy Tarreau
2026-02-01 21:45   ` Daniel Palmer
2026-02-01 21:49     ` Willy Tarreau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox