diff mbox series

回复: [PATCH] fs: allow strip binaries when create rootfs

Message ID AM6PR03MB56222D5EBD242C87ABF79C28B5949@AM6PR03MB5622.eurprd03.prod.outlook.com
State Rejected
Headers show
Series 回复: [PATCH] fs: allow strip binaries when create rootfs | expand

Commit Message

Tan Xiaofan Nov. 11, 2021, 3:16 a.m. UTC
>> From: xiaofan <xfan1024@live.com>
>> Date: Wed, 10 Nov 2021 23:13:25 +0800
>> Subject: [PATCH] fs: allow strip binaries when create rootfs
>>
>> Add BR2_STRIP_ROOTFS option, it is useful when using gdbserver on
>> target board. Host need unstriped binares for debug info and target
>> need only striped binares for rootfs size.
>>
>> Signed-off-by: xiaofan <xfan1024@live.com>
>
> This is a simple approach to the problem, indeed. However, I think the
> choice is not needed: just keep the boolean option, and move the whole
> stripping out of target-finalize and into the fs creation step.
>

Do you mean to change the behavior of BR2_STRIP_strip without adding other
options? In this case, we need to permanently set TARGET_STRIP to /bin/true
to prevent the binaries from being stripped on building time.

From 2b55431c3d5ccee2aa43f5996cfff65afe3f6537 Mon Sep 17 00:00:00 2001
From: xiaofan <xfan1024@live.com>
Date: Thu, 11 Nov 2021 11:01:13 +0800
Subject: [PATCH] fs: move stripping into fs creation step

It is useful when using gdbserver on target board. Host need unstriped
binares for debug info and target need only striped binares for rootfs
size.

Signed-off-by: xiaofan <xfan1024@live.com>
---
 Config.in           | 4 +---
 Makefile            | 2 --
 fs/common.mk        | 4 ++++
 package/Makefile.in | 7 +------
 4 files changed, 6 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/Config.in b/Config.in
index 3db2c8d..593859c 100644
--- a/Config.in
+++ b/Config.in
@@ -432,9 +432,7 @@  config BR2_STRIP_strip
 	help
 	  Binaries and libraries in the target filesystem will be
 	  stripped using the normal 'strip' command. This allows to save
-	  space, mainly by removing debugging symbols. Debugging symbols
-	  on the target are needed for native debugging, but not when
-	  remote debugging is used.
+	  space, mainly by removing debugging symbols.
 
 config BR2_STRIP_EXCLUDE_FILES
 	string "executables that should not be stripped"
diff --git a/Makefile b/Makefile
index 4062883..64cc8a0 100644
--- a/Makefile
+++ b/Makefile
@@ -763,8 +763,6 @@  endif
 ifneq ($(BR2_ENABLE_DEBUG):$(BR2_STRIP_strip),y:)
 	rm -rf $(TARGET_DIR)/lib/debug $(TARGET_DIR)/usr/lib/debug
 endif
-	$(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
-	$(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $(STRIPCMD) $(STRIP_STRIP_DEBUG) 2>/dev/null || true
 
 	test -f $(TARGET_DIR)/etc/ld.so.conf && \
 		{ echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
diff --git a/fs/common.mk b/fs/common.mk
index afab7b5..9675d02 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -171,6 +171,10 @@  $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES)
 		--exclude=/$$(notdir $$(TARGET_DIR_WARNING_FILE)) \
 		$$(BASE_TARGET_DIR)/ \
 		$$(TARGET_DIR)
+ifeq ($$(BR2_STRIP_strip),y)
+	$$(STRIP_FIND_CMD) | xargs -0 $$(STRIPCMD) 2>/dev/null || true
+	$$(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $$(STRIPCMD) $$(STRIP_STRIP_DEBUG) 2>/dev/null || true
+endif
 
 	echo '#!/bin/sh' > $$(FAKEROOT_SCRIPT)
 	echo "set -e" >> $$(FAKEROOT_SCRIPT)
diff --git a/package/Makefile.in b/package/Makefile.in
index dae7a85..a03312d 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -224,14 +224,9 @@  TARGET_READELF  = $(TARGET_CROSS)readelf
 TARGET_OBJCOPY  = $(TARGET_CROSS)objcopy
 TARGET_OBJDUMP  = $(TARGET_CROSS)objdump
 
-ifeq ($(BR2_STRIP_strip),y)
 STRIP_STRIP_DEBUG := --strip-debug
-TARGET_STRIP = $(TARGET_CROSS)strip
-STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
-else
 TARGET_STRIP = /bin/true
-STRIPCMD = $(TARGET_STRIP)
-endif
+STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
 INSTALL := $(shell which install || type -p install)
 UNZIP := $(shell which unzip || type -p unzip) -q