From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102735 invoked by alias); 17 Jul 2017 11:37:51 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 102714 invoked by uid 89); 17 Jul 2017 11:37:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=josh, leak, Josh X-Spam-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Jul 2017 11:37:48 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 4CD18300070A; Mon, 17 Jul 2017 13:37:46 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 3BA1940E39EF; Mon, 17 Jul 2017 13:37:46 +0200 (CEST) Message-ID: <1500291465.14595.339.camel@klomp.org> Subject: Re: [PATCH] strip: Add --keep-section=SECTION and --remove-section=SECTION. From: Mark Wielaard To: Josh Stone Cc: elfutils-devel@sourceware.org Date: Mon, 17 Jul 2017 11:37:00 -0000 In-Reply-To: <2d4f0400-9313-2d17-11d9-d79c8ee9216b@redhat.com> References: <1500046110-20483-1-git-send-email-mark@klomp.org> <2d4f0400-9313-2d17-11d9-d79c8ee9216b@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.12.11 (3.12.11-22.el7) Mime-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00015.txt.bz2 On Fri, 2017-07-14 at 12:24 -0700, Josh Stone wrote: > On 07/14/2017 08:28 AM, Mark Wielaard wrote: > > Adds two new output options: > >=20 > > --keep-section=3DSECTION Keep the named section. SECTION is an exten= ded > > wildcard pattern. May be given more than once. >=20 > I tried this with rust libraries (eu-strip --keep-section=3D.rustc), and > it seems to work as desired. Thanks! Thanks for testing. Also make distcheck found a memory leak. We used to only cleanup extra debug section data if there were symbol table changes (then the original file would get the small/stripped symbol table, but the debug file would get the full one). But now another reason might be that we explicitly keep a section in the original file, but it is also needed by another section that is moved into the .debug file. For example we keep a string table that is also needed by a removed symbol table. So just always cleanup, not just when there were any symbol table changes: diff --git a/src/strip.c b/src/strip.c index 3aad92e..4a35ea1 100644 --- a/src/strip.c +++ b/src/strip.c @@ -2267,14 +2267,14 @@ while computing checksum for debug information")); if (shdr_info !=3D NULL) { /* For some sections we might have created an table to map symbol - table indices. */ - if (any_symtab_changes) - for (cnt =3D 1; cnt <=3D shdridx; ++cnt) - { - free (shdr_info[cnt].newsymidx); - if (shdr_info[cnt].debug_data !=3D NULL) - free (shdr_info[cnt].debug_data->d_buf); - } + table indices. Or we might kept (original) data around to put + into the .debug file. */ + for (cnt =3D 1; cnt <=3D shdridx; ++cnt) + { + free (shdr_info[cnt].newsymidx); + if (shdr_info[cnt].debug_data !=3D NULL) + free (shdr_info[cnt].debug_data->d_buf); + } =20 /* Free data we allocated for the .gnu_debuglink section. */ free (debuglink_buf); Added to the patch and pushed to master. Cheers, Mark