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 434873858D33 for ; Tue, 28 Feb 2023 12:24:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 434873858D33 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 3F08930067AD; Tue, 28 Feb 2023 13:24:24 +0100 (CET) Received: by r6.localdomain (Postfix, from userid 1000) id F17783401F8; Tue, 28 Feb 2023 13:24:23 +0100 (CET) Message-ID: <492387583758712a4f5f1f2e2646a3ba6a7a23f1.camel@klomp.org> Subject: Re: [PATCH v3] strip: keep .ctf section in stripped file From: Mark Wielaard To: "Guillermo E. Martinez" Cc: elfutils-devel@sourceware.org, nickc@redhat.com Date: Tue, 28 Feb 2023 13:24:23 +0100 In-Reply-To: <20230224164838.lyfxsjbcpttxdsaf@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> 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.6 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 Guillermo, CCed Nick to see if he knows why binutils strip does what it does. On Fri, 2023-02-24 at 10:48 -0600, Guillermo E. Martinez wrote: > On Fri, Feb 24, 2023 at 12:51:25PM +0100, Mark Wielaard wrote: >=20 >=20 > > On Thu, Feb 23, 2023 at 12:42:37PM -0600, Guillermo E. Martinez via Elf= utils-devel wrote: > > > This is the third version of the patch to avoid remove the CTF sectio= n in > > > stripped files. Changes from v2: > > >=20 > > > - Rebased from master. > > >=20 > > > Please let me know your thoughts. > > >=20 > > > CTF debug format was designed to be present in stripped files, so > > > this section should not be removed, so a new --remove-ctf option > > > is added to indicate explicitly that .ctf section will be stripped > > > out from binary file. > >=20 > > Since the way to recognize a CTF section is by name ".ctf" does it > > really need a new option? eu-strip already has: > >=20 > > --keep-section=3DSECTION Keep the named section. SECTION is an ext= ended > > wildcard pattern. May be given more than on= ce. > >=20 > > -R, --remove-section=3DSECTION Remove the named section. SECTION is = an > > extended wildcard pattern. May be given mor= e than > > once. Only non-allocated sections can be > > removed. > >=20 > > Do you really need a new option? Or could you use an explicit > > --keep-section=3D.ctf and/or --remove-section=3D.ctf ? > >=20 >=20 > Oh, I see, thanks for your comment!. My intention with this patch is to > replicate the same proceeding by _default_ implemented in `binutils strip= ' > tool, it is: not remove CTF section, except it is indicated explicitly. O, this surprises me. I wasn't aware binutils strip keeps unallocated sections by default. But apparently it does. It doesn't seem specific to ".ctf". Do you know why? This seems counter to how strip is supposed to behave, at least how I understand it. eu-strip removes any non-allocated section (unless -g is given) which isn't referenced through a sh_link or sh_info (with SHF_INFO_LINK set) from a section that isn't removed. I assumed binutils strip would behave the same. See also http://www.linker-aliens.org/blogs/ali/entry/how_to_strip_an_elf/ (So one idea might be to reference the .ctf section through sh_link from e.g. the .text or .data section to signal it should be kept?) > Of course, if you think it is not really a good idea, I can propose a > patch to change the invocation of `eu-strip' in `find-debuginfo.sh' to > preserve CTF section as you showed above, when it generates debug > packages. Note that find-debuginfo already has: Use --keep-section SECTION or --remove-section SECTION to explicitly keep a (non-allocated) section in the main executable or explicitly remove it into the .debug file. SECTION is an extended wildcard pattern. Both options can be given more than once. =20 Cheers, Mark