+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>
* po/es.po: Commit new Spanish translation.
-*- 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
--strip-unneeded-symbols, namely for use together with the wildcard
matching the original --strip-symbol/--strip-symbols provided, but
@ifinfo
@c man begin COPYRIGHT
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
under the terms of the GNU Free Documentation License, Version 1.1
@c "objdump", "nm", "size", "strings", "strip", "readelf" and "ranlib".
@c
@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 This text may be freely distributed under the terms of the GNU
@c Free Documentation License.
@vskip 0pt plus 1filll
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
under the terms of the GNU Free Documentation License, Version 1.1
[@option{--strip-unneeded-symbol=}@var{symbolname}]
[@option{-G} @var{symbolname}|@option{--keep-global-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}|@option{--wildcard}]
[@option{-x}|@option{--discard-all}]
[@option{--strip-unneeded-symbols=}@var{filename}]
[@option{--keep-global-symbols=}@var{filename}]
[@option{--localize-symbols=}@var{filename}]
+ [@option{--globalize-symbols=}@var{filename}]
[@option{--weaken-symbols=}@var{filename}]
[@option{--alt-machine-code=}@var{index}]
[@option{--prefix-symbols=}@var{string}]
@itemx --weaken-symbol=@var{symbolname}
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
@itemx --wildcard
Permit regular expressions in @var{symbolname}s used in other command
name per line. Line comments may be introduced by the hash character.
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}
Apply @option{--weaken-symbol} option to each symbol listed in the file
@var{filename}. @var{filename} is simply a flat file, with one symbol
static struct symlist *strip_unneeded_list = NULL;
static struct symlist *keep_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 *weaken_specific_list = NULL;
static struct redefine_node *redefine_sym_list = NULL;
OPTION_STRIP_UNNEEDED_SYMBOLS,
OPTION_KEEP_SYMBOLS,
OPTION_LOCALIZE_SYMBOLS,
+ OPTION_GLOBALIZE_SYMBOL,
+ OPTION_GLOBALIZE_SYMBOLS,
OPTION_KEEPGLOBAL_SYMBOLS,
OPTION_WEAKEN_SYMBOLS,
OPTION_RENAME_SECTION,
{"discard-locals", no_argument, 0, 'X'},
{"format", required_argument, 0, 'F'}, /* Obsolete */
{"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'},
{"impure", no_argument, 0, OPTION_IMPURE},
{"info", no_argument, 0, OPTION_FORMATS_INFO},
--only-keep-debug Strip everything but the debug information\n\
-K --keep-symbol <name> Only copy symbol <name>\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\
-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\
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\
+ --globalize-symbols <file> --globalize-symbol for all 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\
--alt-machine-code <index> Use alternate machine code for output\n\
if (keep && is_strip_section (abfd, bfd_get_section (sym)))
keep = 0;
- if (keep && (flags & BSF_GLOBAL) != 0
- && (weaken || is_specified_symbol (name, weaken_specific_list)))
- {
- sym->flags &=~ BSF_GLOBAL;
- sym->flags |= BSF_WEAK;
- }
- if (keep && !undefined && (flags & (BSF_GLOBAL | BSF_WEAK))
- && (is_specified_symbol (name, localize_specific_list)
- || (keepglobal_specific_list != NULL
- && ! is_specified_symbol (name, keepglobal_specific_list))))
+ if (keep)
{
- sym->flags &= ~(BSF_GLOBAL | BSF_WEAK);
- sym->flags |= BSF_LOCAL;
- }
+ if ((flags & BSF_GLOBAL) != 0
+ && (weaken || is_specified_symbol (name, weaken_specific_list)))
+ {
+ sym->flags &= ~ BSF_GLOBAL;
+ sym->flags |= BSF_WEAK;
+ }
- if (keep)
- to[dst_count++] = sym;
+ if (!undefined
+ && (flags & (BSF_GLOBAL | BSF_WEAK))
+ && (is_specified_symbol (name, localize_specific_list)
+ || (keepglobal_specific_list != NULL
+ && ! is_specified_symbol (name, keepglobal_specific_list))))
+ {
+ sym->flags &= ~ (BSF_GLOBAL | BSF_WEAK);
+ sym->flags |= BSF_LOCAL;
+ }
+
+ 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] = NULL;
|| strip_specific_list != NULL
|| keep_specific_list != NULL
|| localize_specific_list != NULL
+ || globalize_specific_list != NULL
|| keepglobal_specific_list != NULL
|| weaken_specific_list != NULL
|| prefix_symbols_string
add_specific_symbol (optarg, &localize_specific_list);
break;
+ case OPTION_GLOBALIZE_SYMBOL:
+ add_specific_symbol (optarg, &globalize_specific_list);
+ break;
+
case 'G':
add_specific_symbol (optarg, &keepglobal_specific_list);
break;
add_specific_symbols (optarg, &localize_specific_list);
break;
+ case OPTION_GLOBALIZE_SYMBOLS:
+ add_specific_symbols (optarg, &globalize_specific_list);
+ break;
+
case OPTION_KEEPGLOBAL_SYMBOLS:
add_specific_symbols (optarg, &keepglobal_specific_list);
break;