Skip to content

Commit ec36ce3

Browse files
committed
build: strip debug info into a separate file
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
1 parent 2ed40e2 commit ec36ce3

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
cscope.*
66
*.iso
77
*.img
8+
*.debug
89
Makeconf.local
910
.DS_Store
1011
drivers/acpi/acpica/source/

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ SHELL := bash
7979
RM := rm
8080
LN := ln
8181
SYMLINK := $(LN) -s -f
82+
OBJCOPY := objcopy
83+
STRIP := strip
8284

8385
GRUB_FILE := grub-file
8486
GRUB_MKIMAGE := grub-mkimage
@@ -146,6 +148,7 @@ OBJS := $(SOURCES:%.c=%.o)
146148
OBJS += $(ASM_SOURCES:%.S=%.o)
147149

148150
TARGET := kernel64.bin
151+
TARGET_DEBUG := $(TARGET).debug
149152

150153
# On Linux systems, we build directly. On non-Linux, we rely on the 'docker%'
151154
# rule below to create an Ubuntu container and perform the Linux-specific build
@@ -169,6 +172,9 @@ $(TARGET): $(OBJS) $(PREP_LINK_SCRIPT)
169172
$(VERBOSE) rm -rf $(SYMBOLS_NAME).S
170173
@echo "LD " $(TARGET) $(SYMBOLS_NAME).o
171174
$(VERBOSE) $(LD) -T $(PREP_LINK_SCRIPT) -o $@ $(OBJS) $(PFMLIB_LINKER_FLAGS) $(SYMBOLS_NAME).o
175+
@echo "STRIP"
176+
$(VERBOSE) $(OBJCOPY) --only-keep-debug $(TARGET) $(TARGET_DEBUG)
177+
$(VERBOSE) $(STRIP) -s $(TARGET)
172178

173179
$(PFMLIB_ARCHIVE): $(PFMLIB_TARBALL)
174180
@echo "UNTAR libpfm"
@@ -203,6 +209,7 @@ clean:
203209
$(VERBOSE) find $(KTF_ROOT) -name cscope.\* -delete
204210
$(VERBOSE) find $(PFMLIB_DIR) -mindepth 1 ! -name $(PFMLIB_NAME)-$(PFMLIB_VER).tar.gz -delete
205211
$(VERBOSE) $(RM) -rf $(ACPICA_DEST_DIR)/source
212+
$(VERBOSE) $(RM) -f $(TARGET_DEBUG)
206213

207214
# Check whether we can use kvm for qemu
208215
ifeq ($(SYSTEM),LINUX)

0 commit comments

Comments
 (0)