Re: [for-next][PATCH 1/3] sorttable: Move ELF parsing into scripts/elf-parse.[ch]

From: Nicolas Schier
Date: Thu Aug 28 2025 - 15:04:23 EST


On Thu, Aug 28, 2025 at 02:27:55PM -0400, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@xxxxxxxxxxx>
>
> In order to share the elf parsing that is in sorttable.c so that other
> programs could use the same code, move it into elf-parse.c and
> elf-parse.h.
>
> Cc: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> Cc: Mark Rutland <mark.rutland@xxxxxxx>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Arnd Bergmann <arnd@xxxxxxxx>
> Cc: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> Cc: Nathan Chancellor <nathan@xxxxxxxxxx>
> Cc: Nicolas Schier <nicolas.schier@xxxxxxxxx>
> Cc: Nick Desaulniers <nick.desaulniers+lkml@xxxxxxxxx>
> Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Cc: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> Link: https://lore.kernel.org/20250825231355.597630284@xxxxxxxxxx
> Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
> ---
> scripts/Makefile | 3 +
> scripts/Makefile.vmlinux | 2 +
> scripts/elf-parse.c | 198 ++++++++++++++++
> scripts/elf-parse.h | 305 +++++++++++++++++++++++++
> scripts/sorttable.c | 477 +++------------------------------------
> 5 files changed, 542 insertions(+), 443 deletions(-)
> create mode 100644 scripts/elf-parse.c
> create mode 100644 scripts/elf-parse.h
>
> diff --git a/scripts/Makefile b/scripts/Makefile
> index 46f860529df5..f19624b3ed92 100644
> --- a/scripts/Makefile
> +++ b/scripts/Makefile
> @@ -12,6 +12,8 @@ hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
> hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_builder
> hostprogs-always-$(CONFIG_RUST_KERNEL_DOCTESTS) += rustdoc_test_gen
>
> +sorttable-objs := sorttable.o elf-parse.o
> +
> ifneq ($(or $(CONFIG_X86_64),$(CONFIG_X86_32)),)
> always-$(CONFIG_RUST) += target.json
> filechk_rust_target = $< < include/config/auto.conf
> @@ -25,6 +27,7 @@ generate_rust_target-rust := y
> rustdoc_test_builder-rust := y
> rustdoc_test_gen-rust := y
>
> +HOSTCFLAGS_elf-parse.o = -I$(srctree)/tools/include
> HOSTCFLAGS_sorttable.o = -I$(srctree)/tools/include
> HOSTLDLIBS_sorttable = -lpthread
> HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
> diff --git a/scripts/Makefile.vmlinux b/scripts/Makefile.vmlinux
> index b64862dc6f08..ebbb8b5aca83 100644
> --- a/scripts/Makefile.vmlinux
> +++ b/scripts/Makefile.vmlinux
> @@ -97,6 +97,8 @@ ifdef CONFIG_BUILDTIME_TABLE_SORT
> $(vmlinux-final): scripts/sorttable
> endif
>
> +.PRECIOUS: $(vmlinux-final)

Why do you need '.PRECIOUS' here? Does its need match to Masahiros
explanations in
https://git.kernel.org/torvalds/c/875ef1a57f32fcb91010dc9bc8bd1166956a579e

Kind regards,
Nicolas