public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Daniel Palmer <daniel@thingy.jp>
Cc: linux@weissschuh.net, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 03/10] tools/nolibc: Add basic ELF self-relocation support for static PIE
Date: Sat, 7 Feb 2026 16:49:34 +0100	[thread overview]
Message-ID: <aYdfDv4jU4yqYI2h@1wt.eu> (raw)
In-Reply-To: <20260204124542.523567-4-daniel@thingy.jp>

On Wed, Feb 04, 2026 at 09:45:35PM +0900, Daniel Palmer wrote:
> Currently nolibc programs cannot be compiled with -static-pie.
> Which is basically no shared libraries, no interpreter, but contain
> relocation information in the ELF to allow the program to be fixed
> up to run at the address that the kernel loaded it to.
> 
> There might be other use cases for static PIE but mine is for nommu.
> The ELF FDPIC loader can actually load normal ELFs is long as they
> can be relocated.
> 
> This very basic implementation does the following:
> 
> - Works out if we are PIE and need to be relocated. ELF type == ET_DYN
> - Works out if we are static PIE, have no interpreter, and need to
>   relocate ourselves.
> - Calculates the base address using the ELF program header address
>   given to us by the kernel and the size of the ELF header that
>   should be directly above.
> - Finds the ELF relocation data.
> - Calls an arch specific function to handle each of the relocations.
> 
> Note that from testing a lot of archs don't produce static PIE
> binaries with the -static-pie option and you need to compile with
> -pie -Wl,--no-dynamic-linker to get a static PIE binary.
> 
> Currently REL and RELA formats are supported.

So we're clearly past my knowledge of these things and will have to
trust you :-)

One thing however, please keep in mind that all your _relocate and
__relocate* functions will be visible from userland code and as such
should be prefixed with "_nolibc" (or even __nolibc) to prevent name
conflicts. It's a particular effort we have to do that is caused by
the lib's design consisting only in include files: nothing at all
is private.

Willy

  reply	other threads:[~2026-02-07 15:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04 12:45 [RFC PATCH v2 00/10] nolibc: Add static-pie support Daniel Palmer
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 [this message]
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=aYdfDv4jU4yqYI2h@1wt.eu \
    --to=w@1wt.eu \
    --cc=daniel@thingy.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    /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