* [PATCH] Kbuild: generate debug info in building
@ 2008-11-18 2:08 Wenji Huang
2008-11-22 11:43 ` Sam Ravnborg
0 siblings, 1 reply; 6+ messages in thread
From: Wenji Huang @ 2008-11-18 2:08 UTC (permalink / raw)
To: linux-kbuild
This patch will generate kernel debuginfo in Kbuild when invoking "make
debug_info". The separate debug files are in .debug under building tree.
They can help the cases of requiring debug info for tracing/debug tools,
especially cross-compilation. Moreover, it can simplify or standardize
the packaging process for the distributions those will provide
kernel-debuginfo.
Signed-off-by: Wenji Huang <wenji.huang@oracle.com>
---
Makefile | 14 ++++++++++++++
scripts/Makefile.modpost | 14 ++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
index 7f9ff9b..eed7510 100644
--- a/Makefile
+++ b/Makefile
@@ -814,6 +814,20 @@ define rule_vmlinux-modpost
$(Q)echo 'cmd_$@ := $(cmd_vmlinux-modpost)' > $(dot-target).cmd
endef
+ifdef CONFIG_DEBUG_INFO
+quiet_cmd_vmlinux_debug = GEN $<.debug
+ cmd_vmlinux_debug = mkdir -p .debug; \
+ $(OBJCOPY) --only-keep-debug \
+ $< .debug/$<.debug
+targets += vmlinux.debug
+endif
+
+debug_info: vmlinux FORCE
+ifdef CONFIG_DEBUG_INFO
+ $(call if_changed,vmlinux_debug)
+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@
+endif
+
# vmlinux image - including updated kernel symbols
vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o
$(kallsyms.o) FORCE
ifdef CONFIG_HEADERS_CHECK
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index f4053dc..0df73b2 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -137,6 +137,20 @@ $(modules): %.ko :%.o %.mod.o FORCE
targets += $(modules)
+modules-debug := $(modules:.ko=.ko.debug)
+ifdef CONFIG_DEBUG_INFO
+quiet_cmd_debug_ko = GEN $@
+ cmd_debug_ko = mkdir -p .debug/`dirname $@`; \
+ $(OBJCOPY) --only-keep-debug $< .debug/$@
+targets += $(modules-debug)
+endif
+
+debug_info: $(modules-debug) FORCE
+
+$(modules-debug): $(modules) FORCE
+ifdef CONFIG_DEBUG_INFO
+ $(call if_changed,debug_ko)
+endif
# Add FORCE to the prequisites of a target to force it to be always
rebuilt.
#
---------------------------------------------------------------------------
--
1.5.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Kbuild: generate debug info in building
2008-11-18 2:08 [PATCH] Kbuild: generate debug info in building Wenji Huang
@ 2008-11-22 11:43 ` Sam Ravnborg
2008-11-26 5:51 ` Wenji Huang
2009-01-13 3:13 ` Wenji Huang
0 siblings, 2 replies; 6+ messages in thread
From: Sam Ravnborg @ 2008-11-22 11:43 UTC (permalink / raw)
To: Wenji Huang; +Cc: linux-kbuild
On Tue, Nov 18, 2008 at 10:08:12AM +0800, Wenji Huang wrote:
> This patch will generate kernel debuginfo in Kbuild when invoking "make
> debug_info". The separate debug files are in .debug under building tree.
> They can help the cases of requiring debug info for tracing/debug tools,
> especially cross-compilation. Moreover, it can simplify or standardize
> the packaging process for the distributions those will provide
> kernel-debuginfo.
>
> Signed-off-by: Wenji Huang <wenji.huang@oracle.com>
Hi Wenji.
Can you tell a bit more why we need this?
I do not see anyone really asking for this.
Apart form the rationale why this is needed I have a few
comments to your patch.
Why do we need to hide this in a hidden directory?
> ---
> Makefile | 14 ++++++++++++++
> scripts/Makefile.modpost | 14 ++++++++++++++
> 2 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 7f9ff9b..eed7510 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -814,6 +814,20 @@ define rule_vmlinux-modpost
> $(Q)echo 'cmd_$@ := $(cmd_vmlinux-modpost)' > $(dot-target).cmd
> endef
>
> +ifdef CONFIG_DEBUG_INFO
> +quiet_cmd_vmlinux_debug = GEN $<.debug
> + cmd_vmlinux_debug = mkdir -p .debug; \
> + $(OBJCOPY) --only-keep-debug \
> + $< .debug/$<.debug
> +targets += vmlinux.debug
> +endif
There is no reason to use ifdef around the above definitions.
They are harmless is DEBUG_INFO is not defined and the ifdef makes
this file even less reaable.
> +
> +debug_info: vmlinux FORCE
> +ifdef CONFIG_DEBUG_INFO
> + $(call if_changed,vmlinux_debug)
> + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@
> +endif
You need to add a
PHONY += debug_info
> +
> # vmlinux image - including updated kernel symbols
> vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o
> $(kallsyms.o) FORCE
> ifdef CONFIG_HEADERS_CHECK
> diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
> index f4053dc..0df73b2 100644
> --- a/scripts/Makefile.modpost
> +++ b/scripts/Makefile.modpost
> @@ -137,6 +137,20 @@ $(modules): %.ko :%.o %.mod.o FORCE
>
> targets += $(modules)
>
> +modules-debug := $(modules:.ko=.ko.debug)
> +ifdef CONFIG_DEBUG_INFO
> +quiet_cmd_debug_ko = GEN $@
> + cmd_debug_ko = mkdir -p .debug/`dirname $@`; \
> + $(OBJCOPY) --only-keep-debug $< .debug/$@
> +targets += $(modules-debug)
> +endif
drop ifdef/endif
please see if you can use $(dir $@) instead of `dirname $@`
> +
> +debug_info: $(modules-debug) FORCE
> +
> +$(modules-debug): $(modules) FORCE
> +ifdef CONFIG_DEBUG_INFO
> + $(call if_changed,debug_ko)
> +endif
Why is only half of this block ifdeffed out?
>
> # Add FORCE to the prequisites of a target to force it to be always
> rebuilt.
> #
Sam
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Kbuild: generate debug info in building
2008-11-22 11:43 ` Sam Ravnborg
@ 2008-11-26 5:51 ` Wenji Huang
2009-01-13 3:13 ` Wenji Huang
1 sibling, 0 replies; 6+ messages in thread
From: Wenji Huang @ 2008-11-26 5:51 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux-kbuild, LKML, Randy Dunlap, ZANNONI,ELENA
Sam Ravnborg wrote:
> On Tue, Nov 18, 2008 at 10:08:12AM +0800, Wenji Huang wrote:
>> This patch will generate kernel debuginfo in Kbuild when invoking "make
>> debug_info". The separate debug files are in .debug under building tree.
>> They can help the cases of requiring debug info for tracing/debug tools,
>> especially cross-compilation. Moreover, it can simplify or standardize
>> the packaging process for the distributions those will provide
>> kernel-debuginfo.
>>
>> Signed-off-by: Wenji Huang <wenji.huang@oracle.com>
>
> Hi Wenji.
>
> Can you tell a bit more why we need this?
> I do not see anyone really asking for this.
Thanks for your comments. The debug info files are important to some
kernel tracing/debug tools, for example systemtap, crashdumps, etc.
We have several considerations:
* The debuginfo extracting machinery could be integrated into the
kbuild system. This way it's not just done via RPM macros. So
generating debuginfo RPMS or something alike can be simplified and
standardized, also distribution independent.
* Reduce the size of current file which mixes executable and
debug sections. Maybe cut the time of analysis for
elfutils/binutils which is used by some other tools.
>
> Apart form the rationale why this is needed I have a few
> comments to your patch.
Please see updated one.
Regards,
Wenji
diff --git a/Makefile b/Makefile
index 7b1f238..4151f53 100644
--- a/Makefile
+++ b/Makefile
@@ -814,6 +814,19 @@ define rule_vmlinux-modpost
$(Q)echo 'cmd_$@ := $(cmd_vmlinux-modpost)' > $(dot-target).cmd
endef
+quiet_cmd_vmlinux_debug = GEN $<.debug
+ cmd_vmlinux_debug = mkdir -p debug;
\
+ $(OBJCOPY) --only-keep-debug
\
+ $< debug/$<.debug
+targets += vmlinux.debug
+
+PHONY += debug_info
+debug_info: vmlinux FORCE
+ifdef CONFIG_DEBUG_INFO
+ $(call if_changed,vmlinux_debug)
+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@
+endif
+
# vmlinux image - including updated kernel symbols
vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o
$(kallsyms.o) FORCE
ifdef CONFIG_HEADERS_CHECK
@@ -1250,6 +1263,7 @@ help:
@echo ' all - Build all targets marked with [*]'
@echo '* vmlinux - Build the bare kernel'
@echo '* modules - Build all modules'
+ @echo ' debug_info - Generate debug info files in debug'
@echo ' modules_install - Install all modules to
INSTALL_MOD_PATH (default: /)'
@echo ' firmware_install- Install all firmware to
INSTALL_FW_PATH'
@echo ' (default:
$$(INSTALL_MOD_PATH)/lib/firmware)'
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index f4053dc..6e630e6 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -137,6 +137,18 @@ $(modules): %.ko :%.o %.mod.o FORCE
targets += $(modules)
+modules-debug := $(modules:.ko=.ko.debug)
+quiet_cmd_debug_ko = GEN $@
+ cmd_debug_ko = mkdir -p debug/$(dir $@); \
+ $(OBJCOPY) --only-keep-debug $< debug/$@
+targets += $(modules-debug)
+
+debug_info: $(modules-debug) FORCE
+
+ifdef CONFIG_DEBUG_INFO
+$(modules-debug): $(modules) FORCE
+ $(call if_changed,debug_ko)
+endif
# Add FORCE to the prequisites of a target to force it to be always
rebuilt.
#
---------------------------------------------------------------------------
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Kbuild: generate debug info in building
2008-11-22 11:43 ` Sam Ravnborg
2008-11-26 5:51 ` Wenji Huang
@ 2009-01-13 3:13 ` Wenji Huang
2009-01-13 3:23 ` Building error of 2.6.29-rc1 using old binutils Wenji Huang
1 sibling, 1 reply; 6+ messages in thread
From: Wenji Huang @ 2009-01-13 3:13 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux-kbuild, lkml
Hi,
I got the following building error for 2.6.29-rc1.
# make
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-x86
CALL scripts/checksyscalls.sh
CHK include/linux/compile.h
IHEX firmware/e100/d101m_ucode.bin
AS firmware/e100/d101m_ucode.bin.gen.o
IHEX firmware/e100/d101s_ucode.bin
AS firmware/e100/d101s_ucode.bin.gen.o
IHEX firmware/e100/d102e_ucode.bin
AS firmware/e100/d102e_ucode.bin.gen.o
LD firmware/built-in.o
LD vmlinux.o
MODPOST vmlinux.o
GEN .version
CHK include/linux/compile.h
UPD include/linux/compile.h
CC init/version.o
LD init/built-in.o
LD .tmp_vmlinux1
STRIP .tmp_vmlinux1.stripped
objcopy: unrecognized option `--strip-unneeded-symbols'
# objcopy --version
GNU objcopy 2.15.92.0.2 20040927
Copyright 2004 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms
of the GNU General Public License. This program has absolutely no warranty.
The option --strip-unneeded-symbols is only available on higher version,
but not exists on binutils-2.15.
Seems to keep Makefile compatible on all kinds of circumstances. Like,
quiet_cmd_kstrip = STRIP $@
cmd_kstrip = $(OBJCOPY) --wildcard $(addprefix --strip-symbols
,$(filter %/scripts/strip-symbols,$^)) $< $@
Regards,
Wenji
^ permalink raw reply [flat|nested] 6+ messages in thread
* Building error of 2.6.29-rc1 using old binutils
2009-01-13 3:13 ` Wenji Huang
@ 2009-01-13 3:23 ` Wenji Huang
2009-01-13 6:04 ` Wenji Huang
0 siblings, 1 reply; 6+ messages in thread
From: Wenji Huang @ 2009-01-13 3:23 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux-kbuild, lkml
Hi,
Sorry, resend it in terms of correct subject.
I got the following building error for 2.6.29-rc1.
# make
CHK include/linux/version.h
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-x86
CALL scripts/checksyscalls.sh
CHK include/linux/compile.h
IHEX firmware/e100/d101m_ucode.bin
AS firmware/e100/d101m_ucode.bin.gen.o
IHEX firmware/e100/d101s_ucode.bin
AS firmware/e100/d101s_ucode.bin.gen.o
IHEX firmware/e100/d102e_ucode.bin
AS firmware/e100/d102e_ucode.bin.gen.o
LD firmware/built-in.o
LD vmlinux.o
MODPOST vmlinux.o
GEN .version
CHK include/linux/compile.h
UPD include/linux/compile.h
CC init/version.o
LD init/built-in.o
LD .tmp_vmlinux1
STRIP .tmp_vmlinux1.stripped
objcopy: unrecognized option `--strip-unneeded-symbols'
# objcopy --version
GNU objcopy 2.15.92.0.2 20040927
Copyright 2004 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms
of the GNU General Public License. This program has absolutely no warranty.
The option --strip-unneeded-symbols is only available on higher version,
but not exists on binutils-2.15.
Seems to keep Makefile compatible on all kinds of circumstances. Like,
quiet_cmd_kstrip = STRIP $@
cmd_kstrip = $(OBJCOPY) --wildcard $(addprefix --strip-symbols
,$(filter %/scripts/strip-symbols,$^)) $< $@
Regards,
Wenji
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Building error of 2.6.29-rc1 using old binutils
2009-01-13 3:23 ` Building error of 2.6.29-rc1 using old binutils Wenji Huang
@ 2009-01-13 6:04 ` Wenji Huang
0 siblings, 0 replies; 6+ messages in thread
From: Wenji Huang @ 2009-01-13 6:04 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux-kbuild, lkml
Wenji Huang wrote:
> Hi,
>
> Sorry, resend it in terms of correct subject.
>
> I got the following building error for 2.6.29-rc1.
> # make
> CHK include/linux/version.h
> CHK include/linux/utsrelease.h
> SYMLINK include/asm -> include/asm-x86
> CALL scripts/checksyscalls.sh
> CHK include/linux/compile.h
> IHEX firmware/e100/d101m_ucode.bin
> AS firmware/e100/d101m_ucode.bin.gen.o
> IHEX firmware/e100/d101s_ucode.bin
> AS firmware/e100/d101s_ucode.bin.gen.o
> IHEX firmware/e100/d102e_ucode.bin
> AS firmware/e100/d102e_ucode.bin.gen.o
> LD firmware/built-in.o
> LD vmlinux.o
> MODPOST vmlinux.o
> GEN .version
> CHK include/linux/compile.h
> UPD include/linux/compile.h
> CC init/version.o
> LD init/built-in.o
> LD .tmp_vmlinux1
> STRIP .tmp_vmlinux1.stripped
> objcopy: unrecognized option `--strip-unneeded-symbols'
>
> # objcopy --version
> GNU objcopy 2.15.92.0.2 20040927
> Copyright 2004 Free Software Foundation, Inc.
> This program is free software; you may redistribute it under the terms
> of the GNU General Public License. This program has absolutely no
> warranty.
>
>
> The option --strip-unneeded-symbols is only available on higher version,
> but not exists on binutils-2.15.
>
> Seems to keep Makefile compatible on all kinds of circumstances. Like,
>
> quiet_cmd_kstrip = STRIP $@
> cmd_kstrip = $(OBJCOPY) --wildcard $(addprefix --strip-symbols
> ,$(filter %/scripts/strip-symbols,$^)) $< $@
>
>
> Regards,
> Wenji
>
When I upgraded binutils to 2.18 and enabled CONFIG_RELOCATABLE, there
are still mismatched symbols between kernel and debuginfo.
For example, to verify buildid (bytes from __start_notes to
__stop_notes) will get failed. The __stop_notes of running kernel
doesn't match the one in debuginfo.
$ uname -r
2.6.29-rc1
$ cat /proc/kallsyms |grep __stop_notes
c0543610 T __stop_notes
$ readelf -s /lib/modules/2.6.29-rc1/build/vmlinux |grep __stop_notes
48985: c1343610 0 NOTYPE GLOBAL DEFAULT 5 __stop_notes
$ cat /lib/modules/2.6.29-rc1/build/.config|grep CONFIG_RELOCATABLE
CONFIG_RELOCATABLE=y
$ gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-9.0.1)
$ ld -v
GNU ld (GNU Binutils) 2.18
$ objcopy --version
GNU objcopy (GNU Binutils) 2.18
Copyright 2007 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms
of the GNU General Public License version 3 or (at your option) any
later version.
This program has absolutely no warranty.
Regards,
Wenji
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-01-13 6:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-18 2:08 [PATCH] Kbuild: generate debug info in building Wenji Huang
2008-11-22 11:43 ` Sam Ravnborg
2008-11-26 5:51 ` Wenji Huang
2009-01-13 3:13 ` Wenji Huang
2009-01-13 3:23 ` Building error of 2.6.29-rc1 using old binutils Wenji Huang
2009-01-13 6:04 ` Wenji Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).