public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Schier <nsc@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: Alexey Gladkov <legion@kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>,
	Alexander Potapenko <glider@google.com>,
	Andrey Konovalov <andreyknvl@gmail.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	kasan-dev@googlegroups.com,
	Charles Mirabile <cmirabil@redhat.com>
Subject: Re: [PATCH] kbuild: Use '--strip-unneeded-symbol' for removing module device table symbols
Date: Sat, 11 Oct 2025 10:12:54 +0200	[thread overview]
Message-ID: <aOoRhgzntzk2YKYP@levanger> (raw)
In-Reply-To: <20251010-kbuild-fix-mod-device-syms-reloc-err-v1-1-6dc88143af25@kernel.org>

On Fri, Oct 10, 2025 at 02:49:27PM -0700, Nathan Chancellor wrote:
> After commit 5ab23c7923a1 ("modpost: Create modalias for builtin
> modules"), relocatable RISC-V kernels with CONFIG_KASAN=y start failing
> when attempting to strip the module device table symbols:
> 
>   riscv64-linux-objcopy: not stripping symbol `__mod_device_table__kmod_irq_starfive_jh8100_intc__of__starfive_intc_irqchip_match_table' because it is named in a relocation
>   make[4]: *** [scripts/Makefile.vmlinux:97: vmlinux] Error 1
> 
> The relocation appears to come from .LASANLOC5 in .data.rel.local:
> 
>   $ llvm-objdump --disassemble-symbols=.LASANLOC5 --disassemble-all -r drivers/irqchip/irq-starfive-jh8100-intc.o
> 
>   drivers/irqchip/irq-starfive-jh8100-intc.o:   file format elf64-littleriscv
> 
>   Disassembly of section .data.rel.local:
> 
>   0000000000000180 <.LASANLOC5>:
>   ...
>        1d0: 0000          unimp
>                   00000000000001d0:  R_RISCV_64   __mod_device_table__kmod_irq_starfive_jh8100_intc__of__starfive_intc_irqchip_match_table
>   ...
> 
> This section appears to come from GCC for including additional
> information about global variables that may be protected by KASAN.
> 
> There appears to be no way to opt out of the generation of these symbols
> through either a flag or attribute. Attempting to remove '.LASANLOC*'
> with '--strip-symbol' results in the same error as above because these
> symbols may refer to (thus have relocation between) each other.
> 
> Avoid this build breakage by switching to '--strip-unneeded-symbol' for
> removing __mod_device_table__ symbols, as it will only remove the symbol
> when there is no relocation pointing to it. While this may result in a
> little more bloat in the symbol table in certain configurations, it is
> not as bad as outright build failures.
> 
> Fixes: 5ab23c7923a1 ("modpost: Create modalias for builtin modules")
> Reported-by: Charles Mirabile <cmirabil@redhat.com>
> Closes: https://lore.kernel.org/20251007011637.2512413-1-cmirabil@redhat.com/
> Suggested-by: Alexey Gladkov <legion@kernel.org>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> I am Cc'ing KASAN folks in case they have any additional knowledge
> around .LASANLOC symbols or how to remove/avoid them.
> 
> I plan to send this to Linus tomorrow.
> ---
>  scripts/Makefile.vmlinux | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Thanks!

Tested-by: Nicolas Schier <nsc@kernel.org>

      reply	other threads:[~2025-10-11  8:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-10 21:49 [PATCH] kbuild: Use '--strip-unneeded-symbol' for removing module device table symbols Nathan Chancellor
2025-10-11  8:12 ` Nicolas Schier [this message]

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=aOoRhgzntzk2YKYP@levanger \
    --to=nsc@kernel.org \
    --cc=andreyknvl@gmail.com \
    --cc=cmirabil@redhat.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=legion@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ryabinin.a.a@gmail.com \
    /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