kbuild: link-vmlinux.sh: Make output file name configurable
authorArd Biesheuvel <ardb@kernel.org>
Tue, 11 Mar 2025 11:06:18 +0000 (12:06 +0100)
committerMasahiro Yamada <masahiroy@kernel.org>
Sun, 16 Mar 2025 15:29:45 +0000 (00:29 +0900)
In order to introduce an intermediate, non-stripped vmlinux build that
can be used by other build steps as an input, pass the output file name
to link-vmlinux.sh via its command line.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/Makefile.vmlinux
scripts/link-vmlinux.sh

index fb79fd6b246543d598e83c919f2dfcf349e58b5e..487f0bf716ad8523271913cb421249cf45cb2680 100644 (file)
@@ -69,7 +69,7 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
 
 # Final link of vmlinux with optional arch pass after final link
 cmd_link_vmlinux =                                                     \
-       $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)";            \
+       $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)" "$@";       \
        $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
 
 targets += vmlinux
index 96ae0bb65308a1803f67bc125487009cc1b95f1c..b3d928925598097efe937f46334ecefd25c5cfc3 100755 (executable)
@@ -31,6 +31,7 @@ set -e
 LD="$1"
 KBUILD_LDFLAGS="$2"
 LDFLAGS_vmlinux="$3"
+VMLINUX="$4"
 
 is_enabled() {
        grep -q "^$1=y" include/config/auto.conf
@@ -283,23 +284,23 @@ if is_enabled CONFIG_VMLINUX_MAP; then
        generate_map=1
 fi
 
-vmlinux_link vmlinux
+vmlinux_link "${VMLINUX}"
 
 # fill in BTF IDs
 if is_enabled CONFIG_DEBUG_INFO_BTF; then
-       info BTFIDS vmlinux
+       info BTFIDS "${VMLINUX}"
        RESOLVE_BTFIDS_ARGS=""
        if is_enabled CONFIG_WERROR; then
                RESOLVE_BTFIDS_ARGS=" --fatal_warnings "
        fi
-       ${RESOLVE_BTFIDS} ${RESOLVE_BTFIDS_ARGS} vmlinux
+       ${RESOLVE_BTFIDS} ${RESOLVE_BTFIDS_ARGS} "${VMLINUX}"
 fi
 
-mksysmap vmlinux System.map
+mksysmap "${VMLINUX}" System.map
 
 if is_enabled CONFIG_BUILDTIME_TABLE_SORT; then
-       info SORTTAB vmlinux
-       if ! sorttable vmlinux; then
+       info SORTTAB "${VMLINUX}"
+       if ! sorttable "${VMLINUX}"; then
                echo >&2 Failed to sort kernel tables
                exit 1
        fi
@@ -315,4 +316,4 @@ if is_enabled CONFIG_KALLSYMS; then
 fi
 
 # For fixdep
-echo "vmlinux: $0" > .vmlinux.d
+echo "${VMLINUX}: $0" > ".${VMLINUX}.d"