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]

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


This changes objcopy --only-keep-debug so it does not discard allocated
SHT_NOTE sections.  (I have also made this change in elfutils 0.128 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.)

Ok to commit?


Thanks,
Roland


---

2007-06-28  Roland McGrath  <roland@frob.com>

	* objcopy.c (setup_section): Don't reset ELF section type to
	SHT_NOBITS when it is SHT_NOTE.
	* doc/binutils.texi (objcopy, strip): Mention under --only-keep-debug.

Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.114
diff -b -B -p -u -r1.114 objcopy.c
--- binutils/objcopy.c	27 Jun 2007 11:54:09 -0000	1.114
+++ binutils/objcopy.c	29 Jun 2007 00:01:05 -0000
@@ -2212,6 +2212,9 @@ setup_section (bfd *ibfd, sec_ptr isecti
   if (strip_symbols == STRIP_NONDEBUG
       && obfd->xvec->flavour == bfd_target_elf_flavour
       && (flags & SEC_ALLOC) != 0
+      && elf_section_type (osection) != SHT_NOTE
+      && (ibfd->xvec->flavour != bfd_target_elf_flavour
+	  || elf_section_type (isection) != SHT_NOTE)
       && (p == NULL || !p->set_flags))
     elf_section_type (osection) = SHT_NOBITS;
 
Index: binutils/doc/binutils.texi
===================================================================
RCS file: /cvs/src/src/binutils/doc/binutils.texi,v
retrieving revision 1.109
diff -b -B -p -u -r1.109 binutils.texi
--- binutils/doc/binutils.texi	19 Jun 2007 13:24:33 -0000	1.109
+++ binutils/doc/binutils.texi	29 Jun 2007 00:01:06 -0000
@@ -1481,7 +1481,7 @@ which would otherwise get stripped.
 @item --only-keep-debug
 Strip a file, removing contents of any sections that would not be
 stripped by @option{--strip-debug} and leaving the debugging sections
-intact.
+intact.  In ELF files, this preserves all note sections in the output.
 
 The intention is that this option will be used in conjunction with
 @option{--add-gnu-debuglink} to create a two part executable.  One a
@@ -2412,8 +2412,9 @@ When stripping a file, perhaps with @opt
 which would otherwise get stripped.
 
 @item --only-keep-debug
-Strip a file, removing any sections that would be stripped by
-@option{--strip-debug} and leaving the debugging sections.
+Strip a file, removing contents of any sections that would not be
+stripped by @option{--strip-debug} and leaving the debugging sections
+intact.  In ELF files, this preserves all note sections in the output.
 
 The intention is that this option will be used in conjunction with
 @option{--add-gnu-debuglink} to create a two part executable.  One a


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