binutils/

2004-12-15 Jan Beulich  <jbeulich@novell.com>

	* doc/binutils.texi: Document --strip-unneeded-symbol and
	--strip-unneeded-symbols.
	* objcopy.c (strip_unneeded_list): New.
	(enum command_line_switch): Add OPTION_STRIP_UNNEEDED_SYMBOL
	and OPTION_STRIP_UNNEEDED_SYMBOLS.
	(copy_options): Add  --strip-unneeded-symbol and
	--strip-unneeded-symbols.
	(copy_usage): Likewise.
	(filter_symbols): Suppress copying of symbol if in strip_unneeded_list
	and the symbol is not needed.
	(copy_main): Handle OPTION_STRIP_UNNEEDED_SYMBOL and
	OPTION_STRIP_UNNEEDED_SYMBOLS.
This commit is contained in:
Jan Beulich 2004-12-16 13:16:33 +00:00
parent 5b9d23c67a
commit bcf32829af
4 changed files with 55 additions and 0 deletions

View file

@ -1,3 +1,18 @@
2004-12-15 Jan Beulich <jbeulich@novell.com>
* doc/binutils.texi: Document --strip-unneeded-symbol and
--strip-unneeded-symbols.
* objcopy.c (strip_unneeded_list): New.
(enum command_line_switch): Add OPTION_STRIP_UNNEEDED_SYMBOL
and OPTION_STRIP_UNNEEDED_SYMBOLS.
(copy_options): Add --strip-unneeded-symbol and
--strip-unneeded-symbols.
(copy_usage): Likewise.
(filter_symbols): Suppress copying of symbol if in strip_unneeded_list
and the symbol is not needed.
(copy_main): Handle OPTION_STRIP_UNNEEDED_SYMBOL and
OPTION_STRIP_UNNEEDED_SYMBOLS.
2004-12-09 Ian Lance Taylor <ian@wasabisystems.com> 2004-12-09 Ian Lance Taylor <ian@wasabisystems.com>
* readelf.c (get_machine_flags): Handle E_MIPS_MACH_9000. * readelf.c (get_machine_flags): Handle E_MIPS_MACH_9000.

View file

@ -1,5 +1,10 @@
-*- text -*- -*- text -*-
* objcopy recognizes two new options --strip-unneeded-symbol and
--strip-unneeded-symbols, namely for use together with the wildcard
matching the original --strip-symbol/--strip-symbols provided, but
retaining any symbols matching but needed by relocations.
* readelf can now display address ranges from .debug_range sections. This * readelf can now display address ranges from .debug_range sections. This
happens automatically when a DW_AT_range attribute is encountered. The happens automatically when a DW_AT_range attribute is encountered. The
command line switch --debug-dump=Ranges (or -wR) can also be used to display command line switch --debug-dump=Ranges (or -wR) can also be used to display

View file

