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

Bug#555549: 555549: adding .gnu_debuglink section in kernel modules



On Sat, 2010-08-14 at 02:01 +0530, Ritesh Raj Sarraf wrote:
> tags 555549 +patch
> thanks
> 
> Hello Bastian,
> 
> On Tuesday 10 Aug 2010 13:35:58 Bastian Blank wrote:
> > > I tried re-building the kernel image with dh_strip -k  but that did not
> > > help.  So, how is the linux-image-xxxx-dbg package created ?
> > 
> > debian/rules.real shows it.
> 
> Thanks for pointing this out. Attached patch adds .gnu_debuglink section to 
> the kernel modules pointing to the corresponding kernel modules containing the 
> DWARF information.
> 
> Please review the patch and apply. I've generated it against the debian/ 
> kernel trunk from the svn repository. I would like to see this be part of the 
> Squeeze release. So please apply this to the Squeeze kernel too.
[...]
> diff --git a/rules.real b/rules.real
> index 0d938f3..bf1771e 100644
> --- a/rules.real
> +++ b/rules.real
> @@ -345,6 +345,9 @@ install-image_$(ARCH)_$(FEATURESET)_$(FLAVOUR)_plain:
>           DIR='$(DIR)' PACKAGE_DIR='$(PACKAGE_DIR)' INSTALL_DIR='$(INSTALL_DIR)' REAL_VERSION='$(REAL_VERSION)'
>  ifeq ($(MODULES),True)
>         +$(MAKE_CLEAN) -C $(DIR) modules_install INSTALL_MOD_PATH='$(CURDIR)'/$(PACKAGE_DIR) INSTALL_MOD_STRIP=1
> +       find $(PACKAGE_DIR) -name '*.ko' | sed 's|$(PACKAGE_DIR)/lib/modules/$(REAL_VERSION)/kernel/||' | while read module ; do \
> +         objcopy --add-gnu-debuglink=$(DIR)/$$module $(PACKAGE_DIR)/lib/modules/$(REAL_VERSION)/kernel/$$module; \
> +       done
[...]

We don't build debug information for all architectures, so this should
be done only if DEBUG is True.

[I also wonder why we are copying the unstripped modules into
/usr/lib/debug and not just debug info?  And shouldn't this really be
part of Kbuild?  Here's how we could do it in Kbuild:

--- a/Makefile
+++ b/Makefile
@@ -623,8 +623,11 @@ export	INSTALL_PATH ?= /boot
 # makefile but the argument can be passed to make if needed.
 #
 
-MODLIB	= $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
+MODLIB_DIR = /lib/modules/$(KERNELRELEASE)
+MODLIB	= $(INSTALL_MOD_PATH)$(MODLIB_DIR)
+MODLIB_DEBUG = $(INSTALL_MOD_PATH)/usr/lib/debug$(MODLIB_DIR)
 export MODLIB
+export MODLIB_DEBUG
 
 #
 #  INSTALL_MOD_STRIP, if defined, will cause modules to be
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -17,7 +17,11 @@ __modinst: $(modules)
 	@:
 
 quiet_cmd_modules_install = INSTALL $@
+ifdef INSTALL_MOD_DEBUGLINK
+      cmd_modules_install = mkdir -p $(2); mkdir -p $(3); $(OBJCOPY) --only-keep-debug $@ $(3)/$(@F) && $(OBJCOPY) --strip-debug --add-gnu-debuglink=$(3)/$(@F) $@ $(2)/$(@F)
+else
       cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@)
+endif
 
 # Modules built outside the kernel source tree go into extra by default
 INSTALL_MOD_DIR ?= extra
@@ -26,7 +30,7 @@ ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D)
 modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
 
 $(modules):
-	$(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
+	$(call cmd,modules_install,$(MODLIB)/$(modinst_dir),$(MODLIB_DEBUG)/$(modinst_dir))
 
 
 # Declare the contents of the .PHONY variable as phony.  We keep that
--- END ---

I'm less sure how we would invoke this in debian/rules.*.  I think we
would need to build the image and image-dbg packages at the same time.]

Ben.

-- 
Ben Hutchings
Once a job is fouled up, anything done to improve it makes it worse.

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: