Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Tan Xiaofan <xfan1024@live.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	"buildroot@buildroot.org" <buildroot@buildroot.org>
Subject: Re: [Buildroot] [PATCH] fs: allow strip binaries when create rootfs
Date: Wed, 10 Nov 2021 20:00:05 +0100	[thread overview]
Message-ID: <20211110190005.GN2084998@scaer> (raw)
In-Reply-To: <AM6PR03MB56227C126CCA7748EAB48382B5939@AM6PR03MB5622.eurprd03.prod.outlook.com>

Xiaofan, All,

+Peter, +Arnout, +Thomas

On 2021-11-10 16:10 +0000, Tan Xiaofan spake thusly:
> From 2f74b5bedffdf32e71a3786ca740c82257982f80 Mon Sep 17 00:00:00 2001
> 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.

Thoughts?

Regards,
Yann E. MORIN.

> ---
>  Config.in           | 21 +++++++++++++++++----
>  fs/common.mk        |  4 ++++
>  package/Makefile.in |  5 +++--
>  3 files changed, 24 insertions(+), 6 deletions(-)
> 
> diff --git a/Config.in b/Config.in
> index 3db2c8d..60a15ae 100644
> --- a/Config.in
> +++ b/Config.in
> @@ -425,10 +425,10 @@ config BR2_ENABLE_RUNTIME_DEBUG
>  	  Note: disabling this option is not a guarantee that all
>  	  packages effectively removed these runtime debugging elements.
>  
> -config BR2_STRIP_strip
> -	bool "strip target binaries"
> -	default y
> -	depends on !BR2_PACKAGE_HOST_ELF2FLT
> +choice
> +	prompt "strip target binaries"
> +	default BR2_STRIP_strip if !BR2_PACKAGE_HOST_ELF2FLT
> +	default BR2_STRIP_DISABLE if BR2_PACKAGE_HOST_ELF2FLT
>  	help
>  	  Binaries and libraries in the target filesystem will be
>  	  stripped using the normal 'strip' command. This allows to save
> @@ -436,6 +436,19 @@ config BR2_STRIP_strip
>  	  on the target are needed for native debugging, but not when
>  	  remote debugging is used.
>  
> +config BR2_STRIP_strip
> +	bool "enable"
> +	depends on !BR2_PACKAGE_HOST_ELF2FLT
> +
> +config BR2_STRIP_ROOTFS
> +	bool "enable: only affects on rootfs image"
> +	depends on !BR2_PACKAGE_HOST_ELF2FLT
> +
> +config BR2_STRIP_DISABLE
> +	bool "disable"
> +
> +endchoice
> +
>  config BR2_STRIP_EXCLUDE_FILES
>  	string "executables that should not be stripped"
>  	default ""
> diff --git a/fs/common.mk b/fs/common.mk
> index afab7b5..ac261ba 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_ROOTFS),y)
> +	$$(STRIP_FIND_CMD) | xargs -0 $$(STRIPCMD_ALWAYS) 2>/dev/null || true
> +	$$(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $$(STRIPCMD_ALWAYS) $$(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..d623837 100644
> --- a/package/Makefile.in
> +++ b/package/Makefile.in
> @@ -224,10 +224,11 @@ 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
> +STRIPCMD_ALWAYS = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
> +ifeq ($(BR2_STRIP_strip),y)
>  TARGET_STRIP = $(TARGET_CROSS)strip
> -STRIPCMD = $(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
> +STRIPCMD = $(STRIPCMD_ALWAYS)
>  else
>  TARGET_STRIP = /bin/true
>  STRIPCMD = $(TARGET_STRIP)
> -- 
> 2.17.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2021-11-10 19:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10 16:10 [Buildroot] [PATCH] fs: allow strip binaries when create rootfs Tan Xiaofan
2021-11-10 19:00 ` Yann E. MORIN [this message]
2021-11-11  3:16   ` [Buildroot] 回复: " Tan Xiaofan
2021-11-12 22:36   ` [Buildroot] " Thomas Petazzoni
2022-07-25 19:46     ` Arnout Vandecappelle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211110190005.GN2084998@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@buildroot.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=xfan1024@live.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox