rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: kbuild: Don't export __pfx symbols
@ 2025-03-18 23:18 Sami Tolvanen
  2025-03-19 12:06 ` Alice Ryhl
  2025-04-08 19:50 ` Miguel Ojeda
  0 siblings, 2 replies; 3+ messages in thread
From: Sami Tolvanen @ 2025-03-18 23:18 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross
  Cc: Sami Tolvanen, rust-for-linux, linux-kernel

With CONFIG_PREFIX_SYMBOLS, objtool adds __pfx prefix symbols
to claim the compiler emitted call padding bytes. When
CONFIG_X86_KERNEL_IBT is not selected, the symbols are added to
individual object files and for Rust objects, they end up being
exported, resulting in warnings with CONFIG_GENDWARFKSYMS as the
symbols have no debugging information:

warning: gendwarfksyms: symbol_print_versions: no information for symbol __pfx_rust_helper_put_task_struct
warning: gendwarfksyms: symbol_print_versions: no information for symbol __pfx_rust_helper_task_euid
warning: gendwarfksyms: symbol_print_versions: no information for symbol __pfx_rust_helper_readq_relaxed
...

Filter out the __pfx prefix from exported symbols similarly to
the existing __cfi and __odr_asan prefixes.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
 rust/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/Makefile b/rust/Makefile
index ea3849eb78f6..eb18b59d4f39 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -332,7 +332,7 @@ $(obj)/bindings/bindings_helpers_generated.rs: private bindgen_target_extra = ;
 $(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers/helpers.c FORCE
 	$(call if_changed_dep,bindgen)
 
-rust_exports = $(NM) -p --defined-only $(1) | awk '$$2~/(T|R|D|B)/ && $$3!~/__cfi/ && $$3!~/__odr_asan/ { printf $(2),$$3 }'
+rust_exports = $(NM) -p --defined-only $(1) | awk '$$2~/(T|R|D|B)/ && $$3!~/__(pfx|cfi|odr_asan)/ { printf $(2),$$3 }'
 
 quiet_cmd_exports = EXPORTS $@
       cmd_exports = \
-- 
2.49.0.rc1.451.g8f38331e32-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: kbuild: Don't export __pfx symbols
  2025-03-18 23:18 [PATCH] rust: kbuild: Don't export __pfx symbols Sami Tolvanen
@ 2025-03-19 12:06 ` Alice Ryhl
  2025-04-08 19:50 ` Miguel Ojeda
  1 sibling, 0 replies; 3+ messages in thread
From: Alice Ryhl @ 2025-03-19 12:06 UTC (permalink / raw)
  To: Sami Tolvanen
  Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, rust-for-linux, linux-kernel

On Tue, Mar 18, 2025 at 11:18:16PM +0000, Sami Tolvanen wrote:
> With CONFIG_PREFIX_SYMBOLS, objtool adds __pfx prefix symbols
> to claim the compiler emitted call padding bytes. When
> CONFIG_X86_KERNEL_IBT is not selected, the symbols are added to
> individual object files and for Rust objects, they end up being
> exported, resulting in warnings with CONFIG_GENDWARFKSYMS as the
> symbols have no debugging information:
> 
> warning: gendwarfksyms: symbol_print_versions: no information for symbol __pfx_rust_helper_put_task_struct
> warning: gendwarfksyms: symbol_print_versions: no information for symbol __pfx_rust_helper_task_euid
> warning: gendwarfksyms: symbol_print_versions: no information for symbol __pfx_rust_helper_readq_relaxed
> ...
> 
> Filter out the __pfx prefix from exported symbols similarly to
> the existing __cfi and __odr_asan prefixes.
> 
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] rust: kbuild: Don't export __pfx symbols
  2025-03-18 23:18 [PATCH] rust: kbuild: Don't export __pfx symbols Sami Tolvanen
  2025-03-19 12:06 ` Alice Ryhl
@ 2025-04-08 19:50 ` Miguel Ojeda
  1 sibling, 0 replies; 3+ messages in thread
From: Miguel Ojeda @ 2025-04-08 19:50 UTC (permalink / raw)
  To: Sami Tolvanen
  Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, rust-for-linux, linux-kernel

On Wed, Mar 19, 2025 at 12:18 AM Sami Tolvanen <samitolvanen@google.com> wrote:
>
> With CONFIG_PREFIX_SYMBOLS, objtool adds __pfx prefix symbols
> to claim the compiler emitted call padding bytes. When
> CONFIG_X86_KERNEL_IBT is not selected, the symbols are added to
> individual object files and for Rust objects, they end up being
> exported, resulting in warnings with CONFIG_GENDWARFKSYMS as the
> symbols have no debugging information:
>
> warning: gendwarfksyms: symbol_print_versions: no information for symbol __pfx_rust_helper_put_task_struct
> warning: gendwarfksyms: symbol_print_versions: no information for symbol __pfx_rust_helper_task_euid
> warning: gendwarfksyms: symbol_print_versions: no information for symbol __pfx_rust_helper_readq_relaxed
> ...
>
> Filter out the __pfx prefix from exported symbols similarly to
> the existing __cfi and __odr_asan prefixes.
>
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

Applied to `rust-fixes` -- thanks everyone!

It also gets rid of a lot of `modpost` warnings too at link time.

    Cc: stable@vger.kernel.org
    Fixes: ac61506bf2d1 ("rust: Use gendwarfksyms + extended
modversions for CONFIG_MODVERSIONS")

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-08 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 23:18 [PATCH] rust: kbuild: Don't export __pfx symbols Sami Tolvanen
2025-03-19 12:06 ` Alice Ryhl
2025-04-08 19:50 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).