Add new switch --globalize-symbol to convert local symbols into globals.
This commit is contained in:
parent
f7945f452e
commit
7b4a0685e8
@ -1,3 +1,20 @@
|
|||||||
|
2005-03-15 Daniel Marques <marques@cs.cornell.edu>
|
||||||
|
Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
* objcopy.c (globalize_specific_list): New linked list of symbols
|
||||||
|
to convert from local binding into global binding.
|
||||||
|
(command_line_switch): Add OPTION_GLOBALIZE_SYMBOL and
|
||||||
|
OPTION_GLOBALIZE_SYMBOLS.
|
||||||
|
(copy_options): Add "globalize-symbol" and "globalize-symbols".
|
||||||
|
(copy_usage): Document the new switches.
|
||||||
|
(filter_symbols): Convert defined local symbols mentioned on the
|
||||||
|
globalize_specific_list into global symbols.
|
||||||
|
(copy_object): Perform actions if the globalize_specific_list is
|
||||||
|
not empty.
|
||||||
|
(copy_main): Handle new switches.
|
||||||
|
* NEWS: Mention new feature.
|
||||||
|
* doc/binutils.texi: Document new switches.
|
||||||
|
|
||||||
2005-03-15 Alan Modra <amodra@bigpond.net.au>
|
2005-03-15 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
* po/es.po: Commit new Spanish translation.
|
* po/es.po: Commit new Spanish translation.
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
-*- text -*-
|
-*- text -*-
|
||||||
|
|
||||||
|
* Add "--globalize-symbol <name>" and "--globalize-symbols <filename>" switches
|
||||||
|
to objcopy to convert local symbols into global symbols.
|
||||||
|
|
||||||
|
Changes in 2.16:
|
||||||
|
|
||||||
* objcopy recognizes two new options --strip-unneeded-symbol and
|
* objcopy recognizes two new options --strip-unneeded-symbol and
|
||||||
--strip-unneeded-symbols, namely for use together with the wildcard
|
--strip-unneeded-symbols, namely for use together with the wildcard
|
||||||
matching the original --strip-symbol/--strip-symbols provided, but
|
matching the original --strip-symbol/--strip-symbols provided, but
|
||||||
|
@ -30,7 +30,7 @@ END-INFO-DIR-ENTRY
|
|||||||
@ifinfo
|
@ifinfo
|
||||||
@c man begin COPYRIGHT
|
@c man begin COPYRIGHT
|
||||||
Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||||
2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
under the terms of the GNU Free Documentation License, Version 1.1
|
under the terms of the GNU Free Documentation License, Version 1.1
|
||||||
@ -55,7 +55,7 @@ notice identical to this one except for the removal of this paragraph
|
|||||||
@c "objdump", "nm", "size", "strings", "strip", "readelf" and "ranlib".
|
@c "objdump", "nm", "size", "strings", "strip", "readelf" and "ranlib".
|
||||||
@c
|
@c
|
||||||
@c Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
@c Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||||
@c 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
@c 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||||
@c
|
@c
|
||||||
@c This text may be freely distributed under the terms of the GNU
|
@c This text may be freely distributed under the terms of the GNU
|
||||||
@c Free Documentation License.
|
@c Free Documentation License.
|
||||||
@ -81,7 +81,7 @@ notice identical to this one except for the removal of this paragraph
|
|||||||
|
|
||||||
@vskip 0pt plus 1filll
|
@vskip 0pt plus 1filll
|
||||||
Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
Copyright @copyright{} 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||||
2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Permission is granted to copy, distribute and/or modify this document
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
under the terms of the GNU Free Documentation License, Version 1.1
|
under the terms of the GNU Free Documentation License, Version 1.1
|
||||||
@ -950,6 +950,7 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
|
|||||||
[@option{--strip-unneeded-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{--globalize-symbol=}@var{symbolname}]
|
||||||
[@option{-W} @var{symbolname}|@option{--weaken-symbol=}@var{symbolname}]
|
[@option{-W} @var{symbolname}|@option{--weaken-symbol=}@var{symbolname}]
|
||||||
[@option{-w}|@option{--wildcard}]
|
[@option{-w}|@option{--wildcard}]
|
||||||
[@option{-x}|@option{--discard-all}]
|
[@option{-x}|@option{--discard-all}]
|
||||||
@ -982,6 +983,7 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
|
|||||||
[@option{--strip-unneeded-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{--globalize-symbols=}@var{filename}]
|
||||||
[@option{--weaken-symbols=}@var{filename}]
|
[@option{--weaken-symbols=}@var{filename}]
|
||||||
[@option{--alt-machine-code=}@var{index}]
|
[@option{--alt-machine-code=}@var{index}]
|
||||||
[@option{--prefix-symbols=}@var{string}]
|
[@option{--prefix-symbols=}@var{string}]
|
||||||
@ -1127,6 +1129,11 @@ visible externally. This option may be given more than once.
|
|||||||
@itemx --weaken-symbol=@var{symbolname}
|
@itemx --weaken-symbol=@var{symbolname}
|
||||||
Make symbol @var{symbolname} weak. This option may be given more than once.
|
Make symbol @var{symbolname} weak. This option may be given more than once.
|
||||||
|
|
||||||
|
@item --globalize-symbol=@var{symbolname}
|
||||||
|
Give symbol @var{symbolname} global scoping so that it is visible
|
||||||
|
outside of the file in which it is defined. This option may be given
|
||||||
|
more than once.
|
||||||
|
|
||||||
@item -w
|
@item -w
|
||||||
@itemx --wildcard
|
@itemx --wildcard
|
||||||
Permit regular expressions in @var{symbolname}s used in other command
|
Permit regular expressions in @var{symbolname}s used in other command
|
||||||
@ -1371,6 +1378,12 @@ Apply @option{--localize-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 --globalize-symbols=@var{filename}
|
||||||
|
Apply @option{--globalize-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 --weaken-symbols=@var{filename}
|
@item --weaken-symbols=@var{filename}
|
||||||
Apply @option{--weaken-symbol} option to each symbol listed in the file
|
Apply @option{--weaken-symbol} option to each symbol listed in the file
|
||||||
@var{filename}. @var{filename} is simply a flat file, with one symbol
|
@var{filename}. @var{filename} is simply a flat file, with one symbol
|
||||||
|
@ -195,6 +195,7 @@ static struct symlist *strip_specific_list = NULL;
|
|||||||
static struct symlist *strip_unneeded_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 *globalize_specific_list = NULL;
|
||||||
static struct symlist *keepglobal_specific_list = NULL;
|
static struct symlist *keepglobal_specific_list = NULL;
|
||||||
static struct symlist *weaken_specific_list = NULL;
|
static struct symlist *weaken_specific_list = NULL;
|
||||||
static struct redefine_node *redefine_sym_list = NULL;
|
static struct redefine_node *redefine_sym_list = NULL;
|
||||||
@ -236,6 +237,8 @@ enum command_line_switch
|
|||||||
OPTION_STRIP_UNNEEDED_SYMBOLS,
|
OPTION_STRIP_UNNEEDED_SYMBOLS,
|
||||||
OPTION_KEEP_SYMBOLS,
|
OPTION_KEEP_SYMBOLS,
|
||||||
OPTION_LOCALIZE_SYMBOLS,
|
OPTION_LOCALIZE_SYMBOLS,
|
||||||
|
OPTION_GLOBALIZE_SYMBOL,
|
||||||
|
OPTION_GLOBALIZE_SYMBOLS,
|
||||||
OPTION_KEEPGLOBAL_SYMBOLS,
|
OPTION_KEEPGLOBAL_SYMBOLS,
|
||||||
OPTION_WEAKEN_SYMBOLS,
|
OPTION_WEAKEN_SYMBOLS,
|
||||||
OPTION_RENAME_SECTION,
|
OPTION_RENAME_SECTION,
|
||||||
@ -306,6 +309,8 @@ static struct option copy_options[] =
|
|||||||
{"discard-locals", no_argument, 0, 'X'},
|
{"discard-locals", no_argument, 0, 'X'},
|
||||||
{"format", required_argument, 0, 'F'}, /* Obsolete */
|
{"format", required_argument, 0, 'F'}, /* Obsolete */
|
||||||
{"gap-fill", required_argument, 0, OPTION_GAP_FILL},
|
{"gap-fill", required_argument, 0, OPTION_GAP_FILL},
|
||||||
|
{"globalize-symbol", required_argument, 0, OPTION_GLOBALIZE_SYMBOL},
|
||||||
|
{"globalize-symbols", required_argument, 0, OPTION_GLOBALIZE_SYMBOLS},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, 0, 'h'},
|
||||||
{"impure", no_argument, 0, OPTION_IMPURE},
|
{"impure", no_argument, 0, OPTION_IMPURE},
|
||||||
{"info", no_argument, 0, OPTION_FORMATS_INFO},
|
{"info", no_argument, 0, OPTION_FORMATS_INFO},
|
||||||
@ -416,6 +421,7 @@ copy_usage (FILE *stream, int exit_status)
|
|||||||
--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\
|
||||||
|
--globalize-symbol <name> Force symbol <name> to be marked as a global\n\
|
||||||
-G --keep-global-symbol <name> Localize all symbols except <name>\n\
|
-G --keep-global-symbol <name> Localize all symbols except <name>\n\
|
||||||
-W --weaken-symbol <name> Force symbol <name> to be marked as a weak\n\
|
-W --weaken-symbol <name> Force symbol <name> to be marked as a weak\n\
|
||||||
--weaken Force all global symbols to be marked as weak\n\
|
--weaken Force all global symbols to be marked as weak\n\
|
||||||
@ -456,6 +462,7 @@ copy_usage (FILE *stream, int exit_status)
|
|||||||
in <file>\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\
|
||||||
|
--globalize-symbols <file> --globalize-symbol for all 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\
|
||||||
--weaken-symbols <file> -W for all symbols listed in <file>\n\
|
--weaken-symbols <file> -W for all symbols listed in <file>\n\
|
||||||
--alt-machine-code <index> Use alternate machine code for output\n\
|
--alt-machine-code <index> Use alternate machine code for output\n\
|
||||||
@ -923,13 +930,17 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
|
|||||||
if (keep && is_strip_section (abfd, bfd_get_section (sym)))
|
if (keep && is_strip_section (abfd, bfd_get_section (sym)))
|
||||||
keep = 0;
|
keep = 0;
|
||||||
|
|
||||||
if (keep && (flags & BSF_GLOBAL) != 0
|
if (keep)
|
||||||
|
{
|
||||||
|
if ((flags & BSF_GLOBAL) != 0
|
||||||
&& (weaken || is_specified_symbol (name, weaken_specific_list)))
|
&& (weaken || is_specified_symbol (name, weaken_specific_list)))
|
||||||
{
|
{
|
||||||
sym->flags &= ~ BSF_GLOBAL;
|
sym->flags &= ~ BSF_GLOBAL;
|
||||||
sym->flags |= BSF_WEAK;
|
sym->flags |= BSF_WEAK;
|
||||||
}
|
}
|
||||||
if (keep && !undefined && (flags & (BSF_GLOBAL | BSF_WEAK))
|
|
||||||
|
if (!undefined
|
||||||
|
&& (flags & (BSF_GLOBAL | BSF_WEAK))
|
||||||
&& (is_specified_symbol (name, localize_specific_list)
|
&& (is_specified_symbol (name, localize_specific_list)
|
||||||
|| (keepglobal_specific_list != NULL
|
|| (keepglobal_specific_list != NULL
|
||||||
&& ! is_specified_symbol (name, keepglobal_specific_list))))
|
&& ! is_specified_symbol (name, keepglobal_specific_list))))
|
||||||
@ -938,9 +949,17 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
|
|||||||
sym->flags |= BSF_LOCAL;
|
sym->flags |= BSF_LOCAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keep)
|
if (!undefined
|
||||||
|
&& (flags & BSF_LOCAL)
|
||||||
|
&& is_specified_symbol (name, globalize_specific_list))
|
||||||
|
{
|
||||||
|
sym->flags &= ~ BSF_LOCAL;
|
||||||
|
sym->flags |= BSF_GLOBAL;
|
||||||
|
}
|
||||||
|
|
||||||
to[dst_count++] = sym;
|
to[dst_count++] = sym;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
to[dst_count] = NULL;
|
to[dst_count] = NULL;
|
||||||
|
|
||||||
@ -1389,6 +1408,7 @@ copy_object (bfd *ibfd, bfd *obfd)
|
|||||||
|| strip_specific_list != NULL
|
|| strip_specific_list != NULL
|
||||||
|| keep_specific_list != NULL
|
|| keep_specific_list != NULL
|
||||||
|| localize_specific_list != NULL
|
|| localize_specific_list != NULL
|
||||||
|
|| globalize_specific_list != NULL
|
||||||
|| keepglobal_specific_list != NULL
|
|| keepglobal_specific_list != NULL
|
||||||
|| weaken_specific_list != NULL
|
|| weaken_specific_list != NULL
|
||||||
|| prefix_symbols_string
|
|| prefix_symbols_string
|
||||||
@ -2548,6 +2568,10 @@ copy_main (int argc, char *argv[])
|
|||||||
add_specific_symbol (optarg, &localize_specific_list);
|
add_specific_symbol (optarg, &localize_specific_list);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPTION_GLOBALIZE_SYMBOL:
|
||||||
|
add_specific_symbol (optarg, &globalize_specific_list);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'G':
|
case 'G':
|
||||||
add_specific_symbol (optarg, &keepglobal_specific_list);
|
add_specific_symbol (optarg, &keepglobal_specific_list);
|
||||||
break;
|
break;
|
||||||
@ -2889,6 +2913,10 @@ copy_main (int argc, char *argv[])
|
|||||||
add_specific_symbols (optarg, &localize_specific_list);
|
add_specific_symbols (optarg, &localize_specific_list);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPTION_GLOBALIZE_SYMBOLS:
|
||||||
|
add_specific_symbols (optarg, &globalize_specific_list);
|
||||||
|
break;
|
||||||
|
|
||||||
case OPTION_KEEPGLOBAL_SYMBOLS:
|
case OPTION_KEEPGLOBAL_SYMBOLS:
|
||||||
add_specific_symbols (optarg, &keepglobal_specific_list);
|
add_specific_symbols (optarg, &keepglobal_specific_list);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user