Check for NULL.
* gold/symtab.cc (Symbol_table::add_from_relobj): Ignore version
symbols during incremental update.
(Symbol_table::add_from_dynobj): Likewise.
segment if -Ttext was specified.
* object.cc (Sized_relobj_file::Sized_relobj_file): Store the ELF
file type.
* object.h (Sized_relobj_file::e_type): New function.
(Sized_relobj_file::e_type_): New data member.
* symtab.cc (Symbol_table::add_from_relobj): Don't add section
base address for ET_EXEC files.
* target.cc (Target::do_make_elf_object_implementation): Allow
ET_EXEC files with --just-symbols option.
* symtab.cc (Symbol_table::add_from_relobj): Mark symbol as referenced
only after checking if it cannot be forced local.
* symtab.h (is_externally_visible): Check if the symbol is not forced
local.
* resolve.cc (Symbol_table::should_override): Add fromtype
parameter. Change all callers. Give error when linking together
TLS and non-TLS symbol.
(Symbol_table::should_override_with_special): Add fromtype
parameter. Change all callers.
* i386.cc (Target_i386::Relocate::relocate_tls): Don't crash if
there is no TLS segment if we have reported some errors.
* x86_64.cc (Target_x86_64::relocate_tls): Likewise.
instead of emit_copy_reloc.
(Copy_relocs::emit_copy_reloc): Refactor.
(Copy_relocs::make_copy_reloc): New function.
(Copy_relocs::add_copy_reloc): Remove.
* copy-relocs.h (Copy_relocs::emit_copy_reloc): Move to public
section.
(Copy_relocs::make_copy_reloc): New function.
(Copy_relocs::add_copy_reloc): Remove.
* gold.cc (queue_middle_tasks): Emit old COPY relocations from
unchanged input files.
* incremental-dump.cc (dump_incremental_inputs): Print "COPY" flag.
* incremental.cc (Sized_incremental_binary::do_reserve_layout):
Reserve BSS space for COPY relocations.
(Sized_incremental_binary::do_emit_copy_relocs): New function.
(Output_section_incremental_inputs::write_info_blocks): Record
whether a symbol is copied from a shared object.
(Sized_incr_dynobj::do_add_symbols): Record COPY relocations.
* incremental.h (enum Incremental_shlib_symbol_flags): New type.
(INCREMENTAL_SHLIB_SYM_FLAGS_SHIFT): New constant.
(Incremental_input_entry_reader::get_output_symbol_index): Add
is_copy parameter.
(Incremental_binary::emit_copy_relocs): New function.
(Incremental_binary::do_emit_copy_relocs): New function.
(Sized_incremental_binary::Sized_incremental_binary): Initialize
new data member.
(Sized_incremental_binary::add_copy_reloc): New function.
(Sized_incremental_binary::do_emit_copy_relocs): New function.
(Sized_incremental_binary::Copy_reloc): New struct.
(Sized_incremental_binary::Copy_relocs): New typedef.
(Sized_incremental_binary::copy_relocs_): New data member.
* symtab.cc (Symbol_table::add_from_incrobj): Change return type.
* symtab.h (Symbol_table::add_from_incrobj): Change return type.
* target.h (Sized_target::emit_copy_reloc): New function.
* x86_64.cc (Target_x86_64::emit_copy_reloc): New function.
info; adjust display of GOT entries.
* incremental.cc (Sized_incremental_binary::setup_readers): Allocate
vector of input objects; remove file_status_.
(Sized_incremental_binary::do_reserve_layout): Remove file_status_.
(Sized_incremental_binary::do_process_got_plt): Adjust calls to
got_plt reader; call target hooks to reserve GOT entries.
(Output_section_incremental_inputs::set_final_data_size): Adjust size
of input file info header and GOT info entry.
(Output_section_incremental_inputs::write_info_blocks): Write dynamic
relocation info.
(Got_plt_view_info::got_descriptor): Remove.
(Got_plt_view_info::sym_index): New data member.
(Got_plt_view_info::input_index): New data member.
(Local_got_offset_visitor::visit): Write input file index.
(Global_got_offset_visitor::visit): Write 0 for input file index.
(Global_symbol_visitor_got_plt::operator()): Replace got_descriptor
with sym_index and input_index.
(Output_section_incremental_inputs::write_got_plt): Adjust size of
incremental info GOT entry; replace got_descriptor with input_index.
(Sized_relobj_incr::Sized_relobj_incr): Adjust initializers; record
map from input file index to object.
(Sized_relobj_incr::do_layout): Replace direct data member reference
with accessor function.
(Sized_relobj_incr::do_for_all_local_got_entries): Move to base class.
* incremental.h (Incremental_input_entry_reader::get_symbol_offset):
Adjust size of input file info header.
(Incremental_input_entry_reader::get_first_dyn_reloc): New function.
(Incremental_input_entry_reader::get_dyn_reloc_count): New function.
(Incremental_input_entry_reader::get_input_section): Adjust size of
input file info header.
(Incremental_got_plt_reader::Incremental_got_plt_reader): Adjust size
of incremental info GOT entry.
(Incremental_got_plt_reader::get_got_desc): Remove.
(Incremental_got_plt_reader::get_got_symndx): New function.
(Incremental_got_plt_reader::get_got_input_index): New function.
(Sized_incremental_binary::Sized_incremental_binary): Remove
file_status_; add input_objects_.
(Sized_incremental_binary::~Sized_incremental_binary): Remove.
(Sized_incremental_binary::set_file_is_unchanged): Remove.
(Sized_incremental_binary::file_is_unchanged): Remove.
(Sized_incremental_binary::set_input_object): New function.
(Sized_incremental_binary::input_object): New function.
(Sized_incremental_binary::file_status_): Remove.
(Sized_incremental_binary::input_objects_): New data member.
(Sized_relobj_incr): Rename Sized_incr_relobj to this; adjust all
references.
(Sized_relobj_incr::invalid_address): Move to base class.
(Sized_relobj_incr::is_output_section_offset_invalid): Move to base
class.
(Sized_relobj_incr::do_output_section_offset): Likewise.
(Sized_relobj_incr::do_for_all_local_got_entries): Likewise.
(Sized_relobj_incr::section_offsets_): Likewise.
* object.cc (Sized_relobj::do_for_all_local_got_entries): New
function.
(Sized_relobj_file::Sized_relobj_file): Remove local_got_offsets_.
(Sized_relobj_file::layout_section): Replace refs to section_offsets_
with accessor function.
(Sized_relobj_file::do_layout): Likewise.
(Sized_relobj_file::do_layout_deferred_sections): Likewise.
(Sized_relobj_file::do_for_all_local_got_entries): Move to base class.
(Sized_relobj_file::compute_final_local_value): Replace refs to
section_offsets_ with accessor function.
(Sized_relobj_file::do_finalize_local_symbols): Likewise.
* object.h (Relobj::Relobj): Initialize new data members.
(Relobj::add_dyn_reloc): New function.
(Relobj::first_dyn_reloc): New function.
(Relobj::dyn_reloc_count): New function.
(Relobj::first_dyn_reloc_): New data member.
(Relobj::dyn_reloc_count_): New data member.
(Sized_relobj): Rename Sized_relobj_base to this; adjust all
references.
(Sized_relobj::Address): New typedef.
(Sized_relobj::invalid_address): Move here from child class.
(Sized_relobj::Sized_relobj): Initialize new data members.
(Sized_relobj::sized_relobj): New function.
(Sized_relobj::is_output_section_offset_invalid): Move here from
child class.
(Sized_relobj::get_output_section_offset): Likewise.
(Sized_relobj::local_has_got_offset): Likewise.
(Sized_relobj::local_got_offset): Likewise.
(Sized_relobj::set_local_got_offset): Likewise.
(Sized_relobj::do_for_all_local_got_entries): Likewise.
(Sized_relobj::clear_got_offsets): New function.
(Sized_relobj::section_offsets): Move here from child class.
(Sized_relobj::do_output_section_offset): Likewise.
(Sized_relobj::do_set_section_offset): Likewise.
(Sized_relobj::Local_got_offsets): Likewise.
(Sized_relobj::local_got_offsets_): Likewise.
(Sized_relobj::section_offsets_): Likewise.
(Sized_relobj_file): Rename Sized_relobj to this; adjust all
references.
(Sized_relobj_file::is_output_section_offset_invalid): Move to base
class.
(Sized_relobj_file::sized_relobj): New function
(Sized_relobj_file::local_has_got_offset): Move to base class.
(Sized_relobj_file::local_got_offset): Likewise.
(Sized_relobj_file::set_local_got_offset): Likewise.
(Sized_relobj_file::get_output_section_offset): Likewise.
(Sized_relobj_file::do_for_all_local_got_entries): Likewise.
(Sized_relobj_file::do_output_section_offset): Likewise.
(Sized_relobj_file::do_set_section_offset): Likewise.
(Sized_relobj_file::Local_got_offsets): Likewise.
(Sized_relobj_file::local_got_offsets_): Likewise.
(Sized_relobj_file::section_offsets_): Likewise.
* output.cc (Output_reloc::Output_reloc): Adjust type of relobj
(all constructors).
(set_needs_dynsym_index): Convert relobj to derived class pointer.
(Output_reloc::get_symbol_index): Likewise.
(Output_reloc::local_section_offset): Likewise.
(Output_reloc::get_address): Likewise.
(Output_reloc::symbol_value): Likewise.
(Output_data_got::reserve_slot): Move to class definition.
(Output_data_got::reserve_local): New function.
(Output_data_got::reserve_slot_for_global): Remove.
(Output_data_got::reserve_global): New function.
* output.h (Output_reloc::Output_reloc): Adjust type of relobj
(all constructors, two instantiations).
(Output_reloc::get_relobj): New function (two instantiations).
(Output_reloc::u1_.relobj, Output_reloc::u2_.relobj): Adjust type.
(Output_data_reloc_base::add): Convert relobj to derived class pointer.
(Output_data_reloc::add_global): Adjust type of relobj.
(Output_data_reloc::add_global_relative): Likewise.
(Output_data_reloc::add_symbolless_global_addend): Likewise.
(Output_data_reloc::add_local): Likewise.
(Output_data_reloc::add_local_relative): Likewise.
(Output_data_reloc::add_symbolless_local_addend): Likewise.
(Output_data_reloc::add_local_section): Likewise.
(Output_data_reloc::add_output_section): Likewise.
(Output_data_reloc::add_absolute): Likewise.
(Output_data_reloc::add_target_specific): Likewise.
(Output_data_got::reserve_slot): Move definition here.
(Output_data_got::reserve_local): New function.
(Output_data_got::reserve_global): New function.
* reloc.cc (Sized_relobj_file::do_read_relocs): Replace refs to
section_offsets_ with accessor function.
(Sized_relobj_file::write_sections): Likewise.
(Sized_relobj_file::do_relocate_sections): Likewise.
* target.h (Sized_target::reserve_local_got_entry): New function.
(Sized_target::reserve_global_got_entry): New function.
* x86_64.cc (Target_x86_64::reserve_local_got_entry): New function.
(Target_x86_64::reserve_global_got_entry): New function.
(Target_x86_64::init_got_plt_for_update): Create rela_dyn section.
report_object.
(Add_archive_symbols::run): Track argument serial numbers.
(Lib_group::include_member): Likewise.
(Add_lib_group_symbols::run): Adjust call to report_archive_begin.
* archive.h (Incremental_archive_entry::Archive_member):
Initialize arg_serial_.
(Archive_member::arg_serial_): New data member.
* dynobj.cc (Dynobj::Dynobj): Allow input_file_ to be NULL.
(Sized_dynobj::do_add_symbols): Track symbols when doing an
incremental link.
(Sized_dynobj::do_for_all_local_got_entries): New function.
* dynobj.h: (Sized_dynobj::do_for_all_local_got_entries): New
function.
* fileread.cc (get_mtime): New function.
* fileread.h (get_mtime): New function.
* gold.cc (queue_initial_tasks): Check for incremental update.
(process_incremental_input): New function.
(queue_middle_tasks): Don't force valid target for incremental
update.
* incremental-dump.cc (find_input_containing_global): Adjust
size of symbol info entry.
(dump_incremental_inputs): Dump argument serial number and
in_system_directory flag; bias shndx by 1; print symbol names
when dumping per-file symbol lists; use new symbol info readers.
* incremental.cc
(Output_section_incremental_inputs:update_data_size): New function.
(Sized_incremental_binary::setup_readers): Setup input readers
for each input file; build maps for files added from libraries
and scripts.
(Sized_incremental_binary::check_input_args): New function.
(Sized_incremental_binary::do_check_inputs): Build map of argument
serial numbers to input arguments.
(Sized_incremental_binary::do_file_has_changed): Rename
do_file_is_unchanged to this; compare file modification times.
(Sized_incremental_binary::do_init_layout): New function.
(Sized_incremental_binary::do_reserve_layout): New function.
(Sized_incremental_binary::do_get_input_reader): Remove.
(Sized_incremental_binary::get_symtab_view): New function.
(Incremental_checker::can_incrementally_link_output_file): Remove.
(Incremental_inputs::report_command_line): Exclude --debug options.
(Incremental_inputs::report_archive_begin): Add parameter; track
argument serial numbers; don't put input file entry for archive
before archive members.
(Incremental_inputs::report_archive_end): Put input file entry
for archive after archive members.
(Incremental_inputs::report_object): Add parameter; track argument
serial numbers and in_system_directory flag.
(Incremental_inputs::report_script): Add parameter; track argument
serial numbers.
(Output_section_incremental_inputs::set_final_data_size): Adjust
size of symbol info entry; check for forwarding symbols.
(Output_section_incremental_inputs::write_input_files): Write
in_system_directory flag and argument serial number.
(Output_section_incremental_inputs::write_info_blocks): Map section
indices between incremental info and original input file; store
input section index for each symbol.
(class Local_got_offset_visitor): Derive from Got_offset_list::Visitor;
change operator() to visit().
(class Global_got_offset_visitor): Likewise.
(class Global_symbol_visitor_got_plt):
(Output_section_incremental_inputs::write_got_plt): Use new visitor
classes.
(Sized_incr_relobj::Sized_incr_relobj): New constructor.
(Sized_incr_relobj::do_read_symbols): New function.
(Sized_incr_relobj::do_layout): New function.
(Sized_incr_relobj::do_layout_deferred_sections): New function.
(Sized_incr_relobj::do_add_symbols): New function.
(Sized_incr_relobj::do_should_include_member): New function.
(Sized_incr_relobj::do_for_all_global_symbols): New function.
(Sized_incr_relobj::do_for_all_local_got_entries): New function.
(Sized_incr_relobj::do_section_size): New function.
(Sized_incr_relobj::do_section_name): New function.
(Sized_incr_relobj::do_section_contents): New function.
(Sized_incr_relobj::do_section_flags): New function.
(Sized_incr_relobj::do_section_entsize): New function.
(Sized_incr_relobj::do_section_address): New function.
(Sized_incr_relobj::do_section_type): New function.
(Sized_incr_relobj::do_section_link): New function.
(Sized_incr_relobj::do_section_info): New function.
(Sized_incr_relobj::do_section_addralign): New function.
(Sized_incr_relobj::do_initialize_xindex): New function.
(Sized_incr_relobj::do_get_global_symbol_counts): New function.
(Sized_incr_relobj::do_read_relocs): New function.
(Sized_incr_relobj::do_gc_process_relocs): New function.
(Sized_incr_relobj::do_scan_relocs): New function.
(Sized_incr_relobj::do_count_local_symbols): New function.
(Sized_incr_relobj::do_finalize_local_symbols): New function.
(Sized_incr_relobj::do_set_local_dynsym_indexes): New function.
(Sized_incr_relobj::do_set_local_dynsym_offset): New function.
(Sized_incr_relobj::do_relocate): New function.
(Sized_incr_relobj::do_set_section_offset): New function.
(Sized_incr_dynobj::Sized_incr_dynobj): New function.
(Sized_incr_dynobj::do_read_symbols): New function.
(Sized_incr_dynobj::do_layout): New function.
(Sized_incr_dynobj::do_add_symbols): New function.
(Sized_incr_dynobj::do_should_include_member): New function.
(Sized_incr_dynobj::do_for_all_global_symbols): New function.
(Sized_incr_dynobj::do_for_all_local_got_entries): New function.
(Sized_incr_dynobj::do_section_size): New function.
(Sized_incr_dynobj::do_section_name): New function.
(Sized_incr_dynobj::do_section_contents): New function.
(Sized_incr_dynobj::do_section_flags): New function.
(Sized_incr_dynobj::do_section_entsize): New function.
(Sized_incr_dynobj::do_section_address): New function.
(Sized_incr_dynobj::do_section_type): New function.
(Sized_incr_dynobj::do_section_link): New function.
(Sized_incr_dynobj::do_section_info): New function.
(Sized_incr_dynobj::do_section_addralign): New function.
(Sized_incr_dynobj::do_initialize_xindex): New function.
(Sized_incr_dynobj::do_get_global_symbol_counts): New function.
(make_sized_incremental_object): New function.
(Incremental_library::copy_unused_symbols): New function.
(Incremental_library::do_for_all_unused_symbols): New function.
* incremental.h (enum Incremental_input_flags): New type.
(class Incremental_checker): Remove.
(Incremental_input_entry::Incremental_input_entry): Add argument
serial number.
(Incremental_input_entry::arg_serial): New function.
(Incremental_input_entry::set_is_in_system_directory): New function.
(Incremental_input_entry::is_in_system_directory): New function.
(Incremental_input_entry::arg_serial_): New data member.
(Incremental_input_entry::is_in_system_directory_): New data member.
(class Script_info): Move here from script.h.
(Script_info::Script_info): Add filename parameter.
(Script_info::filename): New function.
(Script_info::filename_): New data member.
(Incremental_script_entry::Incremental_script_entry): Add argument
serial number.
(Incremental_object_entry::Incremental_object_entry): Likewise.
(Incremental_object_entry::add_input_section): Build list of input
sections with map to original shndx.
(Incremental_object_entry::get_input_section_index): New function.
(Incremental_object_entry::shndx_): New data member.
(Incremental_object_entry::name_key_): Rename; adjust all refs.
(Incremental_object_entry::sh_size_): Rename; adjust all refs.
(Incremental_archive_entry::Incremental_archive_entry): Add argument
serial number.
(Incremental_inputs::report_archive_begin): Likewise.
(Incremental_inputs::report_object): Likewise.
(Incremental_inputs::report_script): Likewise.
(class Incremental_global_symbol_reader): New class.
(Incremental_input_entry_reader::Incremental_input_entry_reader): Read
and store flags and input file type.
(Incremental_input_entry_reader::arg_serial): New function.
(Incremental_input_entry_reader::type): Extract type from flags.
(Incremental_input_entry_reader::is_in_system_directory): New function.
(Incremental_input_entry_reader::get_input_section_count): Call
accessor function for type.
(Incremental_input_entry_reader::get_symbol_offset): Call accessor
function for type; adjust size of global symbol entry.
(Incremental_input_entry_reader::get_global_symbol_count): Call
accessor function for type.
(Incremental_input_entry_reader::get_object_count): Likewise.
(Incremental_input_entry_reader::get_object_offset): Likewise.
(Incremental_input_entry_reader::get_member_count): Likewise.
(Incremental_input_entry_reader::get_unused_symbol_count): Likewise.
(Incremental_input_entry_reader::get_member_offset): Likewise.
(Incremental_input_entry_reader::get_unused_symbol): Likewise.
(Incremental_input_entry_reader::Global_symbol_info): Remove.
(Incremental_input_entry_reader::get_global_symbol_info): Remove.
(Incremental_input_entry_reader::get_global_symbol_reader): New
function.
(Incremental_input_entry_reader::get_output_symbol_index): New
function.
(Incremental_input_entry_reader::type_): Remove.
(Incremental_input_entry_reader::flags_): New data member.
(Incremental_inputs_reader::input_file_offset): New function.
(Incremental_inputs_reader::input_file_index): New function.
(Incremental_inputs_reader::input_file): Call input_file_offset.
(Incremental_inputs_reader::input_file_at_offset): New function.
(Incremental_relocs_reader::get_r_type): Reformat.
(Incremental_relocs_reader::get_r_shndx): Reformat.
(Incremental_relocs_reader::get_r_offset): Reformat.
(Incremental_relocs_reader::data): New function.
(Incremental_binary::Incremental_binary): Initialize new data members.
(Incremental_binary::check_inputs): Add cmdline parameter.
(Incremental_binary::file_is_unchanged): Remove.
(Input_reader::arg_serial): New function.
(Input_reader::get_unused_symbol_count): New function.
(Input_reader::get_unused_symbol): New function.
(Input_reader::do_arg_serial): New function.
(Input_reader::do_get_unused_symbol_count): New function.
(Input_reader::do_get_unused_symbol): New function.
(Incremental_binary::input_file_count): New function.
(Incremental_binary::get_input_reader): Change signature to use
index instead of filename.
(Incremental_binary::file_has_changed): New function.
(Incremental_binary::get_input_argument): New function.
(Incremental_binary::get_library): New function.
(Incremental_binary::get_script_info): New function.
(Incremental_binary::init_layout): New function.
(Incremental_binary::reserve_layout): New function.
(Incremental_binary::output_file): New function.
(Incremental_binary::do_check_inputs): New function.
(Incremental_binary::do_file_is_unchanged): Remove.
(Incremental_binary::do_file_has_changed): New function.
(Incremental_binary::do_init_layout): New function.
(Incremental_binary::do_reserve_layout): New function.
(Incremental_binary::do_input_file_count): New function.
(Incremental_binary::do_get_input_reader): Change signature.
(Incremental_binary::input_args_map_): New data member.
(Incremental_binary::library_map_): New data member.
(Incremental_binary::script_map_): New data member.
(Sized_incremental_binary::Sized_incremental_binary): Initialize
new data members.
(Sized_incremental_binary::output_section): New function.
(Sized_incremental_binary::inputs_reader): Add const.
(Sized_incremental_binary::symtab_reader): Add const.
(Sized_incremental_binary::relocs_reader): Add const.
(Sized_incremental_binary::got_plt_reader): Add const.
(Sized_incremental_binary::get_symtab_view): New function.
(Sized_incremental_binary::Inputs_reader): New typedef.
(Sized_incremental_binary::Input_entry_reader): New typedef.
(Sized_incremental_binary::do_check_inputs): Add cmdline parameter.
(Sized_incremental_binary::do_file_is_unchanged): Remove.
(Sized_incremental_binary::do_file_has_changed): New function.
(Sized_incremental_binary::do_init_layout): New function.
(Sized_incremental_binary::do_reserve_layout): New function.
(Sized_input_reader::Inputs_reader): Remove.
(Sized_input_reader::Input_entry_reader): Remove.
(Sized_input_reader::do_arg_serial): New function.
(Sized_input_reader::do_get_unused_symbol_count): New function.
(Sized_input_reader::do_get_unused_symbol): New function.
(Sized_incremental_binary::do_input_file_count): New function.
(Sized_incremental_binary::do_get_input_reader): Change signature;
use index instead of filename.
(Sized_incremental_binary::section_map_): New data member.
(Sized_incremental_binary::input_entry_readers_): New data member.
(class Sized_incr_relobj): New class.
(class Sized_incr_dynobj): New class.
(make_sized_incremental_object): New function.
(class Incremental_library): New class.
* layout.cc (Free_list::num_lists): New static data member.
(Free_list::num_nodes): New static data member.
(Free_list::num_removes): New static data member.
(Free_list::num_remove_visits): New static data member.
(Free_list::num_allocates): New static data member.
(Free_list::num_allocate_visits): New static data member.
(Free_list::init): New function.
(Free_list::remove): New function.
(Free_list::allocate): New function.
(Free_list::dump): New function.
(Free_list::print_stats): New function.
(Layout_task_runner::run): Resize output file for incremental updates.
(Layout::Layout): Initialize new data members.
(Layout::set_incremental_base): New function.
(Layout::init_fixed_output_section): New function.
(Layout::layout_eh_frame): Do not build .eh_frame_hdr section for
incremental updates.
(Layout::create_gold_note): Do not create gold note section for
incremental updates.
(Layout::set_segment_offsets): Do not recalculate RELRO alignment
for incremental updates.
(Layout::set_section_offsets): For incremental updates, allocate space
from free list.
(Layout::create_symtab_sections): Layout with offsets relative to
start of section; for incremental updates, allocate space from free
list.
(Layout::create_shdrs): For incremental updates, allocate space from
free list.
(Layout::finish_dynamic_section): For incremental updates, do not
check --as-needed (fixed in subsequent patch).
* layout.h (class Free_list): New class.
(Layout::set_incremental_base): New function.
(Layout::incremental_base): New function.
(Layout::init_fixed_output_section): New function.
(Layout::allocate): New function.
(Layout::incremental_base_): New data member.
(Layout::free_list_): New data member.
* main.cc (main): Print Free_list statistics.
* object.cc (Relobj::finalize_incremental_relocs): Add
clear_counts parameter; clear counts only when clear_counts is set.
(Sized_relobj::Sized_relobj): Initialize new base class.
(Sized_relobj::do_layout): Don't report special sections.
(Sized_relobj::do_for_all_local_got_entries): New function.
(Sized_relobj::write_local_symbols): Add symtab_off parameter; add
symtab_off to all symbol table offsets.
(Sized_relobj::do_get_global_symbol_counts): Add typename keyword.
* object.h (class Got_offset_list): Move to top of file.
(Object::Object): Allow case where input_file == NULL.
(Object::~Object): Likewise.
(Object::input_file): Assert that input_file != NULL.
(Object::lock): Allow case where input_file == NULL.
(Object::unlock): Likewise.
(Object::is_locked): Likewise.
(Object::token): Likewise.
(Object::release): Likewise.
(Object::is_incremental): New function.
(Object::get_mtime): New function.
(Object::for_all_local_got_entries): New function.
(Object::clear_view_cache_marks): Allow case where input_file == NULL.
(Object::set_is_in_system_directory): New function.
(Object::is_in_system_directory): New function.
(Object::do_is_incremental): New function.
(Object::do_get_mtime): New function.
(Object::do_for_all_local_got_entries): New function.
(Object::is_in_system_directory_): New data member.
(Relobj::finalize_incremental_relocs): Add clear_counts parameter.
(class Sized_relobj_base): New class.
(class Sized_relobj): Derive from Sized_relobj_base.
(class Sized_relobj::Symbols): Redeclare from base class.
(class Sized_relobj::local_got_offset_list): Remove.
(class Sized_relobj::Output_sections): Redeclare from base class.
(class Sized_relobj::do_for_all_local_got_entries): New function.
(class Sized_relobj::write_local_symbols): Add offset parameter.
(class Sized_relobj::local_symbol_offset_): Update comment.
(class Sized_relobj::local_dynsym_offset_): Update comment.
* options.cc (Input_arguments::add_file): Remove const.
* options.h (Input_file_argument::Input_file_argument):
Initialize arg_serial_ (all constructors).
(Input_file_argument::set_arg_serial): New function.
(Input_file_argument::arg_serial): New function.
(Input_file_argument::arg_serial_): New data member.
(Input_arguments::Input_arguments): Initialize file_count_.
(Input_arguments::add_file): Remove const.
(Input_arguments::number_of_input_files): New function.
(Input_arguments::file_count_): New data member.
(Command_line::number_of_input_files): Call
Input_arguments::number_of_input_files.
* output.cc (Output_segment_headers::Output_segment_headers):
Set current size.
(Output_section::Input_section::current_data_size): New function.
(Output_section::Output_section): Initialize new data members.
(Output_section::add_input_section): Don't do merge sections for
an incremental link; allocate space from free list for an
incremental update.
(Output_section::add_output_section_data): Allocate space from
free list for an incremental update.
(Output_section::update_data_size): New function.
(Output_section::set_fixed_layout): New function.
(Output_section::reserve): New function.
(Output_segment::set_section_addresses): Remove const.
(Output_segment::set_section_list_addresses): Remove const; allocate
space from free list for an incremental update.
(Output_segment::set_offset): Adjust size of RELRO segment for an
incremental update.
* output.h (Output_data::current_data_size): Move here from
child classes.
(Output_data::pre_finalize_data_size): New function.
(Output_data::update_data_size): New function.
(Output_section_headers::update_data_size): new function.
(Output_section_data_build::current_data_size): Move to Output_data.
(Output_data_strtab::update_data_size): New function.
(Output_section::current_data_size): Move to Output_data.
(Output_section::set_fixed_layout): New function.
(Output_section::has_fixed_layout): New function.
(Output_section::reserve): New function.
(Output_section::update_data_size): New function.
(Output_section::has_fixed_layout_): New data member.
(Output_section::free_list_): New data member.
(Output_segment::set_section_addresses): Remove const.
(Output_segment::set_section_list_addresses): Remove const.
* plugin.cc (Sized_pluginobj::do_for_all_local_got_entries):
New function.
* plugin.h (Sized_pluginobj::do_for_all_local_got_entries):
New function.
* readsyms.cc (Read_symbols::do_read_symbols): Add library
parameter when calling Add_symbols constructor; store argument
serial number for members of a lib group.
(Add_symbols::locks): Allow case where token == NULL.
(Add_symbols::run): Report libraries denoted by --start-lib/--end-lib.
(Read_member::~Read_member): New function.
(Read_member::is_runnable): New function.
(Read_member::locks): New function.
(Read_member::run): New function.
(Check_script::~Check_script): New function.
(Check_script::is_runnable): New function.
(Check_script::locks): New function.
(Check_script::run): New function.
(Check_library::~Check_library): New function.
(Check_library::is_runnable): New function.
(Check_library::locks): New function.
(Check_library::run): New function.
* readsyms.h (Add_symbols::Add_symbols): Add library parameter.
(Add_symbols::library_): New data member.
(class Read_member): New class.
(class Check_script): New class.
(class Check_library): New class.
* reloc.cc (Read_relocs::is_runnable): Allow case where
token == NULL.
(Read_relocs::locks): Likewise.
(Scan_relocs::locks): Likewise.
(Relocate_task::locks): Likewise.
(Sized_relobj::do_scan_relocs): Tell finalize_incremental_relocs
to clear counters.
(Sized_relobj::incremental_relocs_scan): Fix comment.
(Sized_relobj::do_relocate): Pass output file offset to
write_local_symbols.
(Sized_relobj::incremental_relocs_write_reltype): Use reloc_size
from class declaration.
* script.cc (read_input_script): Allocate Script_info; pass
argument serial number to report_script.
* script.h (class Script_info): Move to incremental.h.
* symtab.cc (Symbol_table::add_from_incrobj): New function.
* symtab.h (Symbol_table::add_from_incrobj): New function.
(Symbol_table::set_file_offset): New function.
but mark earlier ones as non-canonical
(offset_to_iterator): Update search target and example
(do_addr2line): Return extra lines in a vector*
(format_file_lineno): Extract from do_addr2line
(one_addr2line): Add vector* out-param
* dwarf_reader.h (Offset_to_lineno_entry): New field recording
when a lineno entry appeared last for its instruction
(Dwarf_line_info): Add vector* out-param
* object.cc (Relocate_info): Pass NULL for the vector* out-param
* symtab.cc (Odr_violation_compare): Include the lineno in the
comparison again.
(linenos_from_loc): New. Combine the canonical line for an
address with its other lines.
(True_if_intersect): New. Helper functor to make
std::set_intersection a query.
(detect_odr_violations): Compare sets of lines instead of just
one line for each function. This became less deterministic, but
has fewer false positives.
* symtab.h: Declarations.
* testsuite/Makefile.am (odr_violation2.o): Compile with -O2 to
mix an optimized and non-optimized object in the same binary
(odr_violation2.so): Same.
* testsuite/Makefile.in: Regenerate from Makefile.am.
* testsuite/debug_msg.cc (main): Make OdrDerived classes.
* testsuite/debug_msg.sh: Update line numbers and add
assertions.
* testsuite/odr_violation1.cc: Use OdrDerived, in a
non-optimized context.
* testsuite/odr_violation2.cc: Make sure Ordering::operator()
isn't inlined, and use OdrDerived in an optimized context.
* testsuite/odr_header1.h: Defines OdrDerived, where
optimization will change the
first-instruction-in-the-destructor's file and line number.
* testsuite/odr_header2.h: Defines OdrBase.
* symtab.cc (Symbol::should_add_dynsym_entry) Return false for
plugin only symbols.
(Symbol_table::sized_finalize_symbol) Mark symbol only present
in plugin files as not needed in the symbol table.
(Plugin_manager::claim_file): Set any_claimed_.
(Plugin_manager::save_archive): New function.
(Plugin_manager::save_input_group): New function.
(Plugin_manager::all_symbols_read): Create Plugin_rescan task if
necessary.
(Plugin_manager::new_undefined_symbol): New function.
(Plugin_manager::rescan): New function.
(Plugin_manager::rescannable_defines): New function.
(Plugin_manager::add_input_file): Set any_added_.
* plugin.h (class Plugin_manager): define new fields rescannable_,
undefined_symbols_, any_claimed_, and any_added_. Declare
Plugin_rescan as friend. Declare new functions.
(Plugin_manager::Rescannable): Define type.
(Plugin_manager::Rescannable_list): Define type.
(Plugin_manager::Undefined_symbol_list): Define type.
(Plugin_manager::Plugin_manager): Initialize new fields.
* archive.cc (Archive::defines_symbol): New function.
(Add_archive_symbols::run): Pass archive to plugins if any.
* archive.h (class Archive): Declare defines_symbol.
* readsyms.cc (Input_group::~Input_group): New function.
(Finish_group::run): Pass input_group to plugins if any.
* readsyms.h (class Input_group): Declare destructor.
* symtab.cc (add_from_object): Pass undefined symbol to plugins if
any.
Doug Kwan <dougkwan@google.com>
* resolve.cc (Symbol_table::should_override): When a weak dynamic
defintion overrides non-weak undef, remember that the original undef
is not weak.
* symtab.cc (Symbol_table::sized_write_global): For undef without
an original weak binding, set binding to global in output.
* testsuite/Makefile.am: Add new test strong_ref_weak_def.
* testsuite/Makefile.in: Regenerate.
* testsuite/strong_ref_weak_def.sh: New file.
* testsuite/strong_ref_weak_def_1.c: Ditto.
* testsuite/strong_ref_weak_def_2.c: Ditto.
weak when resolving to a dynamic def.
(Symbol_table::should_override): Add adjust_dyndef flag; set it
for weak undef/dynamic def cases. Adjust callers.
* symtab.cc (Symbol::init_fields): Initialize undef_binding_set_ and
undef_binding_weak_.
(Symbol_table::sized_write_globals): Adjust symbol binding.
(Symbol_table::sized_write_symbol): Add binding parameter.
* symtab.h (Symbol::set_undef_binding): New method.
(Symbol::is_undef_binding_weak): New method.
(Symbol::undef_binding_set_, Symbol::undef_binding_weak_): New members.
(Symbol_table::should_override): Add new parameter.
(Symbol_table::sized_write_symbol): Add new parameter.
* testsuite/weak_undef_file1.cc: Add new test case.
* testsuite/weak_undef_file2.cc: Fix header comment.
* testsuite/weak_undef_test.cc: Add new test case.
* icf.cc (get_section_contents): Check for preemptible functions.
Ignore addend when appropriate.
* symtab.cc (should_add_dynsym_entry): Add new parameter. Check for
section folded.
(add_from_relobj): Check for section folded.
(set_dynsym_indexes): Fix call to should_add_dynsym_entry.
* symtab.h (should_add_dynsym_entry): Add new parameter.
* target-reloc.h (scan_relocs): Check for section folded.
* x86_64.cc (Target_x86_64::Scan::possible_function_pointer_reloc):
Check reloc types for function pointers in shared objects.
* testsuite/Makefile.am (icf_virtual_function_folding_test): New test
case.
(icf_preemptible_functions_test): New test case.
(icf_string_merge_test): New test case.
* testsuite.Makefile.in: Regenerate.
* testsuite/icf_safe_so_test.sh: Change to not fold foo_glob and
bar_glob. Refactor code.
* testsuite/icf_preemptible_functions_test.cc: New file.
* testsuite/icf_preemptible_functions_test.sh: New file.
* testsuite/icf_string_merge_test.cc: New file.
* testsuite/icf_string_merge_test.sh: New file.
* testsuite/icf_virtual_function_folding_test.cc: New file.
* testsuite/icf_virtual_function_folding_test.sh: New file.
of 2009-12-30.
(Version_script_info::Version_script_info): Initialize globs_,
default_version_, default_is_global_, and exact_. Don't
initialize globals_ or locals_.
(Version_script_info::build_lookup_tables): Build local symbols
first.
(Version_script_info::unquote): New function.
(Version_script_info::add_exact_match): New function.
(Version_script_info::build_expression_list_lookup): Remove lookup
parameter. Add is_global parameter. Change all callers. Handle
wildcard pattern specially. Unquote pattern. Call
add_exact_match.
(Version_script_info::get_name_to_match): New function.
(Version_script_info::get_symbol_version): New function.
(Version_script_info::get_symbol_version_helper): Remove.
(Version_script_info::check_unmatched_names): Call unquote.
* script.h (class Version_script_info): Change get_symbol_version
to be non-inline and add is_global parameter; change all callers.
Rewrite symbol_is_local. Update declarations. Define struct
Version_tree_match, Exact, Globs. Don't define struct Lookup.
Remove globals_ and locals_ members. Add exact_, globs_,
default_version_, is_global_.
(Version_script_info::Glob): Remove pattern, add expression and
is_global. Update constructor. Change all callers.
* dynobj.cc (Versions::finalize): Mark the version symbol as the
default version.
(Versions::symbol_section_contents): If a symbol is undefined, or
defined in a dynamic object, set the version index to
VER_NDX_LOCAL.
* symtab.cc (Symbol_table::add_from_relobj): Don't call
symbol_is_local.
(Symbol_table::add_from_pluginobj): Likewise.
* testsuite/ver_matching_test.sh: blaza1 and blaza go into V2.
* symtab.h (class Symbol): Remove fields is_target_special_ and
has_plt_offset_. Add field is_defined_in_discarded_section_.
(Symbol::is_defined_in_discarded_section): New function.
(Symbol::set_is_defined_in_discarded_section): New function.
(Symbol::has_plt_offset): Rewrite.
(Symbol::set_plt_offset): Verify that new offset is not -1U.
* symtab.cc (Symbol::init_fields): Initialize plt_offset_ to -1U.
Don't initialize is_target_special_ or has_plt_offset_.
Initialize is_defined_in_discarded_section_.
(Symbol_table::add_from_relobj): If appropriate, set
is_defined_in_discarded_section.
* resolve.cc (Symbol::override_base_with_special): Don't test
is_target_special_. Change has_plt_offset_ to has_plt_offset().
* target-reloc.h (relocate_section): Do special handling for
symbols defined in discarded sections for global symbols as well
as local symbols.
to is_default_version. Rename insdef to insdefault.
(Symbol_table::add_from_relobj): Rename def to is_default_version
and local to is_forced_local.
(Symbol_table::add_from_pluginobj): Likewise.
(Symbol_table::add_from_dynobj): Likewise.
(Symbol_table::define_special_symbol): Rename insdef to
insdefault.
* symtab.cc (Symbol_table::add_from_relobj): When not exporting
symbols from this object, don't change the visibility of an
undefined symbol.
* testsuite/exclude_libs_test_1.c (lib1_ref): New function.
* arm.cc (Arm_relobj::scan_sections_for_stubs): Exclude ICF-eliminated
sections.
* object.cc (Sized_relobj::do_finalize_local_symbols): Handle
relaxed input sections.
* output.cc (Output_section::find_relaxed_input_section): Change
return type to Output_relaxed_input_section pointer. Adjust code
for new type of relaxed_input_section_map_.
* output.h (Output_section::find_relaxed_input_section): Change
return type to Output_relaxed_input_section pointer.
(Output_section::Output_relaxed_input_section_by_input_section_map):
New type.
(Output_section::relaxed_input_section_map_): Change type to
Output_section::Output_relaxed_input_section_by_input_section_map.
* symtab.cc (Symbol_table::compute_final_value): Handle relaxed
input section.
PR gold/10893
* i386.cc (Target_i386::Scan::globa): Use is_func instead of
checking elfcpp::STT_FUNC.
(Target_i386::Relocate::relocate): Likewise.
* x86_64.cc (Target_x86_64::Scan::global): Likewise.
* symtab.cc (Symbol_table::sized_write_symbol): Turn IFUNC
symbols from shared libraries into normal FUNC symbols.
* symtab.h (Symbol): Add is_func and use it.
* object.h (class Object): Add is_needed and set_is_needed
methods. Add is_needed_ field. Make bool fields into bitfields.
* symtab.cc (Symbol_table::set_dynsym_indexes): If a symbol is
defined in a dynamic object and referenced by a regular object,
set is_needed for the dynamic object.
* layout.cc (Layout::finish_dynamic_section): Don't add DT_NEEDED
if the file is marked with as_needed and it is not needed.
* options.h (class General_options): Add -pie and
--pic-executable.
(General_options::output_is_position_independent): Test -pie.
(General_options::output_is_executable): Return true if not shared
and not relocatable.
(General_options::output_is_pie): Remove.
* options.cc (General_options::finalize): Reject incompatible uses
of -pie.
* gold.cc (queue_middle_tasks): A -pie link is not static.
* symtab.h (Symbol::needs_plt_entry): Return false if -pie.
* symtab.cc (Symbol::final_value_is_known): Return false if
output_is_position_independent.
* layout.cc (Layout::set_segment_offsets): Start at address 0 if
output_is_position_independent.
* output.cc (Output_file_header::do_sized_write): Use ET_DYN if
output_is_position_independent.
* i386.cc (Output_data_plt_i386::do_write): Use the PIC PLT if
output_is_position_independent.
* testsuite/Makefile.am (check_PROGRAMS): Add basic_pie_test and
two_file_pie_test.
(basic_pie_test.o, basic_pie_test): New targets.
(two_file_test_1_pie.o, two_file_test_1b_pie.o): New targets.
(two_file_test_2_pie.o, two_file_test_main_pie.o): New targets.
(two_file_pie_test): New target.
* testsuite/Makefile.in: Rebuild.
* README: Remove note saying that -pie is not supported.
function.
* gold.cc (queue_initial_tasks): Likewise.
(queue_middle_tasks): Likewise.
* object.cc (do_layout): Likewise.
* symtab.cc (is_section_folded): Likewise.
* main.cc (main): Likewise.
* reloc.cc (Read_relocs::run): Likewise.
(Sized_relobj::do_scan_relocs): Likewise.
* icf.cc (is_function_ctor_or_dtor): New function.
(Icf::find_identical_sections): Check if function is ctor or dtor when
safe icf is chosen.
* options.h (General_options::icf): Change option to be an enum.
(Icf_status): New enum.
(icf_enabled): New method.
(icf_safe_folding): New method.
(set_icf_status): New method.
(icf_status_): New variable.
* (options.cc) (General_options::finalize): Set icf_status_.
* testsuite/Makefile.am: Add commands to build icf_safe_test. Modify
icf_test and icf_keep_unique_test to use the --icf enum flag.
* testsuite/icf_safe_test.sh: New file.
* testsuite/icf_safe_test.cc: New file.
* layout.cc (Layout::make_output_section): Call target hook to make
ordinary output section.
(Layout::finalize): Adjust parameter list of call the
Target::may_relax().
* layout.h (class Layout::section_list): New method.
* merge.h (Output_merge_base::entsize): Change visibility to public.
(Output_merge_base::is_string, Output_merge_base::do_is_string):
New methods.
(Output_merge_string::do_is_string): New method.
* object.cc (Sized_relobj::do_setup): renamed from
Sized_relobj::set_up.
* object.h (Sized_relobj::adjust_shndx,
Sized_relobj::initializ_input_to_output_maps,
Sized_relobj::free_input_to_output_maps): Change visibilities to
protected.
(Sized_relobj::setup): Virtualize.
(Sized_relobj::do_setup): New method declaration.
(Sized_relobj::invalidate_section_offset,
Sized_relobj::do_invalidate_section_offset): New method decfinitions.
(Sized_relobj::elf_file, Sized_relobj::local_values): New methods.
* options.cc (parse_int): New function.
* options.h (parse_int): New declaration.
(DEFINE_int): New macro.
(stub_group_size): New option.
* output.cc (Output_section::Output_section): Initialize memebers
merge_section_map_, merge_section_by_properties_map_,
relaxed_input_section_map_, is_relaxed_input_section_map_valid_.
(Output_section::add_input_section): Handled deferred code-fill
generation and remove an old comment.
(Output_section::add_relaxed_input_section): New method definition.
(Output_section::add_merge_input_section): Use merge section by
properties map to speed to search. Update merge section maps
as appropriate.
(Output_section::build_relaxation_map): New method definition.
(Output_section::convert_input_sections_in_list_to_relaxed_sections):
Same.
(Output_section::relax_input_section): Renamed to
Output_section::convert_input_sections_to_relaxed_sections and change
interface to take a vector of pointers to relaxed sections.
(Output_section::find_merge_section,
Output_section::find_relaxed_input_section): New method definitions.
(Output_section::is_input_address_mapped,
Output_section::output_offset, Output_section::output_address):
Use output section data maps to speed up searching.
(Output_section::find_starting_output_address): Add comments.
(Output_section::do_write,
Output_section::write_to_postprocessing_buffer): Do code-fill
generation as appropriate.
(Output_section::get_input_sections): Invalidate relaxed input section
map.
(Output_section::restore_states): Adjust type of checkpoint .
Invalidate relaxed input section map.
* output.h (Output_merge_base): New class declaration.
(Input_section_specifier): New class defintion.
(class Output_relaxed_input_section) Change base class to
Output_section_data_build.
(Output_relaxed_input_section::Output_relaxed_input_section): Adjust
base class initializer.
(Output_section::add_relaxed_input_section): New method declaration.
(Output_section::Input_section): Change visibility to protected.
(Output_section::Input_section::relobj,
Output_section::Input_section::shndx): Handle relaxed input sections.
Output_section::input_sections) Change visibility to protected. Also
define overload to return a non-const pointer.
(Output_section::Merge_section_properties): New class defintion.
(Output_section::Merge_section_by_properties_map,
Output_section::Output_section_data_by_input_section_map,
Output_section::Relaxation_map): New types.
(Output_section::relax_input_section): Rename method to
Output_section::convert_input_sections_to_relaxed_sections and change
interface to take a vector of relaxed section pointers.
(Output_section::find_merge_section,
Output_section::find_relaxed_input_section,
Output_section::build_relaxation_map,
Output_section::convert_input_sections_in_list_to_relaxed_sections):
New method declarations.
(Output_section::merge_section_map_
Output_section::merge_section_by_properties_map_,
Output_section::relaxed_input_section_map_,
Output_section::is_relaxed_input_section_map_valid_,
Output_section::generate_code_fills_at_write_): New data members.
* script-sections.cc
(Output_section_element_input::set_section_addresses): Call
current_data_size and addralign methods of relaxed input sections.
(Orphan_output_section::set_section_addresses): Call current_data_size
and addralign methods of relaxed input sections.
* symtab.cc (Symbol_table::compute_final_value): Extract template
from the body of Symbol_table::sized_finalize_symbol.
(Symbol_table::sized_finalized_symbol): Call
Symbol_table::compute_final_value.
* symtab.h (Symbol_table::Compute_final_value_status): New enum type.
(Symbol_table::compute_final_value): New templated method declaration.
* target.cc (Target::do_make_output_section): New method defintion.
* target.h (Target::make_output_section): New method declaration.
(Target::relax): Add more parameters for input objects, symbol table
and layout. Adjust call to do_relax.
(Target::do_make_output_section): New method declaration.
(Target::do_relax): Add parameters for input objects, symbol table
and layout.
* options.cc: Include <cerrno> and <fstream>.
(General_options::finalize): Parse -retain-symbols-file tag.
* options.h: New flag.
(General_options): New method should_retain_symbol, new
variable symbols_to_retain.
* symtab.cc (Symbol_table::sized_finalize_symbol): Test
should_retain_symbol map.
* testsuite/Makefile.am (retain_symbols_file_test): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/retain_symbols_file_test.sh: New file.
Target::new_output_section.
(Layout::attach_allocated_section_to_segment): Put large section
sections in a separate load segment with the large segment flag
set.
(Layout::segment_precedes): Sort large data segments after other
load segments.
(align_file_offset): New static function.
(Layout::set_segment_offsets): Use align_file_offset.
* output.h (class Output_section): Add is_small_section_ and
is_large_section_ fields.
(Output_section::is_small_section): New function.
(Output_section::set_is_small_section): New function.
(Output_section::is_large_section): New function.
(Output_section::set_is_large_section): New function.
(Output_section::is_large_data_section): New function.
(class Output_segment): Add is_large_data_segment_ field.
(Output_segment::is_large_data_segment): New function.
(Output_segment::set_is_large_data_segment): New function.
* output.cc (Output_section::Output_section): Initialize new
fields.
(Output_segment::Output_segment): Likewise.
(Output_segment::add_output_section): Add assertion that large
data sections always go in large data segments. Force small data
sections to the end of the list of data sections. Force small BSS
sections to the start of the list of BSS sections. For large BSS
sections to the end of the list of BSS sections.
* symtab.h (class Symbol): Declare is_common_shndx.
(Symbol::is_defined): Check Symbol::is_common_shndx.
(Symbol::is_common): Likewise.
(class Symbol_table): Define enum Commons_section_type. Update
declarations. Add small_commons_ and large_commons_ fields.
* symtab.cc (Symbol::is_common_shndx): New function.
(Symbol_table::Symbol_table): Initialize new fields.
(Symbol_table::add_from_object): Put small and large common
symbols in the right list.
(Symbol_table::sized_finalized_symbol): Check
Symbol::is_common_shndx.
(Symbol_table::sized_write_globals): Likewise.
* common.cc (Symbol_table::do_allocate_commons): Allocate new
common symbol lists. Don't call do_allocate_commons_list if the
list is empty.
(Symbol_table::do_allocate_commons_list): Remove is_tls
parameter. Add comons_section_type parameter. Change all
callers. Handle small and large common symbols.
* object.cc (Sized_relobj::do_finalize_local_symbols): Check
Symbol::is_common_shndx.
* resolve.cc (symbol_to_bits): Likewise.
* target.h (Target::small_common_shndx): New function.
(Target::small_common_section_flags): New function.
(Target::large_common_shndx): New function.
(Target::large_common_section_flags): New function.
(Target::new_output_section): New function.
(Target::Target_info): Add small_common_shndx, large_common_shndx,
small_common_section_flags, and large_common_section_flags
fields.
(Target::do_new_output_section): New virtual function.
* arm.cc (Target_arm::arm_info): Initialize new fields.
* i386.cc (Target_i386::i386_info): Likewise.
* powerpc.cc (Target_powerpc::powerpc_info) [all versions]:
Likewise.
* sparc.c (Target_sparc::sparc_info) [all versions]: Likewise.
* x86_64.cc (Target_x86_64::x86_64_info): Likewise.
(Target_x86_64::do_new_output_section): New function.
* configure.ac: Define conditional MCMODEL_MEDIUM.
* testsuite/Makefile.am (check_PROGRAMS): Add large.
(large_SOURCES, large_CFLAGS, large_DEPENDENCIES): Define.
(large_LDFLAGS): Define.
* testsuite/large.c: New file.
* testsuite/testfile.cc (Target_test::test_target_info):
Initialize new fields.
* configure, testsuite/Makefile.in: Rebuild.
* archive.cc (Archive::Archive): Move constructor from archive.h
to here. Initialize no_export_.
(Archive::get_elf_object_for_member): Set no_export flag of object.
* archive.h (Archive::Archive): Move constructor body to
archive.cc.
(Archive::no_export): New method.
(Archive::no_export_): New field.
* object.h (Object::Object): Initialize no_export_ to false.
(Object::no_export, Object::set_no_export): New methods.
(Object::no_export_): New field.
* options.cc (General_options::parse_exclude_libs): New method.
(General_options::check_excluded_libs) Same.
* options.h (exclude_libs): New option.
(General_options::check_excluded_libs): New method declaration.
(General_options::excluded_libs_): New field.
* symtab.cc (Symbol_table::add_from_relobj): Hide symbols with
default or protected visibility if an object has no-export flag set.
testsuite/Makefile.am (check_PROGRAMS): Add exclude_libs_test.
(check_SCRIPTS): Add exclude_libs_test.sh.
(check_DATA): Add exclude_libs_test.syms.
(MOSTLYCLEANFILES): Add exclude_libs_test.syms,
libexclude_libs_test_1.a and libexclude_libs_test_2.a.
(exclude_libs_test_SOURCES, exclude_libs_test_DEPENDENCIES,
exclude_libs_test_LDFLAGS and exclude_libs_test_LDADD): Define.
(exclude_libs_test.syms, libexclude_libs_test_1.a,
libexclude_libs_test_2.a): New rules.
* testsuite/Makefile.in: Regenerate.
* testsuite/exclude_libs_test.c: New file.
* testsuite/exclude_libs_test.sh: Ditto.
* testsuite/exclude_libs_test_1.c: Ditto.
* testsuite/exclude_libs_test_2.c: Ditto.
broken out of add_from_object.
(Symbol_table::add_from_object): Call define_default_version.
(Symbol_table::define_special_symbol): Add resolve_oldsym
parameter. Change all callers. If the version for a symbol comes
from a version script, resolve it with the symbol with the same
name with no version. Also add the symbol without a version if
appropriate.
(do_define_in_output_data): If resolving with oldsym, don't delete
sym.
(do_define_in_output_segment): Likewise.
(do_define_as_constant): Likewise.
* symtab.h (class Symbol_table): Update declarations.
* symtab.cc (Symbol_table::sized_write_section_symbol): In a
relocatable link set the value of the section symbol to zero.
* object.cc (Sized_relobj::do_finalize_local_symbols): In a
relocatable link don't include the section address in the local
symbol value.
* symtab.cc (Symbol_table::add_from_object): If the visibility is
hidden or internal, force the symbol to be local.
* resolve.cc (Symbol::override_visibility): Define.
(Symbol::override_base): Use override_visibility.
(Symbol_table::resolve): Likewise.
(Symbol::override_base_with_special): Likewise.
(Symbol_table::override_with_special): If the visibility is hidden
or internal, force the symbol to be local.
* symtab.h (class Symbol): Add set_visibility and
override_visibility.
* testsuite/ver_test_1.sh: New file.
* testsuite/Makefile.am (check_SCRIPTS): Add ver_test_1.sh.
(check_DATA): Add ver_test_1.syms.
(ver_test_1.syms): New target.
* testsuite/Makefile.in: Rebuild.
* gold.h (gold_undefined_symbol): Change to take only a Symbol
pointer and to report location as the file name associated with
the symbol.
(gold_undefined_symbol_at_location): New function to replace the
old gold_undefined_symbol functionality.
* target-reloc.h (relocate_section): Update to use
gold_undefined_symbol_at_location.
* symtab.cc (Symbol_table::warn_about_undefined_dynobj_symbol):
Call gold_undefined_symbol function rather than gold_error.
* errors.h (Errors::undefined_symbol): Take location as a
string, rather than calculating it from a relocation.
* errors.cc (Errors::fatal): Print "fatal error:" before the
formatted message.
(Errors::error, Errors::error_at_location): Print "error: "
before the formatted message.
(Errors::undefined_symbol): Take location as a string, rather
than calculating it from a relocation.
(gold_undefined_symbol_at_location): New function akin to
old gold_undefined_symbol, calculates location from relocation.
(gold_undefined_symbol): Change to take only a Symbol pointer
and to report location as the file name associated with the symbol.
* testsuite/debug_msg.sh: Update for changed error messages.
* testsuite/undef_symbol.sh: Likewise.
* Makefile.am (CCFILES): Add gc.cc.
(HFILES): Add gc.h.
* Makefile.in: Regenerate.
* gold.cc (Gc_runner): New class.
(queue_initial_tasks): Call garbage collection related tasks
when corresponding options are invoked.
(queue_middle_gc_tasks): New function.
(queue_middle_tasks): Reorder tasks to allow relocs to be read and
processed early before laying out sections during garbage collection.
* gold.h (queue_middle_gc_tasks): New function.
(is_prefix_of): Move from "layout.cc".
* i386.cc (Target_i386::gc_process_relocs): New function.
* layout.cc (is_prefix_of): Remove. Move to "gold.h"
* main.cc (main): Create object of class "Garbage_collection".
* object.cc (Relobj::copy_symbols_data): New function.
(Relobj::is_section_name_included): New function.
(Sized_relobj::do_layout): Allow this function to be called twice
during garbage collection and defer layout of section during the
first call.
* object.h (Relobj::get_symbols_data): New function.
(Relobj::is_section_name_included): New function.
(Relobj::copy_symbols_data): New function.
(Relobj::set_symbols_data): New function.
(Relobj::get_relocs_data): New function.
(Relobj::set_relocs_data): New function.
(Relobj::is_output_section_offset_invalid): New pure virtual function.
(Relobj::gc_process_relocs): New function.
(Relobj::do_gc_process_relocs): New pure virtual function.
(Relobj::sd_): New data member.
(Sized_relobj::is_output_section_offset_invalid): New function.
(Sized_relobj::do_gc_process_relocs): New function.
* options.h (General_options::gc_sections): Modify to not be a no-op.
(General_options::print_gc_sections): New option.
* plugin.cc (Plugin_finish::run): Remove function call to
Plugin_manager::layout_deferred_objects. Move it to "gold.cc".
* powerpc.cc (Target_powerpc::gc_process_relocs): New function.
* reloc.cc (Read_relocs::run): Add task to process relocs and
determine unreferenced sections when doing garbage collection.
(Gc_process_relocs): New class.
(Sized_relobj::do_gc_process_relocs): New function.
(Sized_relobj::do_scan_relocs): Don't try to scan the relocs for
sections that are garbage collected.
* reloc.h (Gc_process_relocs): New class.
* sparc.cc (Target_sparc::gc_process_relocs): New function.
* symtab.cc (Symbol::should_add_dynsym_entry): Do not add entries for
symbols whose corresponding sections are garbage collected.
(Symbol_table::Symbol_table): Add new parameter for the garbage
collection object.
(Symbol_table::gc_mark_undef_symbols): New function.
(Symbol_table::gc_mark_symbol_for_shlib): New function.
(Symbol_table::gc_mark_dyn_syms): New function.
(Symbol_table::resolve): Do not treat symbols seen in dynamic objects
as garbage.
(Symbol_table::add_from_object): Likewise.
(Symbol_table::add_from_relobj): When building shared objects, do not
treat externally visible symbols as garbage.
(Symbol_table::sized_finalize_symbol): Do not check dynamic symbol
table information for static and relocatable links.
* symtab.h (Symbol_table::set_gc): New function.
(Symbol_table::gc): New function.
(Symbol_table::gc_mark_undef_symbols): New function.
(Symbol_table::gc_mark_symbol_for_shlib): New function.
(Symbol_table::gc_mark_dyn_syms): New function.
(Symbol_table::gc_): New data member.
* target.h (Sized_target::gc_process_relocs): New pure virtual
function.
* x86_64.cc (Target_x86_64::gc_process_relocs): New function.
* testsuite/testfile.cc (Target_test::gc_process_relocs): New function.
* options.h (General_options): New flags dynamic_list,
dynamic_list_data, dynamic_list_cpp_new, and
dynamic_list_cpp_typeinfo. New variable dynamic_list_.
(General_options::in_dynamic_list): New function.
* script.cc (Lex::Mode): New enum DYNAMIC_LIST.
(Lex::can_start_name): Add support for DYNAMIC_LIST mode.
(Lex::can_continue_name): Likewise.
(yylex): Likewise.
(read_script_file): New parameter script_options.
(read_dynamic_list): New function.
(Script_options::define_dynamic_list): New function.
(dynamic_list_keyword_parsecodes): New variable.
(dynamic_list_keywords): New variable.
* script.h (Script_options::define_dynamic_list): New function
prototype.
(read_dynamic_list): New function prototype.
* symtab.cc (strprefix): New macro.
(Symbol::should_add_dynsym_entry): Support dynamic_list,
dynamic_list_data, dynamic_list_cpp_new, and
dynamic_list_cpp_typeinfo.
* yyscript.y (PARSING_DYNAMIC_LIST): New token.
(dynamic_list_expr): New rule.
(dynamic_list_nodes): Likewise.
(dynamic_list_node): Likewise.
* testsuite/Makefile.am (dynamic_list): New test.
* testsuite/Makefile.in: Regenerated.
* testsuite/dynamic_list.t: New file.
* testsuite/dynamic_list.sh: New file.