mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Daniel Palmer <daniel@thingy.jp>
Cc: linux@weissschuh.net, kees@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 5/9] tools/nolibc: x86: Add relocation support for x86_64
Date: Sun, 1 Feb 2026 18:56:37 +0100	[thread overview]
Message-ID: <aX-T1b-rL_vhxAOF@1wt.eu> (raw)
In-Reply-To: <20260131074440.732588-6-daniel@thingy.jp>

Hi Daniel,

On Sat, Jan 31, 2026 at 04:44:36PM +0900, Daniel Palmer wrote:
> Add relocation support for x86, both 32bit and 64bit.
> 
> Signed-off-by: Daniel Palmer <daniel@thingy.jp>
> ---
>  tools/include/nolibc/arch-x86.h | 35 +++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/tools/include/nolibc/arch-x86.h b/tools/include/nolibc/arch-x86.h
> index f6c43ac5377b..3639c1104e0d 100644
> --- a/tools/include/nolibc/arch-x86.h
> +++ b/tools/include/nolibc/arch-x86.h
> @@ -7,8 +7,17 @@
>  #ifndef _NOLIBC_ARCH_X86_H
>  #define _NOLIBC_ARCH_X86_H
>  
> +#define NOLIBC_ARCH_HAS_RELOC
> +#if !defined(__x86_64__)
> +#define NOLIBC_ARCH_ELF32
> +#define NOLIBC_ARCH_ELF_REL
> +#elif defined(__x86_64__) && defined(__ILP32__)
> +#define NOLIBC_ARCH_ELF32
> +#endif
> +
>  #include "compiler.h"
>  #include "crt.h"
> +#include "elf.h"
>  
>  #if !defined(__x86_64__)
>  
> @@ -158,6 +167,19 @@
>  })
>  
>  #ifndef NOLIBC_NO_RUNTIME
> +static int __relocate_rel(unsigned long base, elf_rel *entry)
> +{
> +	switch (elf_r_type(entry->r_info)) {
> +	case R_386_RELATIVE:
> +		__relocate_rel_relative(base, entry);
> +		break;
> +	default:
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +
>  /* startup code */
>  /*
>   * i386 System V ABI mandates:
> @@ -326,6 +348,19 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
>  })
>  
>  #ifndef NOLIBC_NO_RUNTIME
> +static int __relocate_rela(unsigned long base, elf_rela *entry)
> +{
> +	switch (elf_r_type(entry->r_info)) {
> +	case R_AMD64_RELATIVE:

This needs to be conditioned to the definition of this macro, because
now building with the patched nolibc against older UAPI headers just
breaks the build:

../../../include/nolibc/arch-x86.h: In function '__relocate_rela':
../../../include/nolibc/arch-x86.h:354:14: error: 'R_AMD64_RELATIVE' undeclared (first use in this function)
  354 |         case R_AMD64_RELATIVE:
      |              ^~~~~~~~~~~~~~~~

We always take care of keeping support for still maintained kernels, so
right now it's important that uapi headers from 5.10 continue to produce
code that builds and works (which is still the case before the patch).

Willy

  reply	other threads:[~2026-02-01 17:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=aX-T1b-rL_vhxAOF@1wt.eu \
    --to=w@1wt.eu \
    --cc=daniel@thingy.jp \
    --cc=kees@kernel.org \
    --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

Powered by JetHome