This is the mail archive of the binutils-cvs@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]

[binutils-gdb] Stop strip from merging notes when stripping debug or dwo information.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1b8dd6432644c256ab294d205a8e00f6c6dc5073

commit 1b8dd6432644c256ab294d205a8e00f6c6dc5073
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Apr 24 17:44:31 2019 +0100

    Stop strip from merging notes when stripping debug or dwo information.
    
    	* objcopy.c (strip_main): Do not enable note merging by default if
    	just stripping debug or dwo information.
    	* doc/binutils.texi (strip): Update documentation.

Diff:
---
 binutils/ChangeLog         |  6 ++++++
 binutils/doc/binutils.texi |  2 +-
 binutils/objcopy.c         | 15 +++++++++++++--
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 9aa6bf9..8fbc761 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2019-04-24  Nick Clifton  <nickc@redhat.com>
+
+	* objcopy.c (strip_main): Do not enable note merging by default if
+	just stripping debug or dwo information.
+	* doc/binutils.texi (strip): Update documentation.
+
 2019-04-23  Nick Clifton  <nickc@redhat.com>
 
 	* README-how-to-make-a-release: Add note to update the symbolic
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index 077cf06..502f68d 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -3313,7 +3313,7 @@ normally be stripped.  This option may be given more than once.
 @itemx --no-merge-notes
 For ELF files, attempt (or do not attempt) to reduce the size of any
 SHT_NOTE type sections by removing duplicate notes.  The default is to
-attempt this reduction.
+attempt this reduction unless stripping debug or DWO information.
 
 @item -N @var{symbolname}
 @itemx --strip-symbol=@var{symbolname}
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 330b93c..673e1f6 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -4410,8 +4410,7 @@ strip_main (int argc, char *argv[])
   int c;
   int i;
   char *output_file = NULL;
-
-  merge_notes = TRUE;
+  bfd_boolean merge_notes_set = FALSE;
 
   while ((c = getopt_long (argc, argv, "I:O:F:K:MN:R:o:sSpdgxXHhVvwDU",
 			   strip_options, (int *) 0)) != EOF)
@@ -4452,9 +4451,11 @@ strip_main (int argc, char *argv[])
 	  break;
 	case 'M':
 	  merge_notes = TRUE;
+	  merge_notes_set = TRUE;
 	  break;
 	case OPTION_NO_MERGE_NOTES:
 	  merge_notes = FALSE;
+	  merge_notes_set = TRUE;
 	  break;
 	case 'N':
 	  add_specific_symbol (optarg, strip_specific_htab);
@@ -4506,6 +4507,16 @@ strip_main (int argc, char *argv[])
 	}
     }
 
+  /* If the user has not expressly chosen to merge/not-merge ELF notes
+     then enable the merging unless we are stripping debug or dwo info.  */
+  if (! merge_notes_set
+      && (strip_symbols == STRIP_UNDEF
+	  || strip_symbols == STRIP_ALL
+	  || strip_symbols == STRIP_UNNEEDED
+	  || strip_symbols == STRIP_NONDEBUG
+	  || strip_symbols == STRIP_NONDWO))
+    merge_notes = TRUE;
+
   if (formats_info)
     {
       display_info ();


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