mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vasily Gorbik <gor@linux.ibm.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>,
	Michal Marek <michal.lkml@markovi.net>
Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org
Subject: [PATCH] kbuild: add Map option to save vmlinux linker map file(s)
Date: Mon, 6 Aug 2018 15:38:56 +0200	[thread overview]
Message-ID: <patch.git-39444503b4d3.your-ad-here.call-01533562662-ext-6094@work.hours> (raw)

Add "Map" kbuild option, so that "make Map=1" would save vmlinux linker
map into vmlinux.map, which is quite useful during making kernel changes
related to how the kernel is composed.

KBUILD_SAVE_LINK_MAP flag is exported and architectures
supporting compressed kernel images might respect it and produce
arch/*/boot/compressed/vmlinux.map for the decompressor code as well.

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
---
 .gitignore |  1 +
 Makefile   | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/.gitignore b/.gitignore
index 97ba6b79834c..1d2308e597ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,6 +44,7 @@
 *.xz
 Module.symvers
 modules.builtin
+vmlinux.map
 
 #
 # Top-level generic files
diff --git a/Makefile b/Makefile
index 7a3c4548162b..f1790deae03b 100644
--- a/Makefile
+++ b/Makefile
@@ -176,6 +176,14 @@ ifndef KBUILD_CHECKSRC
   KBUILD_CHECKSRC = 0
 endif
 
+# Use 'make Map=1' to enable saving linker map file(s):
+# vmlinux.map for vmlinux,
+# (arch/*/boot/compressed/vmlinux.map for arch/*/boot/compressed/vmlinux)
+
+ifeq ("$(origin Map)", "command line")
+	export KBUILD_SAVE_LINK_MAP := $(Map)
+endif
+
 # Use make M=dir to specify directory of external module to build
 # Old syntax make ... SUBDIRS=$PWD is still supported
 # Setting the environment variable KBUILD_EXTMOD take precedence
@@ -838,6 +846,11 @@ ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
 LDFLAGS_vmlinux	+= $(call ld-option, -X,)
 endif
 
+ifdef KBUILD_SAVE_LINK_MAP
+LDFLAGS_vmlinux	+= -Map=vmlinux.map
+CLEAN_FILES	+= vmlinux.map
+endif
+
 # insure the checker run with the right endianness
 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
 
@@ -1434,6 +1447,7 @@ help:
 	@echo  '		2: warnings which occur quite often but may still be relevant'
 	@echo  '		3: more obscure warnings, can most likely be ignored'
 	@echo  '		Multiple levels can be combined with W=12 or W=123'
+	@echo  '  make Map=1 [targets] Save vmlinux linker map file(s)'
 	@echo  ''
 	@echo  'Execute "make" or "make all" to build all targets marked with [*] '
 	@echo  'For further info see the ./README file'
-- 
2.18.0.13.gd42ae10


             reply	other threads:[~2018-08-06 13:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-06 13:38 Vasily Gorbik [this message]
2018-08-09  4:58 ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=patch.git-39444503b4d3.your-ad-here.call-01533562662-ext-6094@work.hours \
    --to=gor@linux.ibm.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®