[PATCH 1/2] kbuild: add config option to save link map file(s)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add CONFIG_SAVE_LINK_MAP config option, which would make linker to save
link map to vmlinux.map file. Link map is quite useful during making
kernel changes related to how the kernel is composed and debugging
linker scripts. It also provides information about discarded sections
and symbols.

Architectures supporting compressed kernel images might respect
CONFIG_SAVE_LINK_MAP option and produce arch/*/boot/compressed/vmlinux.map
for the decompressor code as well.

Signed-off-by: Vasily Gorbik <gor@xxxxxxxxxxxxx>
---
 .gitignore        |  1 +
 Makefile          |  6 +++++-
 lib/Kconfig.debug | 13 +++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index d01cda8e1177..81ba7416a0b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,6 +48,7 @@
 Module.symvers
 modules.builtin
 modules.order
+vmlinux.map
 
 #
 # Top-level generic files
diff --git a/Makefile b/Makefile
index e71979882e4f..d35a59f98e83 100644
--- a/Makefile
+++ b/Makefile
@@ -984,6 +984,10 @@ ifeq ($(CONFIG_RELR),y)
 LDFLAGS_vmlinux	+= --pack-dyn-relocs=relr
 endif
 
+ifeq ($(CONFIG_SAVE_LINK_MAP),y)
+LDFLAGS_vmlinux	+= -Map=vmlinux.map
+endif
+
 # Align the bit size of userspace programs with the kernel
 KBUILD_USERCFLAGS  += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
 KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
@@ -1461,7 +1465,7 @@ endif # CONFIG_MODULES
 # make distclean Remove editor backup files, patch leftover files and the like
 
 # Directories & files removed with 'make clean'
-CLEAN_FILES += include/ksym vmlinux.symvers \
+CLEAN_FILES += include/ksym vmlinux.symvers vmlinux.map \
 	       modules.builtin modules.builtin.modinfo modules.nsdeps \
 	       compile_commands.json
 
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index d7a7bc3b6098..1ac4234ad879 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -363,6 +363,19 @@ config SECTION_MISMATCH_WARN_ONLY
 
 	  If unsure, say Y.
 
+config SAVE_LINK_MAP
+	bool "Save vmlinux link map file(s)"
+	default n
+	help
+	  If you say Y here, vmlinux link map will be saved into
+	  vmlinux.map. The link map is quite useful during making kernel
+	  changes related to how the kernel is composed and linker
+	  scripts debugging.
+
+	  In addition to that architectures supporting compressed kernel
+	  images might also produce arch/*/boot/compressed/vmlinux.map
+	  for the decompressor code as well.
+
 config DEBUG_FORCE_FUNCTION_ALIGN_32B
 	bool "Force all function address 32B aligned" if EXPERT
 	help
-- 
2.25.4




[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux