From: Daniel Palmer <daniel@thingy.jp>
To: w@1wt.eu, linux@weissschuh.net
Cc: linux-kernel@vger.kernel.org, Daniel Palmer <daniel@thingy.jp>
Subject: [RFC PATCH v2 00/10] nolibc: Add static-pie support
Date: Wed, 4 Feb 2026 21:45:32 +0900 [thread overview]
Message-ID: <20260204124542.523567-1-daniel@thingy.jp> (raw)
v2:
- This is still RFC quality
- I have gotten a few more archs to work (not crash in nolibc-test) so I have added them
to show the that the arch specific parts are pretty small.
- This should now only add this extra code if NOLIBC_WANT_RELOC is defined, which happens
automatically if you compile with -fpie. Should address Willy's concern with the size
blowing up for even binaries that don't need this.
Size difference on ppc64 is massive, I guess PIC code is big there.
static:
$ file nolibc-test
nolibc-test: ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500, Power ELF V1 ABI, version 1 (SYSV), statically linked, not stripped
$ size nolibc-test
text data bss dec hex filename
59560 3240 104 62904 f5b8 nolibc-test
static pie:
$ file nolibc-test
nolibc-test: ELF 64-bit MSB pie executable, 64-bit PowerPC or cisco 7500, Power ELF V1 ABI, version 1 (SYSV), static-pie linked, with debug_info, not stripped
$ size nolibc-test
text data bss dec hex filename
67801 3656 104 71561 11789 nolibc-test
- Each of the archs checks that the relocations they need (just the one at the moment) is defined
before defining the relocation defines. So this shouldn't break with older UAPI headers.
- I think maybe you might want to set NOLIBC_WANT_RELOC even if __pie__ is not defined,
maybe for testing? So I didn't make it _NOLIBC_WANT_RELOC.
- I was worried some archs didn't work because calling the relocation functions was
causing things like accessing the stack canary before it was accessible. So I added
__inline__ to all of the relocation functions to force them to get inlined into _start_c().
This might be too much. checkpatch certainly hates it.
- I think I addressed most of Thomas' code style comments, prefixing etc. Maybe added some new problems :)
- I cleaned up the REL/RELA differences a bit more so the lines of code has dropped a
bit in reloc.h.
- I fixed working out where the dynamic section is, this fixed SuperH and PPC. I suspect
I can get all of the others except maybe mips working now.
- new elf UAPI header for the relocation types is still wrong, script to run the
self-tests is still wonky.
Thanks in advance,
Daniel
v1: https://lore.kernel.org/lkml/20260131074440.732588-1-daniel@thingy.jp/
v0: https://lore.kernel.org/lkml/20260116122812.2421621-1-daniel@thingy.jp/
Daniel Palmer (10):
elf: Add relocation types used by nolibc
tools/nolibc: crt: Split _start_c() into stack-only and normal parts
tools/nolibc: Add basic ELF self-relocation support for static PIE
tools/nolibc: m68k: Add relocation support
tools/nolibc: x86: Add relocation support
tools/nolibc: riscv: Add relocation support
tools/nolibc: arm: Add relocation support
tools/nolibc: sh: Add relocation support
tools/nolibc: ppc: Add relocation support
selftests/nolibc: Add option for building with -static-pie
include/uapi/linux/elf-r.h | 27 +++
include/uapi/linux/elf.h | 1 +
tools/include/nolibc/Makefile | 1 +
tools/include/nolibc/arch-arm.h | 25 ++
tools/include/nolibc/arch-m68k.h | 27 ++-
tools/include/nolibc/arch-powerpc.h | 24 ++
tools/include/nolibc/arch-riscv.h | 26 ++
tools/include/nolibc/arch-sh.h | 24 ++
tools/include/nolibc/arch-x86.h | 53 +++++
tools/include/nolibc/compiler.h | 6 +
tools/include/nolibc/crt.h | 62 +++--
tools/include/nolibc/reloc.h | 224 ++++++++++++++++++
tools/testing/selftests/nolibc/Makefile | 2 +-
.../testing/selftests/nolibc/Makefile.nolibc | 8 +-
tools/testing/selftests/nolibc/run-tests.sh | 10 +-
15 files changed, 489 insertions(+), 31 deletions(-)
create mode 100644 include/uapi/linux/elf-r.h
create mode 100644 tools/include/nolibc/reloc.h
--
2.51.0
next reply other threads:[~2026-02-04 12:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 12:45 Daniel Palmer [this message]
2026-02-04 12:45 ` [RFC PATCH v2 01/10] elf: Add relocation types used by nolibc Daniel Palmer
2026-02-07 15:35 ` Willy Tarreau
2026-02-16 20:33 ` Thomas Weißschuh
2026-02-04 12:45 ` [RFC PATCH v2 02/10] tools/nolibc: crt: Split _start_c() into stack-only and normal parts Daniel Palmer
2026-02-07 15:45 ` Willy Tarreau
2026-02-08 1:40 ` Daniel Palmer
2026-02-16 20:42 ` Thomas Weißschuh
2026-02-04 12:45 ` [RFC PATCH v2 03/10] tools/nolibc: Add basic ELF self-relocation support for static PIE Daniel Palmer
2026-02-07 15:49 ` Willy Tarreau
2026-02-04 12:45 ` [RFC PATCH v2 04/10] tools/nolibc: m68k: Add relocation support Daniel Palmer
2026-02-16 20:51 ` Thomas Weißschuh
2026-02-04 12:45 ` [RFC PATCH v2 05/10] tools/nolibc: x86: " Daniel Palmer
2026-02-16 21:06 ` Thomas Weißschuh
2026-02-04 12:45 ` [RFC PATCH v2 06/10] tools/nolibc: riscv: " Daniel Palmer
2026-02-04 12:45 ` [RFC PATCH v2 07/10] tools/nolibc: arm: " Daniel Palmer
2026-02-04 12:45 ` [RFC PATCH v2 08/10] tools/nolibc: sh: " Daniel Palmer
2026-02-04 12:45 ` [RFC PATCH v2 09/10] tools/nolibc: ppc: " Daniel Palmer
2026-02-04 12:45 ` [RFC PATCH v2 10/10] selftests/nolibc: Add option for building with -static-pie Daniel Palmer
2026-02-16 20:59 ` Thomas Weißschuh
2026-02-07 15:34 ` [RFC PATCH v2 00/10] nolibc: Add static-pie support Willy Tarreau
2026-02-08 1:35 ` Daniel Palmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260204124542.523567-1-daniel@thingy.jp \
--to=daniel@thingy.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=w@1wt.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®