@ -947,6 +947,7 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
[@option{-g}|@option{--strip-debug}] [@option{-g}|@option{--strip-debug}]
[@option{-K} @var{symbolname}|@option{--keep-symbol=}@var{symbolname}] [@option{-K} @var{symbolname}|@option{--keep-symbol=}@var{symbolname}]
[@option{-N} @var{symbolname}|@option{--strip-symbol=}@var{symbolname}] [@option{-N} @var{symbolname}|@option{--strip-symbol=}@var{symbolname}]
[@option{--strip-unneeded-symbol=}@var{symbolname}]
[@option{-G} @var{symbolname}|@option{--keep-global-symbol=}@var{symbolname}] [@option{-G} @var{symbolname}|@option{--keep-global-symbol=}@var{symbolname}]
[@option{-L} @var{symbolname}|@option{--localize-symbol=}@var{symbolname}] [@option{-L} @var{symbolname}|@option{--localize-symbol=}@var{symbolname}]
[@option{-W} @var{symbolname}|@option{--weaken-symbol=}@var{symbolname}] [@option{-W} @var{symbolname}|@option{--weaken-symbol=}@var{symbolname}]
@ -978,6 +979,7 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
[@option{--weaken}] [@option{--weaken}]
[@option{--keep-symbols=}@var{filename}] [@option{--keep-symbols=}@var{filename}]
[@option{--strip-symbols=}@var{filename}] [@option{--strip-symbols=}@var{filename}]
[@option{--strip-unneeded-symbols=}@var{filename}]
[@option{--keep-global-symbols=}@var{filename}] [@option{--keep-global-symbols=}@var{filename}]
[@option{--localize-symbols=}@var{filename}] [@option{--localize-symbols=}@var{filename}]
[@option{--weaken-symbols=}@var{filename}] [@option{--weaken-symbols=}@var{filename}]
@ -1106,6 +1108,10 @@ be given more than once.
Do not copy symbol @var{symbolname} from the source file. This option Do not copy symbol @var{symbolname} from the source file. This option
may be given more than once. may be given more than once.
@item --strip-unneeded-symbol=@var{symbolname}
Do not copy symbol @var{symbolname} from the source file unless it is needed
by a relocation. This option may be given more than once.
@item -G @var{symbolname} @item -G @var{symbolname}
@itemx --keep-global-symbol=@var{symbolname} @itemx --keep-global-symbol=@var{symbolname}
Keep only symbol @var{symbolname} global. Make all other symbols local Keep only symbol @var{symbolname} global. Make all other symbols local
@ -1347,6 +1353,12 @@ Apply @option{--strip-symbol} option to each symbol listed in the file
name per line. Line comments may be introduced by the hash character. name per line. Line comments may be introduced by the hash character.
This option may be given more than once. This option may be given more than once.
@item --strip-unneeded-symbols=@var{filename}
Apply @option{--strip-unneeded-symbol} option to each symbol listed in
the file @var{filename}. @var{filename} is simply a flat file, with one
symbol name per line. Line comments may be introduced by the hash
character. This option may be given more than once.
@item --keep-global-symbols=@var{filename} @item --keep-global-symbols=@var{filename}
Apply @option{--keep-global-symbol} option to each symbol listed in the Apply @option{--keep-global-symbol} option to each symbol listed in the
file @var{filename}. @var{filename} is simply a flat file, with one file @var{filename}. @var{filename} is simply a flat file, with one

View file

