kbuild: add CONFIG_VMLINUX_MAP expert option
Subsystems (3)
PATCH 1/1 kbuild: add CONFIG_VMLINUX_MAP expert option
It can be quite useful to have ld emit a link map file, in order to debug or verify that special sections end up where they are supposed to, and to see what LD_DEAD_CODE_DATA_ELIMINATION manages to get rid of.
The only reason I'm not just adding this unconditionally is 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. Also hide the prompt behind CONFIG_EXPERT.
--- .gitignore | 1 + Makefile | 3 ++- lib/Kconfig.debug | 9 +++++++++ scripts/link-vmlinux.sh | 9 +++++++++ 4 files changed, 21 insertions(+), 1 deletion(-)
.gitignore +1 -0
@@ -58,6 +58,7 @@ modules.order /TAGS /linux /vmlinux +/vmlinux.map /vmlinux.32 /vmlinux.symvers /vmlinux-gdb.py
Makefile +2 -1
@@ -1501,7 +1501,8 @@ endif # CONFIG_MODULES # Directories & files removed with 'make clean' CLEAN_FILES += include/ksym vmlinux.symvers \ modules.builtin modules.builtin.modinfo modules.nsdeps \ - compile_commands.json + compile_commands.json \ + vmlinux.map # Directories & files removed with 'make mrproper' MRPROPER_FILES += include/config include/generated \
lib/Kconfig.debug +9 -0
@@ -412,6 +412,15 @@ config VMLINUX_VALIDATION depends on STACK_VALIDATION && DEBUG_ENTRY && !PARAVIRT default y +config VMLINUX_MAP + bool "Generate vmlinux.map file when linking" if EXPERT + help + Selecting this option will pass "-Map=vmlinux.map" to ld + when linking vmlinux. That file can be useful for verifying + and debugging magic section games, and for seeing which + pieces of code get eliminated with + CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. + config DEBUG_FORCE_WEAK_PER_CPU bool "Force weak per-cpu definitions" depends on DEBUG_KERNEL
scripts/link-vmlinux.sh +9 -0
@@ -166,6 +166,12 @@ vmlinux_link() strip_debug=-Wl,--strip-debug fi + if [ -n "${CONFIG_VMLINUX_MAP}" ]; then + map_option="-Map=${output}.map" + else + map_option="" + fi + if [ "${SRCARCH}" != "um" ]; then if [ -n "${CONFIG_LTO_CLANG}" ]; then # Use vmlinux.o instead of performing the slow LTO
@@ -187,6 +193,7 @@ vmlinux_link() ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \ ${strip_debug#-Wl,} \ -o ${output} \ + ${map_option} \ -T ${lds} ${objects} else objects="-Wl,--whole-archive \
@@ -200,6 +207,7 @@ vmlinux_link() ${CC} ${CFLAGS_vmlinux} \ ${strip_debug} \ -o ${output} \ + ${map_option:+-Wl,${map_option}} \ -Wl,-T,${lds} \ ${objects} \ -lutil -lrt -lpthread
@@ -303,6 +311,7 @@ cleanup() rm -f .tmp_vmlinux* rm -f System.map rm -f vmlinux + rm -f vmlinux.map rm -f vmlinux.o }
Signature · 1 line
2.29.2
Quoted 9 lines · Rasmus Villemoes
It can be quite useful to have ld emit a link map file, in order to debug or verify that special sections end up where they are supposed to, and to see what
LD_DEAD_CODE_DATA_ELIMINATIONmanages to get rid of.The only reason I'm not just adding this unconditionally is 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. Also hide the prompt behind
CONFIG_EXPERT.
ping
Quoted 24 lines · Rasmus Villemoes
It can be quite useful to have ld emit a link map file, in order to debug or verify that special sections end up where they are supposed to, and to see what
LD_DEAD_CODE_DATA_ELIMINATIONmanages to get rid of.The only reason I'm not just adding this unconditionally is 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. Also hide the prompt behind
CONFIG_EXPERT.Signed-off-by Rasmus Villemoes <[email protected]>--- .gitignore | 1 + Makefile | 3 ++- lib/Kconfig.debug | 9 +++++++++ scripts/link-vmlinux.sh | 9 +++++++++ 4 files changed, 21 insertions(+), 1 deletion(-).gitignore +0
-0
.gitignore modules.order · line 61
Quoted 4 lines
.gitignore +1
-0@@ -58,6 +58,7 @@ modules.order /TAGS /linux /vmlinux +/vmlinux.map
Could you move this one line below
so that vmlinux.map is placed between
vmlinux.32 and vmlinux.symvers ?
I know this list is not sorted...
.gitignore modules.order · line 64
Quoted 3 lines
.gitignore +0
-0/vmlinux.32 /vmlinux.symvers /vmlinux-gdb.py
Please add this to Documentation/dontdiff as well.
Makefile endif # CONFIG_MODULES · line 1505
Quoted 11 lines
Makefile +2
-1@@ -1501,7 +1501,8 @@ endif # CONFIG_MODULES # Directories & files removed with 'make clean' CLEAN_FILES += include/ksym vmlinux.symvers \ modules.builtin modules.builtin.modinfo modules.nsdeps \ - compile_commands.json + compile_commands.json \ + vmlinux.map
Do you need this ?
You already added this to cleanup() of scripts/link-vmlinux.sh, which is invoked from 'make clean'.
lib/Kconfig.debug config VMLINUX_VALIDATION · line 416
Quoted 12 lines
Makefile +0
-0# Directories & files removed with 'make mrproper' MRPROPER_FILES += include/config include/generated \lib/Kconfig.debug +2
-0@@ -412,6 +412,15 @@ config VMLINUX_VALIDATION depends on STACK_VALIDATION && DEBUG_ENTRY && !PARAVIRT default y +config VMLINUX_MAP + bool "Generate vmlinux.map file when linking" if EXPERT
Please use depends on EXPERT
because VMLINUX_MAP is not select or implied by anyone.
Quoted 15 lines
lib/Kconfig.debug +7
-0+ help + Selecting this option will pass "-Map=vmlinux.map" to ld + when linking vmlinux. That file can be useful for verifying + and debugging magic section games, and for seeing which + pieces of code get eliminated with + CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. + config DEBUG_FORCE_WEAK_PER_CPU bool "Force weak per-cpu definitions" depends on DEBUG_KERNELscripts/link-vmlinux.sh +0
-0
scripts/link-vmlinux.sh vmlinux_link() · line 174
Quoted 9 lines
scripts/link-vmlinux.sh +6
-0@@ -166,6 +166,12 @@ vmlinux_link() strip_debug=-Wl,--strip-debug fi + if [ -n "${CONFIG_VMLINUX_MAP}" ]; then + map_option="-Map=${output}.map" + else + map_option="" + fi +
For consistency, please do like strip_debug, that is, define this as a local variable, and
set the value of the 'if' case.
Quoted 30 lines
scripts/link-vmlinux.sh +3
-1if [ "${SRCARCH}" != "um" ]; then if [ -n "${CONFIG_LTO_CLANG}" ]; then # Use vmlinux.o instead of performing the slow LTO@@ -187,6 +193,7 @@ vmlinux_link() ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \ ${strip_debug#-Wl,} \ -o ${output} \ + ${map_option} \ -T ${lds} ${objects} else objects="-Wl,--whole-archive \@@ -200,6 +207,7 @@ vmlinux_link() ${CC} ${CFLAGS_vmlinux} \ ${strip_debug} \ -o ${output} \ + ${map_option:+-Wl,${map_option}} \ -Wl,-T,${lds} \ ${objects} \ -lutil -lrt -lpthread@@ -303,6 +311,7 @@ cleanup() rm -f .tmp_vmlinux* rm -f System.map rm -f vmlinux + rm -f vmlinux.map rm -f vmlinux.o } --2.29.2
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH v2 1/1 kbuild: add CONFIG_VMLINUX_MAP expert option
It can be quite useful to have ld emit a link map file, in order to debug or verify that special sections end up where they are supposed to, and to see what LD_DEAD_CODE_DATA_ELIMINATION manages to get rid of.
The only reason I'm not just adding this unconditionally is 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. Also make it depend on CONFIG_EXPERT.
--- .gitignore | 1 + Documentation/dontdiff | 1 + lib/Kconfig.debug | 10 ++++++++++ scripts/link-vmlinux.sh | 8 ++++++++ 4 files changed, 20 insertions(+)
.gitignore +1 -0
@@ -59,6 +59,7 @@ modules.order /linux /vmlinux /vmlinux.32 +/vmlinux.map /vmlinux.symvers /vmlinux-gdb.py /vmlinuz
Documentation/dontdiff +1 -0
@@ -252,6 +252,7 @@ vmlinux-* vmlinux.aout vmlinux.bin.all vmlinux.lds +vmlinux.map vmlinux.symvers vmlinuz voffset.h
lib/Kconfig.debug +10 -0
@@ -412,6 +412,16 @@ config VMLINUX_VALIDATION depends on STACK_VALIDATION && DEBUG_ENTRY && !PARAVIRT default y +config VMLINUX_MAP + bool "Generate vmlinux.map file when linking" + depends on EXPERT + help + Selecting this option will pass "-Map=vmlinux.map" to ld + when linking vmlinux. That file can be useful for verifying + and debugging magic section games, and for seeing which + pieces of code get eliminated with + CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. + config DEBUG_FORCE_WEAK_PER_CPU bool "Force weak per-cpu definitions" depends on DEBUG_KERNEL
scripts/link-vmlinux.sh +8 -0
@@ -155,6 +155,7 @@ vmlinux_link() local output=${1} local objects local strip_debug + local map_option info LD ${output}
@@ -166,6 +167,10 @@ vmlinux_link() strip_debug=-Wl,--strip-debug fi + if [ -n "${CONFIG_VMLINUX_MAP}" ]; then + map_option="-Map=${output}.map" + fi + if [ "${SRCARCH}" != "um" ]; then if [ -n "${CONFIG_LTO_CLANG}" ]; then # Use vmlinux.o instead of performing the slow LTO
@@ -187,6 +192,7 @@ vmlinux_link() ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \ ${strip_debug#-Wl,} \ -o ${output} \ + ${map_option} \ -T ${lds} ${objects} else objects="-Wl,--whole-archive \
@@ -200,6 +206,7 @@ vmlinux_link() ${CC} ${CFLAGS_vmlinux} \ ${strip_debug} \ -o ${output} \ + ${map_option:+-Wl,${map_option}} \ -Wl,-T,${lds} \ ${objects} \ -lutil -lrt -lpthread
@@ -303,6 +310,7 @@ cleanup() rm -f .tmp_vmlinux* rm -f System.map rm -f vmlinux + rm -f vmlinux.map rm -f vmlinux.o }
Signature · 1 line
2.29.2
Quoted 6 lines · Rasmus Villemoes
It can be quite useful to have ld emit a link map file, in order to debug or verify that special sections end up where they are supposed to, and to see what
LD_DEAD_CODE_DATA_ELIMINATIONmanages to get rid of.
Quoted 7 lines
The only reason I'm not just adding this unconditionally is 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. Also make it depend on
CONFIG_EXPERT.Signed-off-by Rasmus Villemoes <[email protected]>---
Applied to linux-kbuild.
Thanks.
Quoted 99 lines
.gitignore | 1 + Documentation/dontdiff | 1 + lib/Kconfig.debug | 10 ++++++++++ scripts/link-vmlinux.sh | 8 ++++++++ 4 files changed, 20 insertions(+).gitignore +1
-0@@ -59,6 +59,7 @@ modules.order /linux /vmlinux /vmlinux.32 +/vmlinux.map /vmlinux.symvers /vmlinux-gdb.py /vmlinuzDocumentation/dontdiff +1
-0@@ -252,6 +252,7 @@ vmlinux-* vmlinux.aout vmlinux.bin.all vmlinux.lds +vmlinux.map vmlinux.symvers vmlinuz voffset.hlib/Kconfig.debug +10
-0@@ -412,6 +412,16 @@ config VMLINUX_VALIDATION depends on STACK_VALIDATION && DEBUG_ENTRY && !PARAVIRT default y +config VMLINUX_MAP + bool "Generate vmlinux.map file when linking" + depends on EXPERT + help + Selecting this option will pass "-Map=vmlinux.map" to ld + when linking vmlinux. That file can be useful for verifying + and debugging magic section games, and for seeing which + pieces of code get eliminated with + CONFIG_LD_DEAD_CODE_DATA_ELIMINATION. + config DEBUG_FORCE_WEAK_PER_CPU bool "Force weak per-cpu definitions" depends on DEBUG_KERNELscripts/link-vmlinux.sh +8
-1@@ -155,6 +155,7 @@ vmlinux_link() local output=${1} local objects local strip_debug + local map_option info LD ${output}@@ -166,6 +167,10 @@ vmlinux_link() strip_debug=-Wl,--strip-debug fi + if [ -n "${CONFIG_VMLINUX_MAP}" ]; then + map_option="-Map=${output}.map" + fi + if [ "${SRCARCH}" != "um" ]; then if [ -n "${CONFIG_LTO_CLANG}" ]; then # Use vmlinux.o instead of performing the slow LTO@@ -187,6 +192,7 @@ vmlinux_link() ${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \ ${strip_debug#-Wl,} \ -o ${output} \ + ${map_option} \ -T ${lds} ${objects} else objects="-Wl,--whole-archive \@@ -200,6 +206,7 @@ vmlinux_link() ${CC} ${CFLAGS_vmlinux} \ ${strip_debug} \ -o ${output} \ + ${map_option:+-Wl,${map_option}} \ -Wl,-T,${lds} \ ${objects} \ -lutil -lrt -lpthread@@ -303,6 +310,7 @@ cleanup() rm -f .tmp_vmlinux* rm -f System.map rm -f vmlinux + rm -f vmlinux.map rm -f vmlinux.o } --
Quoted 2 lines
2.29.2
--
Best Regards
Masahiro Yamada