This is the mail archive of the
mailing list for the elfutils project.
Re: [PATCH] strip: Add --keep-section=SECTION and --remove-section=SECTION.
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:
> > --keep-section=SECTION Keep the named section. SECTION is an extended
> > wildcard pattern. May be given more than once.
> I tried this with rust libraries (eu-strip --keep-section=.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
diff --git a/src/strip.c b/src/strip.c
index 3aad92e..4a35ea1 100644
@@ -2267,14 +2267,14 @@ while computing checksum for debug information"));
if (shdr_info != NULL)
/* For some sections we might have created an table to map symbol
- table indices. */
- if (any_symtab_changes)
- for (cnt = 1; cnt <= shdridx; ++cnt)
- free (shdr_info[cnt].newsymidx);
- if (shdr_info[cnt].debug_data != 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 = 1; cnt <= shdridx; ++cnt)
+ free (shdr_info[cnt].newsymidx);
+ if (shdr_info[cnt].debug_data != NULL)
+ free (shdr_info[cnt].debug_data->d_buf);
/* Free data we allocated for the .gnu_debuglink section. */
Added to the patch and pushed to master.