@ -192,6 +192,7 @@ static bfd_boolean wildcard = FALSE;
/* List of symbols to strip, keep, localize, keep-global, weaken, /* List of symbols to strip, keep, localize, keep-global, weaken,
or redefine. */ or redefine. */
static struct symlist *strip_specific_list = NULL; static struct symlist *strip_specific_list = NULL;
static struct symlist *strip_unneeded_list = NULL;
static struct symlist *keep_specific_list = NULL; static struct symlist *keep_specific_list = NULL;
static struct symlist *localize_specific_list = NULL; static struct symlist *localize_specific_list = NULL;
static struct symlist *keepglobal_specific_list = NULL; static struct symlist *keepglobal_specific_list = NULL;
@ -231,6 +232,8 @@ enum command_line_switch
OPTION_SREC_LEN, OPTION_SREC_LEN,
OPTION_SREC_FORCES3, OPTION_SREC_FORCES3,
OPTION_STRIP_SYMBOLS, OPTION_STRIP_SYMBOLS,
OPTION_STRIP_UNNEEDED_SYMBOL,
OPTION_STRIP_UNNEEDED_SYMBOLS,
OPTION_KEEP_SYMBOLS, OPTION_KEEP_SYMBOLS,
OPTION_LOCALIZE_SYMBOLS, OPTION_LOCALIZE_SYMBOLS,
OPTION_KEEPGLOBAL_SYMBOLS, OPTION_KEEPGLOBAL_SYMBOLS,
@ -340,6 +343,8 @@ static struct option copy_options[] =
{"strip-all", no_argument, 0, 'S'}, {"strip-all", no_argument, 0, 'S'},
{"strip-debug", no_argument, 0, 'g'}, {"strip-debug", no_argument, 0, 'g'},
{"strip-unneeded", no_argument, 0, OPTION_STRIP_UNNEEDED}, {"strip-unneeded", no_argument, 0, OPTION_STRIP_UNNEEDED},
{"strip-unneeded-symbol", required_argument, 0, OPTION_STRIP_UNNEEDED_SYMBOL},
{"strip-unneeded-symbols", required_argument, 0, OPTION_STRIP_UNNEEDED_SYMBOLS},
{"strip-symbol", required_argument, 0, 'N'}, {"strip-symbol", required_argument, 0, 'N'},
{"strip-symbols", required_argument, 0, OPTION_STRIP_SYMBOLS}, {"strip-symbols", required_argument, 0, OPTION_STRIP_SYMBOLS},
{"target", required_argument, 0, 'F'}, {"target", required_argument, 0, 'F'},
@ -405,6 +410,9 @@ copy_usage (FILE *stream, int exit_status)
-g --strip-debug Remove all debugging symbols & sections\n\ -g --strip-debug Remove all debugging symbols & sections\n\
--strip-unneeded Remove all symbols not needed by relocations\n\ --strip-unneeded Remove all symbols not needed by relocations\n\
-N --strip-symbol <name> Do not copy symbol <name>\n\ -N --strip-symbol <name> Do not copy symbol <name>\n\
--strip-unneeded-symbol <name>\n\
Do not copy symbol <name> unless needed by\n\
relocations\n\
--only-keep-debug Strip everything but the debug information\n\ --only-keep-debug Strip everything but the debug information\n\
-K --keep-symbol <name> Only copy symbol <name>\n\ -K --keep-symbol <name> Only copy symbol <name>\n\
-L --localize-symbol <name> Force symbol <name> to be marked as a local\n\ -L --localize-symbol <name> Force symbol <name> to be marked as a local\n\
@ -443,6 +451,9 @@ copy_usage (FILE *stream, int exit_status)
--srec-len <number> Restrict the length of generated Srecords\n\ --srec-len <number> Restrict the length of generated Srecords\n\
--srec-forceS3 Restrict the type of generated Srecords to S3\n\ --srec-forceS3 Restrict the type of generated Srecords to S3\n\
--strip-symbols <file> -N for all symbols listed in <file>\n\ --strip-symbols <file> -N for all symbols listed in <file>\n\
--strip-unneeded-symbols <file>\n\
--strip-unneeded-symbol for all symbols listed\n\
in <file>\n\
--keep-symbols <file> -K for all symbols listed in <file>\n\ --keep-symbols <file> -K for all symbols listed in <file>\n\
--localize-symbols <file> -L for all symbols listed in <file>\n\ --localize-symbols <file> -L for all symbols listed in <file>\n\
--keep-global-symbols <file> -G for all symbols listed in <file>\n\ --keep-global-symbols <file> -G for all symbols listed in <file>\n\
@ -903,6 +914,10 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
if (keep && is_specified_symbol (name, strip_specific_list)) if (keep && is_specified_symbol (name, strip_specific_list))
keep = 0; keep = 0;
if (keep
&& !(flags & BSF_KEEP)
&& is_specified_symbol (name, strip_unneeded_list))
keep = 0;
if (!keep && is_specified_symbol (name, keep_specific_list)) if (!keep && is_specified_symbol (name, keep_specific_list))
keep = 1; keep = 1;
if (keep && is_strip_section (abfd, bfd_get_section (sym))) if (keep && is_strip_section (abfd, bfd_get_section (sym)))
@ -2525,6 +2540,10 @@ copy_main (int argc, char *argv[])
add_specific_symbol (optarg, &strip_specific_list); add_specific_symbol (optarg, &strip_specific_list);
break; break;
case OPTION_STRIP_UNNEEDED_SYMBOL:
add_specific_symbol (optarg, &strip_unneeded_list);
break;
case 'L': case 'L':
add_specific_symbol (optarg, &localize_specific_list); add_specific_symbol (optarg, &localize_specific_list);
break; break;
@ -2858,6 +2877,10 @@ copy_main (int argc, char *argv[])
add_specific_symbols (optarg, &strip_specific_list); add_specific_symbols (optarg, &strip_specific_list);
break; break;
case OPTION_STRIP_UNNEEDED_SYMBOLS:
add_specific_symbols (optarg, &strip_unneeded_list);
break;
case OPTION_KEEP_SYMBOLS: case OPTION_KEEP_SYMBOLS:
add_specific_symbols (optarg, &keep_specific_list); add_specific_symbols (optarg, &keep_specific_list);
break; break;