aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@novell.com>2005-11-15 08:33:38 +0000
committerJan Beulich <jbeulich@novell.com>2005-11-15 08:33:38 +0000
commit1637cd900b9f1f05d0a128479bd3484cd98f2811 (patch)
tree49b2a63392584d3c8e7cfb6d5e71791b9fc8b255
parent9ab8018267fa3d466d8302aea29281dc121c5a52 (diff)
downloadgdb-1637cd900b9f1f05d0a128479bd3484cd98f2811.zip
gdb-1637cd900b9f1f05d0a128479bd3484cd98f2811.tar.gz
gdb-1637cd900b9f1f05d0a128479bd3484cd98f2811.tar.bz2
binutils/
2005-11-15 Jan Beulich <jbeulich@novell.com> * objcopy.c (keep_file_symbols): New. (enum command_line_switch): Add OPTION_KEEP_FILE_SYMBOLS. (strip_options): Add --keep-file-symbols. (copy_options): Likewise. (copy_usage): Likewise. (strip_usage): Likewise. (filter_symbols): Act upon keep_file_symbols. (strip_main): Handle OPTION_KEEP_FILE_SYMBOLS. (copy_main): Likewise. * doc/binutils.texi: Document --keep-file-symbols for objcopy and strip.
-rw-r--r--binutils/ChangeLog14
-rw-r--r--binutils/doc/binutils.texi12
-rw-r--r--binutils/objcopy.c19
3 files changed, 44 insertions, 1 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index c025d1c..a84b9b3 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,17 @@
+2005-11-15 Jan Beulich <jbeulich@novell.com>
+
+ * objcopy.c (keep_file_symbols): New.
+ (enum command_line_switch): Add OPTION_KEEP_FILE_SYMBOLS.
+ (strip_options): Add --keep-file-symbols.
+ (copy_options): Likewise.
+ (copy_usage): Likewise.
+ (strip_usage): Likewise.
+ (filter_symbols): Act upon keep_file_symbols.
+ (strip_main): Handle OPTION_KEEP_FILE_SYMBOLS.
+ (copy_main): Likewise.
+ * doc/binutils.texi: Document --keep-file-symbols for objcopy
+ and strip.
+
2005-11-14 Daniel Jacobowitz <dan@codesourcery.com>
* readelf.c (struct dump_list_entry, request_dump_byname)
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index f01919a..ee5114c 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -991,6 +991,7 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
[@option{--prefix-sections=}@var{string}]
[@option{--prefix-alloc-sections=}@var{string}]
[@option{--add-gnu-debuglink=}@var{path-to-file}]
+ [@option{--keep-file-symbols}]
[@option{--only-keep-debug}]
[@option{--writable-text}]
[@option{--readonly-text}]
@@ -1428,6 +1429,11 @@ Prefix all the names of all allocated sections in the output file with
Creates a .gnu_debuglink section which contains a reference to @var{path-to-file}
and adds it to the output file.
+@item --keep-file-symbols
+When stripping a file, perhaps with @option{--strip-debug} or
+@option{--strip-unneeded}, retain any symbols specifying source file names,
+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
@@ -2223,6 +2229,7 @@ strip [@option{-F} @var{bfdname} |@option{--target=}@var{bfdname}]
[@option{-x}|@option{--discard-all}] [@option{-X} |@option{--discard-locals}]
[@option{-R} @var{sectionname} |@option{--remove-section=}@var{sectionname}]
[@option{-o} @var{file}] [@option{-p}|@option{--preserve-dates}]
+ [@option{--keep-file-symbols}]
[@option{--only-keep-debug}]
[@option{-v} |@option{--verbose}] [@option{-V}|@option{--version}]
[@option{--help}] [@option{--info}]
@@ -2331,6 +2338,11 @@ Remove non-global symbols.
Remove compiler-generated local symbols.
(These usually start with @samp{L} or @samp{.}.)
+@item --keep-file-symbols
+When stripping a file, perhaps with @option{--strip-debug} or
+@option{--strip-unneeded}, retain any symbols specifying source file names,
+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.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index d46d093..e93534d6 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -203,6 +203,9 @@ static struct redefine_node *redefine_sym_list = NULL;
/* If this is TRUE, we weaken global symbols (set BSF_WEAK). */
static bfd_boolean weaken = FALSE;
+/* If this is TRUE, we retain BSF_FILE symbols. */
+static bfd_boolean keep_file_symbols = FALSE;
+
/* Prefix symbols/sections. */
static char *prefix_symbols_string = 0;
static char *prefix_sections_string = 0;
@@ -249,6 +252,7 @@ enum command_line_switch
OPTION_FORMATS_INFO,
OPTION_ADD_GNU_DEBUGLINK,
OPTION_ONLY_KEEP_DEBUG,
+ OPTION_KEEP_FILE_SYMBOLS,
OPTION_READONLY_TEXT,
OPTION_WRITABLE_TEXT,
OPTION_PURE,
@@ -266,6 +270,7 @@ static struct option strip_options[] =
{"info", no_argument, 0, OPTION_FORMATS_INFO},
{"input-format", required_argument, 0, 'I'}, /* Obsolete */
{"input-target", required_argument, 0, 'I'},
+ {"keep-file-symbols", no_argument, 0, OPTION_KEEP_FILE_SYMBOLS},
{"keep-symbol", required_argument, 0, 'K'},
{"only-keep-debug", no_argument, 0, OPTION_ONLY_KEEP_DEBUG},
{"output-format", required_argument, 0, 'O'}, /* Obsolete */
@@ -317,6 +322,7 @@ static struct option copy_options[] =
{"input-format", required_argument, 0, 'I'}, /* Obsolete */
{"input-target", required_argument, 0, 'I'},
{"interleave", required_argument, 0, 'i'},
+ {"keep-file-symbols", no_argument, 0, OPTION_KEEP_FILE_SYMBOLS},
{"keep-global-symbol", required_argument, 0, 'G'},
{"keep-global-symbols", required_argument, 0, OPTION_KEEPGLOBAL_SYMBOLS},
{"keep-symbol", required_argument, 0, 'K'},
@@ -420,6 +426,7 @@ copy_usage (FILE *stream, int exit_status)
relocations\n\
--only-keep-debug Strip everything but the debug information\n\
-K --keep-symbol <name> Do not strip symbol <name>\n\
+ --keep-file-symbols Do not strip file symbol(s)\n\
-L --localize-symbol <name> Force symbol <name> to be marked as a local\n\
--globalize-symbol <name> Force symbol <name> to be marked as a global\n\
-G --keep-global-symbol <name> Localize all symbols except <name>\n\
@@ -505,6 +512,7 @@ strip_usage (FILE *stream, int exit_status)
--only-keep-debug Strip everything but the debug information\n\
-N --strip-symbol=<name> Do not copy symbol <name>\n\
-K --keep-symbol=<name> Do not strip symbol <name>\n\
+ --keep-file-symbols Do not strip file symbol(s)\n\
-w --wildcard Permit wildcard in symbol comparison\n\
-x --discard-all Remove all non-global symbols\n\
-X --discard-locals Remove any compiler-generated symbols\n\
@@ -926,7 +934,9 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
&& !(flags & BSF_KEEP)
&& is_specified_symbol (name, strip_unneeded_list))
keep = 0;
- if (!keep && is_specified_symbol (name, keep_specific_list))
+ if (!keep
+ && ((keep_file_symbols && (flags & BSF_FILE))
+ || is_specified_symbol (name, keep_specific_list)))
keep = 1;
if (keep && is_strip_section (abfd, bfd_get_section (sym)))
keep = 0;
@@ -2460,6 +2470,9 @@ strip_main (int argc, char *argv[])
case OPTION_ONLY_KEEP_DEBUG:
strip_symbols = STRIP_NONDEBUG;
break;
+ case OPTION_KEEP_FILE_SYMBOLS:
+ keep_file_symbols = 1;
+ break;
case 0:
/* We've been given a long option. */
break;
@@ -2617,6 +2630,10 @@ copy_main (int argc, char *argv[])
strip_symbols = STRIP_NONDEBUG;
break;
+ case OPTION_KEEP_FILE_SYMBOLS:
+ keep_file_symbols = 1;
+ break;
+
case OPTION_ADD_GNU_DEBUGLINK:
gnu_debuglink_filename = optarg;
break;