From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id F0F753857C5A for ; Tue, 7 Mar 2023 14:50:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F0F753857C5A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from r6.localdomain (82-217-174-174.cable.dynamic.v4.ziggo.nl [82.217.174.174]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id C942F3000340; Tue, 7 Mar 2023 15:50:01 +0100 (CET) Received: by r6.localdomain (Postfix, from userid 1000) id 262063401DD; Tue, 7 Mar 2023 15:50:01 +0100 (CET) Message-ID: Subject: Re: [PATCH v3] strip: keep .ctf section in stripped file From: Mark Wielaard To: "Guillermo E. Martinez" , Nick Clifton Cc: elfutils-devel@sourceware.org Date: Tue, 07 Mar 2023 15:50:01 +0100 In-Reply-To: <20230304140044.gp5fvjufvomr2vv3@kamehouse> References: <20220601155527.2192182-1-guillermo.e.martinez@oracle.com> <20230223184237.240615-1-guillermo.e.martinez@oracle.com> <20230224115125.GD9039@gnu.wildebeest.org> <20230224164838.lyfxsjbcpttxdsaf@kamehouse> <492387583758712a4f5f1f2e2646a3ba6a7a23f1.camel@klomp.org> <8367d8ae-670d-b614-d922-211dcae11250@redhat.com> <0f9fdbd9eaaa8a8e42b426d86a5aa977eef2d8e4.camel@klomp.org> <20230303024058.42stfebtruwj4t3e@kamehouse> <8f58e4ca-16c9-4401-1985-262db0299cbb@redhat.com> <20230304140044.gp5fvjufvomr2vv3@kamehouse> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-3029.5 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Nick, Hi Guillermo, On Sat, 2023-03-04 at 08:00 -0600, Guillermo E. Martinez wrote: > Hello, >=20 > On Fri, Mar 03, 2023 at 12:24:19PM +0000, Nick Clifton wrote: > > Hi Mark, > >=20 > > > > > I am mainly wondering why binutils strip already seems to keep ".= ctf" > > > > > sections (even without -g). > >=20 > > > Right. But I am wondering how that mechanism works with binutils stri= p. > > > Apparently we do something different in eu-strip which makes it > > > necessary to add a --keep-ctf option based on the section name. It > > > would be good if we figured out how/what we can do to keep the > > > different strip utilities in sync. > >=20 > > I think that the function that does this is "is_strip_section_1" in >=20 > That's right, this function decided whether the section will be striped > out by default, if it has set `SEC_DEBUGGING' in BFD section flags then > section is removed by the default. For `.ctf' this flag is not set > because in `_bfd_elf_make_section_from_shdr' when BFD sections are > building it uses the section's name: ".debug", ".gnu.debuglto_.debug_", > ".gnu.linkonce.wi.", ".zdebug", "lines", ".stab", etc, to set > `SEC_DEBUGGING' flag. >=20 > > binutils/objcopy.c. If an input section has the BSF_DEBUGGING flag > > set (an internal flag to he BFD library, but basically it should be > > set for all debug sections, including .ctf sections I think), then > > the basic decision is to keep the section unless -g is used. OK, that is interesting. So given the .ctf section is NOT marked as SEC_DEBUGGING binutils strip basically never strips it. While eu-strip does strip it by default (since it is a non-loadable PROGBITS section), but keeps it with -g (which only strips the explicitly named .debug sections). But both binutils strip and eu-strip do have --keep-section=3D.ctf which would explicitly keep it even without -g, and both have --remove- section=3D.ctf which always removes the section. So binutils strip and eu-strip aren't totally identical with the default flags, but with --keep-section=3D.ctf and --remove-section=3D.ctf they seem to do the same thing. So I am not sure we really need a --keep-ctf flag for eu-strip (unless we also get it for binutils strip). My preference would be to just recommend a user use --keep-section=3D.ctf or --remove-section=3D.ctf to indicate what they want. Cheers, Mark