@@ -832,6 +832,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
@@ -1278,6 +1291,7 @@ help:
@echo ' all - Build all targets marked with [*]'
@echo '* vmlinux - Build the bare kernel'
@echo '* modules - Build all modules'
+ @echo ' debug_info - Extract debug info to debug directory'
@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)'
@@ -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.