This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] objcopy --only-keep-debug vs SHT_NOTE


On Sat, May 19, 2007 at 04:24:41PM -0700, Roland McGrath wrote:
> This patch changes objcopy --only-keep-debug in two ways.  First, it
> preserves the sh_type of saved sections not being otherwise molested.
> This, for example, makes unallocated note sections preserved in .debug
> files keep their SHT_NOTE type instead of being reset to SHT_PROGBITS.

Yes, that's a bug.  I don't think your fix is the best possible
though;  We probably should be calling copy_private_section_data for
any sections we copy.  Nick disabled that particular call because at
the time he implemented objcopy --only-keep-debug,
copy_private_section_data also copied program headers, which as the
comment says "We do not want".

Moreover, I'm inclined to think that there is a further bug here.
As the --only-keep-debug documentation says, it should result in
stripping all sections except those removed by --strip-debug.  ie.  I
think your note section should have been removed.

> Second, it does not discard allocated SHT_NOTE sections.  (I am also
> making this change in elfutils strip.)  The idea here is that some
> SHT_NOTE sections might be used to embed identifying information in
> stripped binaries, and by copying these sections into the .debug file
> as well, they can be compared and used for matching things up.  (This
> is part of a particular nascent plan using notes, but it seems like a
> straightforward and harmless change regardless.)

This of course makes the situation worse, as far as --only-keep-debug
and --strip-debug ought to partition a file into two distinct sets of
sections.  I think that if you want to keep certain sections along
with the debug sections, then objcopy should support this with another
option, or perhaps --only-keep-debug along with --only-section=

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]