mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Daniel Palmer <daniel@thingy.jp>
Cc: w@1wt.eu, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 04/10] tools/nolibc: m68k: Add relocation support
Date: Mon, 16 Feb 2026 21:51:19 +0100	[thread overview]
Message-ID: <313ca312-b3ff-4f3e-8fe1-22e85fa29e04@t-8ch.de> (raw)
In-Reply-To: <20260204124542.523567-5-daniel@thingy.jp>

On 2026-02-04 21:45:36+0900, Daniel Palmer wrote:
> Add support for handling relocations on m68k.
> 
> This also changes the branch to _start_c to be relative.
> This might break FLAT binaries so needs to be checked
> and probably wrapped in some #ifdef .. magic.

You are the expert here, so some more definitive answer to this question
would be nice :-)

> Signed-off-by: Daniel Palmer <daniel@thingy.jp>
> ---
>  tools/include/nolibc/arch-m68k.h | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/include/nolibc/arch-m68k.h b/tools/include/nolibc/arch-m68k.h
> index 2a4fbada5e79..e82ff48d3fb8 100644
> --- a/tools/include/nolibc/arch-m68k.h
> +++ b/tools/include/nolibc/arch-m68k.h
> @@ -10,8 +10,16 @@
>  #ifndef _NOLIBC_ARCH_M68K_H
>  #define _NOLIBC_ARCH_M68K_H
>  
> +#include "elf.h"
> +
> +#ifdef R_68K_RELATIVE
> +#define _NOLIBC_ARCH_HAS_RELOC
> +#define _NOLIBC_ARCH_ELF32
> +#endif
> +
>  #include "compiler.h"
>  #include "crt.h"
> +#include "reloc.h"
>  
>  #define _NOLIBC_SYSCALL_CLOBBERLIST "memory"
>  
> @@ -129,12 +137,29 @@
>  })
>  
>  #ifndef NOLIBC_NO_RUNTIME
> +
> +#ifdef NOLIBC_WANT_RELOC
> +static __inline__ int __relocate_rela(unsigned long base, _nolibc_elf_rela *entry)
> +{
> +	switch (_nolibc_elf_r_type(entry->r_info)) {
> +	case R_68K_RELATIVE:

It seems there is only ever a single relocation used per architecture.
So wouldn't it be possible to do something like this:

#define _NOLIBC_ARCH_HAS_RELOC
#define _NOLIBC_ARCH_RELA_RELOC R_68K_RELATIVE

This keeps the per-architecture code simpler and removes the ugly
'ifdef R_68K_RELATIVE'. The code will break if somebody actually tries
to build a static pie using old uapi headers, but then this has never
worked before anyways.

> +		__relocate_rela_relative(base, entry);
> +		break;
> +	default:
> +		return -1;
> +	}
> +
> +	return 0;
> +}
> +#endif /* NOLIBC_WANT_RELOC */
> +
>  void _start(void);
>  void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
>  {
>  	__asm__ volatile (
>  		"movel %sp, %sp@-\n"
> -		"jsr _start_c\n"
> +		"lea _start_c(%pc), %a0\n"
> +		"jsr (%a0)\n"
>  	);
>  	__nolibc_entrypoint_epilogue();
>  }
> -- 
> 2.51.0
> 

  reply	other threads:[~2026-02-16 20:51 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
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 [this message]
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=313ca312-b3ff-4f3e-8fe1-22e85fa29e04@t-8ch.de \
    --to=linux@weissschuh.net \
    --cc=daniel@thingy.jp \
    --cc=linux-kernel@vger.kernel.org \
    --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®