kbuild: do not generate .tmp_vmlinux*.map when CONFIG_VMLINUX_MAP=y
authorMasahiro Yamada <masahiroy@kernel.org>
Thu, 13 Mar 2025 10:26:03 +0000 (19:26 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sat, 15 Mar 2025 12:22:52 +0000 (21:22 +0900)
Commit 5cc124720461 ("kbuild: add CONFIG_VMLINUX_MAP expert option")
mentioned that "the .map file can be rather large (several MB), and
that's a waste of space when one isn't interested in these things."

If that is the case, generating map files for the intermediate
tmp_vmlinux* files is also a waste of space. It is unlikely that
anyone would be interested in the .tmp_vmlinux*.map files.

This commit stops passing the -Map= option when linking the .tmp_vmlinux*
intermediates.

I also hard-coded the file name 'vmlinux.map' instead of ${output}.map
because a later commit will introduce vmlinux.unstripped but I want to
keep the current name of the map file.

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

index 56a077d204cfa1b67609cf0ea4a8ebe5f5884f03..96ae0bb65308a1803f67bc125487009cc1b95f1c 100755 (executable)
@@ -97,8 +97,8 @@ vmlinux_link()
                ldflags="${ldflags} ${wl}--strip-debug"
        fi
 
-       if is_enabled CONFIG_VMLINUX_MAP; then
-               ldflags="${ldflags} ${wl}-Map=${output}.map"
+       if [ -n "${generate_map}" ];  then
+               ldflags="${ldflags} ${wl}-Map=vmlinux.map"
        fi
 
        ${ld} ${ldflags} -o ${output}                                   \
@@ -210,6 +210,7 @@ fi
 btf_vmlinux_bin_o=
 kallsymso=
 strip_debug=
+generate_map=
 
 if is_enabled CONFIG_KALLSYMS; then
        true > .tmp_vmlinux0.syms
@@ -278,6 +279,10 @@ fi
 
 strip_debug=
 
+if is_enabled CONFIG_VMLINUX_MAP; then
+       generate_map=1
+fi
+
 vmlinux_link vmlinux
 
 # fill in BTF IDs