PATCH COMMITTED: Add support for -u to gold
Ian Lance Taylor
iant@google.com
Wed May 7 06:14:00 GMT 2008
This patch adds support for the -u option to gold.
This is slightly complicated by the fact that gold postpones the
decision as to the output format until it sees an input object. This
means that we can not simply add the symbols to the symbol table at
the start of the link, since we don't know the size to use for the
Sized_symbol template class until we find an input object. Since the
first input file might be an archive, we can't ignore the -u options
until we see an input file. So I changed the archive code to
explicitly check the -u options when deciding whether to include a
member. I was then able to postpone adding the -u symbols to the
symbol table until we've seen all the symbols. At that time, if there
are any -u symbols which we never saw, we add them to the symbol table
to be emitted as undefined symbols. This is what happens with GNU ld
as well.
I jumped the gun in handling --no-undefined as the reverse of
--undefined, because it turns out that for GNU ld --undefined is the
long form of -u. So now both --undefined and --no-undefined are
listed, and they are not antonyms.
Because I was adding a new type of symbol--IS_UNDEFINED--I took the
opportunity to clean up the initialization functions to they no longer
rely on overloading to decide what to do. I also renamed CONSTANT to
IS_CONSTANT to make preprocessor collisions less likely.
Ian
2008-05-06 Ian Lance Taylor <iant@google.com>
PR 6049
* options.h (DEFINE_set): Add VARNAME_begin and VARNAME_end
functions.
(class General_options): Remove existing --undefined, and add
--no-undefined instead. Add new --undefined as synonym for -u.
* archive.cc (Archive::add_symbols): Check whether symbol was
named with -u.
* gold.cc (queue_middle_tasks): Add -u symbols to symbol table.
* symtab.h (class Symbol): Rename CONSTANT to IS_CONSTANT; change
all uses. Add IS_UNDEFINED. Update declarations to split
different versions of init_base. Declare init_base_undefined.
(Symbol::is_defined): Handle IS_UNDEFINED.
(Symbol::is_undefined): Likewise.
(Symbol::is_weak_undefined): Call is_undefined.
(Symbol::is_absolute): Handle IS_CONSTANT.
(class Sized_symbol): Update declarations to split different
versions of init. Declare init_undefined.
(class Symbol_table): Declare new functions.
* symtab.cc (Symbol::init_base_object): Rename from init_base.
Change all callers.
(Symbol::init_base_output_data): Likewise.
(Symbol::init_base_output_segment): Likewise.
(Symbol::init_base_constant): Likewise.
(Symbol::init_base_undefined): New function.
(Sized_symbol::init_object): Rename from init. Change all
callers.
(Sized_symbol::init_output_data): Likewise.
(Sized_symbol::init_output_segment): Likewise.
(Sized_symbol::init_constant): Likewise.
(Sized_symbol::init_undefined): New function.
(Symbol_table::add_undefined_symbols_from_command_line): New
function.
(Symbol_table::do_add_undefined_symbols_from_command_line): New
function.
(Symbol::final_value_is_known): Handle IS_UNDEFINED.
(Symbol::output_section): Likewise.
(Symbol::set_output_section): Likewise.
(Symbol_table::sized_finalize_symbol): Likewise.
(Symbol_table::sized_write_globals): Likewise.
* resolve.cc (Symbol_table::should_override): Likewise.
(Symbol::override_base_with_special): Likewise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-patch
Size: 23727 bytes
Desc: Implement -u
URL: <https://sourceware.org/pipermail/binutils/attachments/20080507/1b78ff06/attachment.bin>
More information about the Binutils
mailing list