with MREMAP_MAYMOVE.
* output.h (class Output_file): Add map_is_allocated_ field.
* output.cc: Only #include <sys/mman.h> if it exists. If mmap is
not available, provide stubs. If mremap is not available, #define
it to gold_mremap.
(MREMAP_MAYMOVE): Define if not defined.
(Output_file::Output_file): Initialize map_is_allocated_.
(Output_file::resize): Check map_is_allocated_.
(Output_file::map_anonymous): If mmap fails, use malloc.
(Output_file::unmap): Don't do anything for an anonymous map.
* fileread.cc: Only #include <sys/mman.h> if it exists. If mmap
is not available, provide stubs.
(File_read::View::~View): Use free rather than delete[].
(File_read::make_view): Use malloc rather than new[]. If mmap
fails, use malloc.
(File_read::find_or_make_view): Use malloc rather than new[].
* gold.h: Remove HAVE_REMAP code.
* mremap.c: #include <errno.h>. Only #include <sys/mman.h> if it
exists. Rename mremap to gold_mremap. If mmap is not available
don't do anything.
* configure, config.in: Rebuild.
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.
by reference; adjust all callers.
* output.cc (Output_segment::set_section_addresses): Adjust references
to increase_relro. Add padding to *increase_relro when ORDER_RELRO_LAST
list is empty.
(Output_segment::set_offset): Assert if PT_GNU_RELRO segment does not
end at page boundary.
* layout.cc (Layout::choose_output_section): Transform names of
compressed sections even when using a script with a SECTIONS clause.
(Layout::output_section_name): Remove code to transform
compressed debug section names.
* output.cc (Output_section::add_input_section): Use uncompressed
section size when tracking input sections.
* arm.cc (Arm_outout_section::fix_exidx_coverage): Adjust call to
Output_section::add_relaxed_input_section.
* output.cc (Output_section::add_relaxed_input_section): Add new
arguments LAYOUT and NAME. Set section order index.
(Output_section::convert_input_sections_in_list_to_relaxed_sections):
Copy section order index.
* output.h (Output_section::add_relaxed_input_section): Add new
arguments LAYOUT and NAME.
signature. Update all callers.
* output.cc (Output_segment::is_first_section_relro): Ignore TLS
sections.
(Output_segment::set_section_addresses): Align after last TLS
section. Add padding before last relro section instead of after.
segment that has been aligned for relro.
* output.cc (Output_segment::set_section_addresses): Change signature;
adjust all callers. Account for alignment when totalling
size of relro sections.
* output.h (Output_segment::set_section_addresses): Change signature.
* testsuite/Makefile.am (relro_test.sh, relro_test.stdout): New
targets.
* testsuite/Makefile.in: Regenerate.
* testsuite/relro_test.cc: Add alignment attributes to test proper
alignment of relro sections when padding is necessary.
* testsuite/relro_test.sh: New script.
* i386.cc (class Output_data_plt_i386): Update declarations.
Define Global_ifunc and Local_ifunc types. Add global_ifuncs_ and
local_ifuncs_ fields.
(Target_i386::do_plt_section_for_global): New function.
(Target_i386::do_plt_section_for_local): New function.
(Output_data_plt_i386::Output_data_plt_i386): Add symtab
parameter; change all callers. Initialize global_ifuncs_ and
local_ifuncs_. If doing a static link define __rel_iplt_start and
__rel_iplt_end.
(Output_data_plt_i386::add_entry): Handle IFUNC symbols.
(Output_data_plt_i386::add_local_ifunc_entry): New function.
(Output_data_plt_i386::do_write): Fix GOT entries for IFUNC
symbols.
(Target_i386::make_plt_section): New function, broken out of
make_plt_entry. Set sh_info field of .rel.plt to point to .plt.
(Target_i386::make_plt_entry): Call make_plt_section.
(Target_i386::make_local_ifunc_plt_entry): New function.
(Target_i386::Scan::reloc_needs_iplt_for_ifunc): New function.
(Target_i386::Scan::local): Handle IFUNC symbols. Add
R_386_IRELATIVE to switch.
(Target_i386::Scan::global): Likewise.
(Target_i386::Relocate::relocate): Likewise.
(Target_i386::Relocatable_size_for_reloc): Add R_386_IRELATIVE to
switch.
* x86_64.cc (class Output_data_plt_x86_64): Update declarations.
(Target_x86_64::do_plt_section_for_global): New function.
(Target_x86_64::do_plt_section_for_local): New function.
(Output_data_plt_x86_64::Output_data_plt_x86_64): Add symtab
parameter; change all callers. If doing a static link define
__rela_iplt_start and __rela_iplt_end.
(Output_data_plt_x86_64::add_entry): Handle IFUNC symbols.
(Output_data_plt_x86_64::add_local_ifunc_entry): New function.
(Target_x86_64::make_plt_section): Set sh_info field of .rel.plt
to point to .plt.
(Target_x86_64::make_local_ifunc_plt_entry): New function.
(Target_x86_64::Scan::check_non_pic): Add R_X86_64_IRELATIVE to
switch.
(Target_x86_64::Scan::reloc_needs_iplt_for_ifunc): New function.
(Target_x86_64::Scan::local): Handle IFUNC symbols. Add
R_X86_64_IRELATIVE to switch.
(Target_x86_64::Scan::global): Likewise.
(Target_x86_64::Relocate::relocate): Likewise.
(Target_x86_64::Relocatable_size_for_reloc): Add R_X86_64_IRELATIVE to
switch.
* target.h (class Target): Add plt_section_for_global and
plt_section_for_local functions. Add do_plt_section_for_global
and do_plt_section_for_local virtual functions.
* symtab.h (Symbol::needs_plt_entry): Handle IFUNC symbol. Add
clarifying comments.
(Symbol::use_plt_offset): Handle IFUNC symbol.
* object.cc (Sized_relobj::Sized_relobj): Initialize
local_plt_offsets_.
(Sized_relobj::local_has_plt_offset): New function.
(Sized_relobj::local_plt_offset): New function.
(Sized_relobj::set_local_plt_offset): New function.
(Sized_relobj::do_count): Handle IFUNC symbol.
* object.h (class Symbol_value): Add is_ifunc_symbol_ field. Take
a bit away from input_shndx_ field. Add set_is_func_symbol and
is_ifunc_symbol functions.
(class Sized_relobj): Update declarations. Remove Tls_got_entry
and Local_tls_got_offsets. Define Local_plt_offsets. Add
local_plt_offsets_ field.
(Sized_relobj::clear_local_symbols): Clear local_plt_offsets_.
* output.h (class Output_section_data): Add non-const
output_section function.
(class Output_data_got): Update declarations.
(class Output_data_got::Got_entry): Add use_plt_offset_ field.
Add use_plt_offset parameter to global and local constructors.
Change all callers. Change local_sym_index_ field to 31 bits.
Change GSYM_CODE and CONSTANT_CODE accordingly.
* output.cc (Output_data_reloc_base::do_adjust_output_section): If
doing a static link don't set sh_link field.
(Output_data_got::Got_entry::write): Use PLT offset if
appropriate.
(Output_data_got::add_global_plt): New function.
(Output_data_got::add_local_plt): New function.
* target-reloc.h (relocate_section): Handle IFUNC symbol.
* defstd.cc (in_section): Remove entries for __rel_iplt_start,
__rel_iplt_end, __rela_iplt_start, and __rela_iplt_end.
* configure.ac: Set IFUNC automake conditional for glibc >= 2.11.
* testsuite/Makefile.am: Add a bunch of IFUNC tests, all within
IFUNC conditional.
* testsuite/ifunc-sel.h: New file.
* testsuite/ifuncmain1.c: New file.
* testsuite/ifuncmain1vis.c: New file.
* testsuite/ifuncmod1.c: New file.
* testsuite/ifuncdep2.c: New file.
* testsuite/ifuncmain2.c: New file.
* testsuite/ifuncmain3.c: New file.
* testsuite/ifuncmod3.c: New file.
* testsuite/ifuncmain4.c: New file.
* testsuite/ifuncmain5.c: New file.
* testsuite/ifuncmod5.c: New file.
* testsuite/ifuncmain6pie.c: New file.
* testsuite/ifuncmod6.c: New file.
* testsuite/ifuncmain7.c: New file.
* configure, testsuite/Makefile.in: Rebuild.
* output.cc (Output_segment::set_offset): Search for the first and
last sections rather than assuming that the list is in order.
(Output_segment::find_first_and_last_list): New function.
* output.h (class Output_segment): Update declarations.
* testsuite/Makefile.am (check_PROGRAMS): Add relro_strip_test.
(relro_strip_test_SOURCES): New variable.
(relro_strip_test_DEPENDENCIES): New variable.
(relro_strip_test_LDFLAGS): New variable.
(relro_strip_test_LDADD): New variable.
(relro_strip_test.so): New target.
* arm.cc (Arm_input_section::Arm_input_section): For a
SHT_ARM_EXIDX section, always keeps the input sections.
(Arm_input_section::set_exidx_section_link): New method.
(Arm_exidx_input_section::Arm_exidx_input_section): Initialize
has_errors_ to false.
(Arm_exidx_input_section::has_errors,
Arm_exidx_input_section::set_has_errors): New methods.
(Arm_exidx_input_section::has_errors_): New data member.
(Arm_relobj::get_exidx_shndx_list): New method.
(Arm_output_section::append_text_sections_to_list): Do not skip
section without SHF_EXECINSTR.
(Arm_output_section::fix_exidx_coverage): Skip input sections with
errors.
(Arm_relobj::make_exidx_input_section): Add new parameter for text
section header. Make error messages more verbose. Check for
a non-executable section linked to an EXIDX section.
(Arm_relobj::do_read_symbols): Remove error checking, which has been
moved to Arm_relobj::make_exidx_input_section. Add an assertion to
check that there is no deferred EXIDX section if we exit early.
Instead of not making an EXIDX section in case of an error, make one
and set the has_errors flag of it.
(Target_arm::do_finalize_sections): Fix up links of EXIDX sections
in a relocatable link.
(Target_arm::do_relax): Look for the EXIDX output section instead of
assuming that it is called .ARM.exidx.
(Target_arm::fix_exidx_coverage): Add a new parameter for input
section list. Do not check for SHF_EXECINSTR section flags but
skip any input section with errors.
* output.cc (Output_section::Output_section): Initialize
always_keeps_input_sections_ to false.
(Output_section::add_input_section): Check for
always_keeps_input_sections_.
* output.h (Output_section::always_keeps_input_sections,
Output_section::set_always_keeps_input_sections): New methods.
(Output_section::always_keeps_input_sections): New data member.
* layout.cc (Layout::layout): Pass this pointer to add_input_section.
(Layout::layout_eh_frame): Ditto.
(Layout::find_section_order_index): New method.
(Layout::read_layout_from_file): New method.
* layout.h (Layout::find_section_order_index): New method.
(Layout::read_layout_from_file): New method.
(Layout::input_section_position_): New private member.
(Layout::input_section_glob_): New private member.
* main.cc (main): Call read_layout_from_file here.
* options.h (--section-ordering-file): New option.
* output.cc (Output_section::input_section_order_specified_): New
member.
(Output_section::Output_section): Initialize new member.
(Output_section::add_input_section): Add new parameter.
Keep input sections when --section-ordering-file is used.
(Output_section::set_final_data_size): Sort input sections when
section ordering file is specified.
(Output_section::Input_section_sort_entry): Add new parameter.
Check sorting type.
(Output_section::Input_section_sort_entry::compare_section_ordering):
New method.
(Output_section::Input_section_sort_compare::operator()): Change to
consider section_order_index.
(Output_section::Input_section_sort_init_fini_compare::operator()):
Change to consider section_order_index.
(Output_section::Input_section_sort_section_order_index_compare
::operator()): New method.
(Output_section::sort_attached_input_sections): Change to sort
according to section order when specified.
(Output_section::add_input_section<32, true>): Add new parameter.
(Output_section::add_input_section<64, true>): Add new parameter.
(Output_section::add_input_section<32, false>): Add new parameter.
(Output_section::add_input_section<64, false>): Add new parameter.
* output.h (Output_section::add_input_section): Add new parameter.
(Output_section::input_section_order_specified): New
method.
(Output_section::set_input_section_order_specified): New method.
(Input_section::Input_section): Initialize section_order_index_.
(Input_section::section_order_index): New method.
(Input_section::set_section_order_index): New method.
(Input_section::section_order_index_): New member.
(Input_section::Input_section_sort_section_order_index_compare): New
struct.
(Output_section::input_section_order_specified_): New member.
* script-sections.cc (is_wildcard_string): Delete and move modified
method to gold.h.
(Output_section_element_input::Output_section_element_input): Modify
call to is_wildcard_string.
(Output_section_element_input::Input_section_pattern
::Input_section_pattern): Ditto.
(Output_section_element_input::Output_section_element_input): Ditto.
* testsuite/Makefile.am (final_layout): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/final_layout.cc: New file.
* testsuite/final_layout.sh: New file.
* arm.cc (Arm_input_section::do_output_offset): Use convert_types
instead of a cast.
(Target_arm::apply_cortex_a8_workaround): Rewrite a conditional branch
with a direct branch, not a conditional branch, to a stub.
* merge.cc (Output_merge_base::record_input_section): New method
defintion.
(Output_merge_data::do_add_input_section): Record input section if
keeps-input-sections flag is set.
(Output_merge_string::do_add_input_section): Ditto.
* merge.h (Output_merge_base::Output_merge_base): Initialize new data
members KEEPS_INPUT_SECTIONS_, FIRST_RELOBJ_, FIRST_SHNDX_ and
INPUT_SECTIONS_.
(Output_merge_base::keeps_input_sections,
Output_merge_base::set_keeps_input_sections,
Output_merge_base::first_relobj, Output_merge_base::first_shndx): New
method definitions.
(Output_merge_base::Input_sections): New type declaration.
(Output_merge_base::input_sections_begin,
Output_merge_base::input_sections_end,
Output_merge_base::do_set_keeps_input_sections): New method definitions.
(Output_merge_base::bool keeps_input_sections_,
Output_merge_base::first_relobj_, Output_merge_base::first_shndx_,
Output_merge_base::input_sections_): New data members.
(Output_merge_data::do_set_keeps_input_sections): New method
defintion.
(Output_merge_string::do_set_keeps_input_sections): Ditto.
* output.cc (Output_section::Input_section::relobj): Move method
defintion from class declaration to here and handle merge sections.
(Output_section::Input_section::shndx): Ditto.
(Output_section::Output_section): Remove initializations of removed
data members and initialize new data member LOOKUP_MAPS_.
(Output_section::add_input_section): Set keeps-input-sections flag
for a newly created merge output section as appropriate. Adjust code
to use Output_section_lookup_maps class.
(Output_section::add_relaxed_input_section): Adjst code for lookup
maps code refactoring.
(Output_section::add_merge_input_section): Add a new parameter
KEEPS_INPUT_SECTION. Adjust code to use Output_section_lookup_maps
class. If adding input section to a newly created merge output
section fails, remove the new merge section.
(Output_section::convert_input_sections_in_list_to_relaxed_input_sections):
Adjust code for use of the Output_section_lookup_maps class.
(Output_section::find_merge_section): Ditto.
(Output_section::build_lookup_maps): New method defintion.
(Output_section::find_relaxed_input_section): Adjust code to use
Output_section_lookup_maps class.
(Output_section::get_input_sections): Export merge sections. Adjust
code to use Output_section_lookup_maps class.
(Output_section:::add_script_input_section): Adjust code to use
Output_section_lookup_maps class. Update lookup maps for merge
sections also.
(Output_section::discard_states): Use Output_section_lookup_maps.
(Output_section::restore_states): Same.
* output.h (Merge_section_properties): Move class defintion out of
Output_section.
(Output_section_lookup_maps): New class.
(Output_section::Input_section::is_merge_section): New method
defintion.
(Output_section::Input_section::relobj): Move defintion out of class
defintion. Declare method only.
(Output_section::Input_section::shndx): Ditto.
(Output_section::Input_section::output_merge_base): New method defintion.
(Output_section::Input_section::u2_.pomb): New union field.
(Output_section::Merge_section_by_properties_map,
Output_section::Output_section_data_by_input_section_map,
Output_section::Ouptut_relaxed_input_section_by_input_section_map):
Remove types.
(Output_section::add_merge_input_section): Add new parameter
KEEPS_INPUT_SECTIONS.
(Output_section::build_lookup_maps): New method declaration.
(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_): Remove data
members.
(Output_section::lookup_maps_): New data member.
* arm.cc (Arm_input_section::original_size): New method.
(Arm_input_section::do_addralign): Add a cast.
(Arm_input_section::do_output_offset): Remove static cast.
(Arm_input_section::original_addralign,
Arm_input_section::original_size_): Change type to uint32_t.
(Arm_input_section::init): Add safe casts for section alignment
and size.
(Arm_input_section::set_final_data_size): Do not set address and
offset of stub table.
(Arm_output_section::fix_exidx_coverage): Change use of of
Output_section::Simple_input_section to that of
Output_section::Input_section.
(Target_arm::do_relax): Set addresses and file offsets of Stub_tables
except for the first pass.
* output.cc (Output_section::get_input_sections): Change type of
input_sections to std::list<Input_section>.
(Output_section::add_script_input_section): Rename from
Output_section::add_simple_input_section. Change type of SIS
parameter from Simple_input_section to Input_section.
* output.h (Output_section::Simple_input_section): Remove class.
(Output_section::Input_section): Change class visibility to public.
(Output_section::Input_section::addralign): Use stored alignments
for special input sections if set.
(Output_section::Input_section::set_addralign): New method.
(Output_section::get_input_sections): Change parameter type from
list of Simple_input_section to list of Input_section.
(Output_section::add_script_input_section): Rename from
Output_section::add_simple_input_section. Change first parameter's
type from Simple_input_section to Input_section and remove the
second and third parameters.
* script-sections.cc (Input_section::Input_section_list): Change
type to list of Output_section::Input_section/
(Input_section_info::Input_section_info): Change parameter type of
INPUT_SECTION to Output_section::Input_section.
(Input_section_info::input_section): Change return type.
(Input_section_info::input_section_): Change type to
Output_section::Input_section.
(Output_section_element_input::set_section_addresses): Adjust code
to use Output_section::Input_section instead of
Output_section::Simple_input_section. Adjust code for renaming
of Output_section::add_simple_input_section.
(Orphan_output_section::set_section_addresses): Ditto.
* layout.cc (Layout::choose_output_section): Handle script section
types.
(Layout::make_output_section_for_script): Add section type parameter.
Handle script section types.
* layout.h (Layout::make_output_section_for_script): Add section
type parameter.
* output.cc (Output_section::Output_section): Initialize data member
is_noload_.
(Output_section::do_reset_address_and_file_offset): Do not set address
to 0 if section is a NOLOAD section.
* output.h (Output_section::is_noload): New method.
(Output_section::set_is_noload): Ditto.
(Output_section::is_noload_): New data member.
* script-c.h (Script_section_type): New enum type.
(struct Parser_output_section_header): Add new file section_type.
* script-sections.cc (Sections_element::output_section_name): Add
parameter for returning script section type.
(Output_section_definition::output_section_name): Ditto.
(Output_section_definition::section_type)P; New method.
(Output_section_definiton::script_section_type_name): Ditto.
(Output_section_definition::script_section_type_): New data member.
(Output_section_definition::Output_section_definition): Initialize
data member Output_section_definition::script_section_type_.
(Output_section_definition::create_sections): Pass script section type
to Layout::make_output_section_for_script.
(Output_section_definition::output_section_name): Return script
section type to caller.
(Output_section_definition::set_section_address): Do not advance
dot value and load address if section type is NOLOAD. Set address
of NOLOAD sections regardless of section flags.
(Output_section_definition::print): Print section type if it is
not SCRIPT_SECTION_TYPE_NONE.
(Output_section_definition::section_type): New method.
(Output_section_definition::script_section_type_name): Ditto.
(Script_sections::output_section_name): Add new parameter
PSECTION_TYPE for returning script section type. Pass it to
section elements. Handle discard sections.
(Sort_output_sections::operator()): Handle NOLOAD sections.
* script-sections.h (Script_sections::Section_type): New enum type.
(Script_sections::output_section_name): Add a new parameter for
returning script section type.
* script.cc (script_keyword_parsecodes): Add keywords COPY, DSECT,
INFO and NOLOAD.
* yyscript.y (union): Add new field SECTION_TYPE.
(COPY, DSECT, INFO, NOLOAD): New tokens.
(opt_address_and_section_type): Change type to output_section_header.
(section_type): New non-terminal
(section_header): Handle section type.
(opt_address_and_section_type): Return section type value.
* merge.cc (Output_merge_data::set_final_data_size): Handle empty
Output_merge_data.
* output.cc (Output_section::add_merge_input_section): Simplify
code and return status of Output_merge_base::add_input_section.
Update merge section map only if Output_merge_base::add_input_section
returns true.
* layout.cc (Layout::Layout): Force section types of .init_array*,
.preinit_array* and .fini_array* sections.
* output.cc (Output_section::Input_section_sort_entry::has_priority):
Fix check of return value of std::string::find.().
(Output_section::Input_section_sort_compare::operator()): Remove
comment about .init_array.
(Output_section::Input_section_sort_init_fini_compare::operator()):
New method.
(Output_section::sort_attached_input_sections): Handle .init_array
and .fini_array specially.
* output.h (Output_section::Inut_section_sort_compare): Update
comment.
(Output_section::Input_section_sort_init_fini_compare): New struct.
that takes two Output_data objects.
(Output_data_dynamic::Dynamic_entry): Create storage for secondary
entry param. Handle it in initializers.
* output.cc (Output_data_dynamic::Dynamic_entry::write): For
DYNAMIC_SECTION_SIZE, add in second object size if non-NULL.
* layout.h (Layout::add_target_dynamic_tags): Add dynrel_includes_plt
arg.
* layout.cc (Layout::add_target_dynamic_tags): If dynrel_includes_plt,
and .rela.plt exists, set DT_REL{,A}SZ to sum of .rela.dyn and .rela.plt
* arm.cc (Target_arm::do_finalize_sections): Update to pass false
for dynrel_includes_plt.
* i386.cc (Target_i386::do_finalize_sections): Likewise.
* x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.
* sparc.cc (Target_sparc::make_plt_entry): Force .rela.dyn to be output
before .rela.plt
(Target_sparc::do_finalize_sections): Update to pass true for
dynrel_includes_plt.
* powerpc.cc (Target_powerpc::make_plt_entry): Force .rela.dyn to be
output before .rela.plt
(Target_powerpc::do_finalize_sections): Update to pass true for
dynrel_includes_plt when 32-bit.
* arm.cc (Target_arm::do_relax): Record an output section for section
offset adjustment it contains any stub table that has changed.
* layout.cc (Layout::clean_up_after_relaxation): Adjust section
offsets in an output section if necessary.
* output.cc (Output_section::Output_section): Initialize
section_offsets_need_adjustments_.
(Output_section::add_input_section_for_script): Renamed to
Output_section::add_simple_input_section.
(Output_section::save_states): Add a comment.
(Output_section::discard_states): New method defintion.
(Output_section::adjust_section_offsets): Same.
* output.h (Output_section::add_input_section_for_script): Renamed to
Output_section::add_simple_input_section.
(Output_section::discard_states): New method declaration.
(Output_section::adjust_section_offsets): Same.
(Output_section::section_offsets_need_adjustment,
Output_section::set_section_offsets_need_adjustment): New method
definitions.
(Output_section::section_offsets_need_adjustment_): New data member.
* script-sections.cc
(Output_section_element_input::set_section_address): Adjust code for
renaming of Output_section::add_input_section_for_script.
(Orphan_output_section::set_section_address): Same.
* arm.cc (Target_arm::Arm_input_section_map): Change key type from
Input_section_specifier to Section_id.
(Target_arm::new_arm_input_section: Adjust code for change of key
type.
(Target_arm::find_arm_input_section): Ditto.
* gc.h (object.h): Include for Section_id nand Section_id_hash.
(Section_id): Remove.
(Garbage_collection::Section_id_hash): Remove.
* icf.h (object.h): Include for Section_id nand Section_id_hash.
(Section_id): Remove.
(Icf::Section_id_hash): Remove.
* object.h (Section_id, Const_section_id, Section_id_hash,
Const_section_id_hash): New type definitions.
* output.cc (Output_section::add_relaxed_input_section): Change to
use Const_section_id instead of Input_section_specifier as key type.
(Output_section::add_merge_input_section): Ditto.
(Output_section::build_relaxation_map): Change to use Section_id
instead of Input_section_specifier as key type.
(Output_section::convert_input_sections_in_list_to_relaxed_sections):
Ditto.
(Output_section::convert_input_sections_to_relaxed_sections): Change
to use Const_section_id instead of Input_section_specifier as key type.
(Output_section::find_merge_section): Ditto.
(Output_section::find_relaxed_input_section): Ditto.
* output.h (Input_section_specifier): Remove class.
(Output_section::Output_section_data_by_input_section_map): Change
key type to Const_section_id.
(Output_section::Output_relaxed_input_section_by_input_section_map):
Ditto.
(Output_section::Relaxation_map): Change key type to Section_id.
* elfcpp.h (PN_XNUM): Define.
gold/:
* output.cc (Output_section_headers::do_sized_write): Write large
segment count to sh_info field.
(Output_file_header::do_sized_write): For large segment count,
write PN_XNUM to e_phnum field.
* arm.cc (map, utility): Include headers.
(Target_arm::apply_cortex_a8_workaround): New method.
(Arm_relobj::do_relocate_sections): Apply any Cortex-A8 workaround.
(Target_arm::Scan::local): Handle R_ARM_THM_JUMP24, R_ARM_THM_JUMP19.
(Target_arm::Scan::global): R_ARM_THM_JUMP19.
(Target_arm::do_finalize_sections): Set fix_cortex_a8_ according to
the --[no-]fix-cortex-a8 command line options.
(Target_arm::Relocate::relocate): Handle R_ARM_JUMP19.
(Target_arm::relocate_stub): Use addend in instruction template.
* options.h (DEFINE_bool): Set the user-set flag.
(General_options): Add --[no-]-fix-cortex options.
* output.cc (Output_section::convert_input_sections_to_relaxed_sections)
: Update fast look-up map after conversion.
PR 11063
* i386.cc (class Target_i386): Change return type of plt_section
to be non-const.
(class Output_data_plt_i386): Add tls_desc_rel_ field.
(Output_data_plt_i386::Output_data_plt_i386): Initialize
tls_desc_rel_ field.
(Output_data_plt_i386::rel_tls_desc): New function.
(Target_i386::rel_tls_desc_section): New function.
(Target_i386::Scan::local): Rewrite R_386_TLS_GOTDESC handling.
(Target_i386::Scan::global): For R_386_TLS_GOTDESC put
R_386_TLS_DESC reloc in rel_tls_desc_section.
* x86_64.cc (class Target_x86_64): Add tlsdesc_reloc_info_ field.
Define struct Tlsdesc_info.
(Target_x86_64::Target_x86_64): Initialize tlsdesc_reloc_info_.
(Target_x86_64::do_reloc_symbol_index): New function.
(Target_x86_64::add_tlsdesc_info): New function.
(class Output_data_plt_x86_64): Add tlsdesc_rel_ field.
(Output_data_plt_x86_64::Output_data_plt_x86_64): Initialize
tlsdesc_rel_ field.
(Output_data_plt_x86_64::rela_plt): Rename from rel_plt. Change
all callers.
(Output_data_plt_x86_64::rela_tlsdesc): New function.
(Target_x86_64::rela_tlsdesc_section): New function.
(Target_x86_64::Scan::local): Rewrite R_X86_64_GOTPC32_TLSDESC
handling.
(Target_x86_64::Scan::global): For R_X86_64_GOTPC32_TLSDESC put
(Target_x86_64::do_reloc_addend): New function.
R_X86_64_TLSDESC reloc in rela_tlsdesc_section.
* output.h (class Output_reloc) [SHT_REL]: Add new constructor
declarations. Define TARGET_CODE. Add arg field to u1_ union.
(Output_reloc::type): New function.
(Output_reloc::is_local_section_symbol): Check for TARGET_CODE.
(Output_reloc::is_target_specific): New function.
(Output_reloc::target_arg): New function.
(class Output_reloc) [SHT_RELA]: Add four new constructors for
absolute relocs and target specific relocs.
(class Output_data_reloc) [SHT_REL]: Add add_absolute and
add_target_specific.
(class Output_data_reloc) [SHT_RELA]: Likewise.
* output.cc (Output_reloc::Output_reloc): Add four new versions
for absolute relocs and target specific relocs.
(Output_reloc::set_needs_dynsym_index): Add TARGET_CODE case.
(Output_reloc::get_symbol_index): Likewise.
(Output_reloc::local_section_offset): Check that local_sym_index_
is not TARGET_CODE or 0.
(Output_reloc::symbol_value): Likewise.
(Output_reloc::write) [SHT_RELA]: Call target for target specific
reloc.
* target.h (class Target): Add reloc_symbol_index and reloc_addend
functions. Add do_reloc_symbol_index and do_reloc_addend virtual
functions.
* layout.cc (add_target_dynamic_tags): Use output section for
DT_PLTRELSZ and DT_JMPREL.
* options.cc (General_options::parse_section_start): New function.
(General_options::section_start): New function.
(General_options::General_options): Initialize all members.
* options.h: Include <map>
(class General_options): Add --section-start. Add section_starts_
member.
* layout.cc (Layout::attach_allocated_section_to_segment): If
--section-start was used, set the address of the segment. Remove
local sort_sections.
(Layout::relaxation_loop_body): If the address of the load segment
has been set by --section-start, don't use it.
* output.h (Output_segment::update_flags_for_output_section): New
function.
* output.cc (Output_segment::add_output_section): Call
update_flags_for_output_section.
* output.cc (Output_segment::Output_segment): If PT_TLS, set the
flags to PF_R.
(Output_segment::add_output_section): Don't change the flags if
the type is PT_TLS.
* output.h (class Output_section): Add is_entsize_zero_ field.
* output.cc (Output_section::Output_section): Initialize
is_entsize_zero_.
(Output_section::set_entsize): If two different entsizes are
requested, force it to zero.
(Output_section::add_input_section): Set flags for .debug_str
before updating section flags. Set entsize.
(Output_section::update_flags_for_input_section): Set SHF_MERGE
and SHF_STRING if all input sections have those flags.
* 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.
to the segment aligment for -N or -n with no load segment.
* output.cc (Output_segment::add_output_section): Don't crash if
the first section is a TLS section.
(Output_segment::set_section_list_addresses): Print an error
message if the address moves backward in a linker script.
* script-sections.cc
(Output_section_element_input::set_section_addresses): Don't
increase *dot_value for a SHF_TLS/SHT_NOBITS section.
(Orphan_output_section::set_section_addresses): Likewise.
* 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.
* 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.
* debug.h (DEBUG_RELAXATION): New constant.
(DEBUG_ALL): Add DEBUG_RELAXATION.
(debug_string_to_enum): Add relaxation debug option.
* layout.cc
(Layout::Relaxation_debug_check::check_output_data_for_reset_values,
Layout::Relaxation_debug_check::read_sections,
Layout::Relaxation_debug_check::read_sections): New method definitions.
(Layout::Layout): Initialize data members
record_output_section_data_from_scrips_,
script_output_section_data_list_ and relaxation_debug_check_.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method definitions.
(Layout::finalize): Support relaxation. Move section layout code to
Layout::relaxation_loop_body.
(Layout::set_asection_address_from_script): Move code for orphan
section placement out.
(Layout::place_orphan_sections_in_script): New method definition.
* layout.h (Output_segment_headers, Output_file_header):
New forward class declarations.
(Layout::~Layout): Define.
(Layout::new_output_section_data_from_script): New method definition.
(Layout::place_orphan_sections_in_script): New method declaration.
(Layout::Segment_states): New type declaration.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method declarations.
(Layout::Output_section_data_list): New type declaration.
(Layout::Relaxation_debug_check): New class definition.
(Layout::record_output_section_data_from_script_,
Layout::script_output_section_data_list_, Layout::segment_states_,
Layout::relaxation_debug_check_): New data members.
* output.cc: (Output_section_headers::do_size): New method definition.
(Output_section_headers::Output_section_headers): Move size
computation to Output_section_headers::do_size.
(Output_segment_headers::do_size): New method definition.
(Output_file_header::Output_file_header): Move size computation to
Output_file_header::do_size and call it.
(Output_file_header::do_size): New method definition.
(Output_data_group::Output_data_group): Adjust call to
Output_section_data.
(Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
(Output_symtab_xindex::do_write): Add array bound check.
(Output_section::Input_section::print_to_mapfile): Handle
RELAXED_INPUT_SECTION_CODE.
(Output_section::Output_section): Initialize data member checkpoint_.
(Output_section::~Output_section): Delete checkpoint object pointed
by checkpoint_.
(Output_section::add_input_section): Always add an Input_section if
relaxing.
(Output_section::add_merge_input_section): Add assert.
(Output_section::relax_input_section): New method definition.
(Output_section::set_final_data_size): Set load address to zero for
an unallocated section.
(Output_section::do_address_and_file_offset_have_reset_values):
New method definition.
(Output_section::Input_section_sort_enty::Input_section_sort_enty):
Handle relaxed input section.
(Output_section::sort_attached_input_sections): Checkpoint input
section list lazily.
(Output_section::get_input_sections): Change type of input_sections to
list of Simple_input_section pointers. Checkpoint input section list
lazily. Also handle relaxed input sections.
(Output_section::add_input_section_for_script): Take a reference to
a Simple_input_section object instead of Relobj pointer and section
index as parameter. Handle relaxed input sections.
(Output_section::save_states, Output_section::restore_states): New
method definitions.
* output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
(Output_data::is_data_size_fixed): New method definition.
(Output_data::reset_addresss_and_file_offset): Do not reset data size
if it is fixed.
(Output_data::address_and_file_offset_have_reset_values): New method
definition.
(Output_data::do_address_and_file_offset_have_reset_values): New method
definition.
(Output_data::set_data_size): Check that data size is not fixed.
(Output_data::fix_data_size): New method definition.
(Output_data::is_data_size_fixed_): New data member.
(Output_section_headers::set_final_data_size): New method definition.
(Output_section_headers::do_size): New method declaration.
(Output_segment_headers::set_final_data_size): New method definition.
(Output_segment_headers::do_size): New method declaration.
(Output_file_header::set_final_data_size)::New method definition.
(Output_file_header::do_size)::New method declaration.
(Output_section_data::Output_section_data): Add new parameter
is_data_size_fixed and use it to fix data size.
(Output_data_const::Output_data_const): Adjust call to base class
constructor and fix data size.
(Output_data_const_buffer::Output_data_const_buffer): Adjust call to
base class constructor and fix data size.
(Output_data_fixed_space::Output_data_fixed_space): Adjust call to
base class constructor and fix data size.
(Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
class constructor and fix data size.
(Output_data_group::set_final_data_size): New method definition.
(Output_data_dynamic::Dynamic_entry::tag): New method definition.
(Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
class constructor and fix data size.
(Output_relaxed_input_section): New class definition.
(Output_section::Simple_input_section): New class definition.
(Output_section::get_input_sections): Adjust parameter list.
(Output_section::add_input_section_for_script): Same.
(Output_section::save_states, Output_section::restore_states,
Output_section::do_address_and_file_offset_have_reset_values,
(Output_section::Input_section::Input_section): Handle
RELAXED_INPUT_SECTION_CODE. Add new overload for
Output_relaxed_input_section.
(Output_section::Input_section::is_input_section,
Output_section::Input_section::set_output_section): Handle relaxed
input section.
(Output_section::Input_section::is_relaxed_input_section,
Output_section::Input_section::output_section_data,
Output_section::Input_section::relaxed_input_section): New method
definitions.
(Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
value.
(Output_section::Input_section::u1_): Update comments.
(Output_section::Input_section::u2_): Add new union member poris.
(Output_section::Checkpoint_output_section): New classs definition.
(Output_section::relax_input_section): New method declaration.
(Output_section::checkpoint_): New data member.
(Output_segment): Update comments.
(Output_segment::Output_segment): Un-privatize copy constructor.
(Output_segment::operator=): Un-privatize.
* script-sections.cc (Output_section_element::Input_section_list):
Change element type to Output_section::Simple_input_section.
(Output_section_element_dot_assignment::set_section_addresses):
Register output section data for relaxation clean up.
(Output_data_exression::Output_data_expression): Adjust call to base
constructor to fix data size.
(Output_section_element_data::set_section_addresses): Register
Output_data_expression object for relaxation clean up.
(struct Input_section_info): Replace Relobj pointer and section index
pair with Output_section::Simple_input_section and Convert struct to a
class.
(Input_section_sorter::operator()): Adjust access to
Input_section_info data member to use accessors.
(Output_section_element_input::set_section_addresses): Use layout
parameter. Adjust code to use Output_section::Simple_input_section
and Input_secction_info classes. Register filler for relaxation
clean up.
(Orphan_output_section::set_section_addresses): Replace Relobj pointer
and section index pair with Output_section::Simple_input_section
class. Adjust code accordingly.
(Phdrs_element::release_segment): New method definition.
(Script_sections::attach_sections_using_phdrs_clause): Do not modify
segment list.
(Script_sections::release_segments): New method definition.
* gold/script-sections.h (Script_sections::release_segments): New
method declaration.
* gold/target.h (Target::may_relax, Target::relax,
Target::do_may_relax, Target::do_relax): New method definitions.
(Output_file::map_anonymous): Changed return type to bool. Record
map in base_ field.
(Output_file::map_no_anonymous): New method, broken out of map.
(Output_file::map): Use map_no_anonymous and map_anonymous.
* output.h (class Output_file): Update declarations.
* layout.cc (Layout::choose_output_section): If we find an
existing section, update the flags.
(Layout::create_notes): New function, broken out of
Layout::finalize.
(Layout::finalize): Don't create note sections.
(Layout::create_note): Don't crash if linker script discards
section.
(Layout::create_gold_note): Likewise.
(Layout::create_build_id): Likewise. Don't set
after_input_sections on the section.
(Layout::create_executable_stack_info): Remove target parameter.
Change caller.
* layout.h (class Layout): Declare create_notes. Update
declaration of create_executable_stack_info.
* gold.cc (queue_middle_tasks): Call create_notes.
* output.cc (Output_section::update_flags_for_input_section): Move
here from output.h. If SHF_ALLOC flag is newly set, mark address
invalid.
* output.h (Output_data::mark_address_invalid): New function.
(class Output_section): Only declare, not define,
update_flags_for_input_section. Remove set_flags.
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.
(Output_file::map): Use map_anonymous. If the regular mmap fails,
try an anonymous one. Report the size if the mmap fails.
* output.h (class Output_file): Declare map_anonymous.
* freebsd.h: New file.
* i386.cc: Include "freebsd.h".
(Target_i386): Derive from Target_freebsd rather than
Sized_target.
(Target_selector_i386): Derive from Target_selector_freebsd rather
than Target_selector.
* x86_64.cc: Include "freebsd.h".
(Target_x86_64): Derive from Target_freebsd rather than
Sized_target.
(Target_selector_x86_64): Derive from Target_selector_freebsd
rather than Target_selector.
* target.h (class Target): Add adjust_elf_header and
do_adjust_elf_header.
* output.cc (Output_file_header:: do_sized_write): Call target
adjust_elf_header routine.
* configure.tgt: Set targ_osabi.
* configure.ac: Define GOLD_DEFAULT_OSABI.
* parameters.cc (Parameters::default_target): Pass
GOLD_DEFAULT_OSABI to select_target.
* target-select.h (class Target_selector): Make instantiate_target
protected rather than private.
* Makefile.am (HFILES): Add freebsd.h.
* configure, Makefile.in, config.in: Rebuild.
ftruncate.
* ftruncate.c: New file, from gnulib.
* output.cc (posix_fallocate): Define dummy version if not
HAVE_POSIX_FALLOCATE.
(Output_file::map): Call posix_fallocate rather than lseek and
write.
* gold.h (ftruncate): Declare if not HAVE_FTRUNCATE.
* configure, Makefile.in, config.in: Rebuild.
* output.cc (Output_section::find_starting_output_address): Rename
from starting_output_address; add PADDR parameter; change return
type.
* output.h (class Output_section): Declare
find_starting_output_address instead of starting_output_address.
* object.cc (Sized_relobj::do_finalize_local_symbols): Handle a
section symbol for which we can't find a merge section.
* object.cc (Sized_relobj::do_layout): Use constant invalid_address
instead of -1U.
(Sized_relobj::do_finalize_local_symbols): Likewise.
(Sized_relobj::map_to_kept_section): Likewise.
* object.h (Sized_relobj::invalid_address): New constant.
(Sized_relobj::do_output_section_offset): Check for invalid_address
and return -1ULL.
* output.cc (Output_reloc::local_section_offset): Use constant
invalid_address instead of -1U.
(Output_reloc::get_address): Likewise.
(Output_section::output_address): Change -1U to -1ULL.
* output.h (Output_reloc::invalid_address): New constant.
* reloc.cc (Sized_relobj::write_sections): Use constant
invalid_address instead of -1U.
(Sized_relobj::relocate_sections): Likewise.
* symtab.cc (Symbol_table::sized_finalize_symbol): Handle symbol
values for merge sections.
* target-reloc.h (relocate_for_relocatable): Use constant
invalid_address instead of -1U.
set tls_segment_ or relro_segment_.
(Layout::make_output_segment): Set tls_segment_ and relro_segment_
when appropriate.
* output.h (Output_section::clear_is_relro): New function.
* output.cc (Output_segment::add_output_section): Handle SHF_TLS
sections specially even when output_data_ is empty.
(Output_segment::maximum_alignment): When first section is relro,
only force alignment for PT_LOAD segments.
* script.cc (script_data_segment_align): New function.
(script_data_segment_relro_end): New function.
* script-c.h (script_data_segment_align): Declare.
(script_data_segment_relro_end): Declare.
* script-sections.h (class Script_sections): Declare
data_segment_align and data_segment_relro_end. Add fields
segment_align_index_ and saw_relro_end_.
* script-sections.cc (class Sections_element): Add set_is_relro
virtual function. Add new bool* parameter to place_orphan_here.
Add get_output_section virtual function.
(class Output_section_definition): Add set_is_relro. Add new
bool* parameter to place_orphan_here. Add get_output_section.
Add is_relro_ field.
(Output_section_definition::Output_section_definition): Initialize
evaluated_address_, evaluated_load_address, evaluated_addralign_,
and is_relro_ fields.
(Output_section_definition::place_orphan_here): Add is_relro
parameter.
(Output_section_definition::set_section_addresses): Set relro for
output section.
(Output_section_definition::alternate_constraint): Likewise.
(class Orphan_output_section): Add new bool* parameter to
place_orphan_here. Add get_output_section.
(Orphan_output_section::place_orphan_here): Add is_relro
parameter.
(Script_sections::Script_sections): Initialize
data_segment_align_index_ and saw_relro_end_.
(Script_sections::data_segment_align): New function.
(Script_sections::data_segment_relro_end): New function.
(Script_sections::place_orphan): Set or clear is_relro.
(Script_sections::set_section_addresses): Force alignment of first
TLS section.
* yyscript.y (exp): Call script_data_segment_align and
script_data_segment_relro_end.
* testsuite/relro_script_test.t: New file.
* testsuite/relro_test.cc (using_script): Declare.
(t1, t2): Test using_script.
* testsuite/Makefile.am (check_PROGRAMS): Add relro_script_test.
(relro_script_test_SOURCES): Define.
(relro_script_test_DEPENDENCIES): Define.
(relro_script_test_LDFLAGS): Define.
(relro_script_test_LDADD): Define.
(relro_script_test.so): New target.
* testsuite/Makefile.in: Rebuild.
* descriptors.cc: New file.
* descriptors.h: New file.
* gold-threads.h (class Hold_optional_lock): New class.
* fileread.cc: Include "descriptors.h".
(File_read::~File_read): Release descriptor rather than closing
it.
(File_read::open) [file]: Call open_descriptor rather than open.
Set is_descriptor_opened_.
(File_read::open) [memory]: Assert that descriptor is not open.
(File_read::reopen_descriptor): New function.
(File_read::release): Release descriptor.
(File_read::do_read): Make non-const. Reopen descriptor.
(File_read::read): Make non-const.
(File_read::make_view): Reopen descriptor.
(File_read::do_readv): Likewise.
* fileread.h (class File_read): Add is_descriptor_opened_ field.
Update declarations.
* layout.cc: Include "descriptors.h".
(Layout::create_build_id): Use open_descriptor rather than open.
* output.cc: Include "descriptors.h".
(Output_file::open): Use open_descriptor rather than open.
* archive.cc (Archive::const_iterator): Change Archive to be
non-const.
(Archive::begin, Archive::end): Make non-const.
(Archive::count_members): Likewise.
* archive.h (class Archive): Update declarations.
* object.h (Object::read): Make non-const.
* Makefile.am (CCFILES): Add descriptors.cc.
(HFILES): Add descriptors.h.
* Makefile.in: Rebuild.
* object.h (class Relobj): Change map_to_output_ to
output_sections_, and just keep a section pointer. Change all
uses. Move comdat group support to Sized_relobj.
(Relobj::is_section_specially_mapped): Remove.
(Relobj::output_section): Remove poff parameter. Change all
callers.
(Relobj::output_section_offset): New function.
(Relobj::set_section_offset): Rewrite.
(Relobj::map_to_output): Remove.
(Relobj::output_sections): New function.
(Relobj::do_output_section_offset): New pure virtual function.
(Relobj::do_set_section_offset): Likewise.
(class Sized_relobj): Add section_offsets_ field. Add comdat
group support from Relobj. Update declarations.
(Sized_relobj::get_output_section_offset): New function.
(Sized_relobj::do_output_section_offset): New function.
(Sized_relobj::do_set_section_offset): New function.
* object.cc (Relobj::output_section_address): Remove.
(Sized_relobj::Sized_relobj): Initialize new fields.
(Sized_relobj::include_section_group): Cast find_kept_object to
Sized_relobj.
(Sized_relobj::include_linkonce_section): Likewise.
(Sized_relobj::do_layout): Use separate arrays for output section
and output offset.
(Sized_relobj::do_count_local_symbols): Change map_to_output to
output_sections.
(Sized_relobj::do_finalize_local_symbols): Change map_to_output to
output_sections and section_offsets.
(Sized_relobj::write_local_symbols): Likewise.
(map_to_kept_section): Compute output address directly.
* reloc.cc (Sized_relobj::do_read_relocs): Change map_to_output to
output_sections and section_offsets.
(Sized_relobj::write_sections): Likewise.
(Sized_relobj::relocate_sections): Likewise.
* symtab.cc (sized_finalize_symbol): Use output_section_offset.
* output.h (class Output_reloc): Update declarations. Change
u2_.relobj to Sized_relobj*.
(class Output_data_reloc): Change add functions to use
Sized_relobj*.
* output.cc (Output_reloc::Output_reloc): Change relobj to
Sized_relobj*.
(Output_reloc::local_section_offset): Change return type to
Elf_Addr. Use get_output_section_offset.
(Output_reloc::get_address): Likewise.
(Output_section::is_input_address_mapped): Don't call
is_section_specially_mapped.
(Output_section::output_offset): Likewise.
(Output_section::output_address): Likewise.
(Output_section::starting_output_address): Likewise.
* copy-relocs.cc (Copy_relocs::copy_reloc): Change object
parameter to Sized_relobj*.
(Copy_relocs::need_copy_reloc): Likewise.
(Copy_relocs::save): Likewise.
* copy-relocs.h (class Copy_relocs): Update declarations.
(class Copy_relocs::Copy_reloc_entry): Change constructor to use
Sized_relobj*. Change relobj_ field to Sized_relobj*.
* target-reloc.h (relocate_for_relocatable): Change
offset_in_output_section type to Elf_Addr. Change code that uses
it as well.
* layout.cc (Layout::layout): Always set *off.
* mapfile.cc (Mapfile::print_input_section): Use
output_section_offset.
* i386.cc (Target_i386::copy_reloc): Change object parameter to
Sized_relobj*.
* powerpc.cc (Target_powerpc::copy_reloc): Likewise.
* sparc.cc (Target_sparc::copy_reloc): Likewise.
* x86_64.cc (Target_x86_64::copy_reloc): Likewise.
* layout.cc (Layout::Layout): Initialize relro_segment_.
(Layout::add_output_section_data): Return the output section.
(Layout::make_output_section): Rcognize relro sections and mark
them appropriately.
(Layout::attach_allocated_section_to_segment): Put relro sections
in a PT_GNU_RELRO segment.
(Layout::create_initial_dynamic_sections): Mark the .dynamic
section as relro.
(Layout::segment_precedes): Sort PT_GNU_RELRO segments after
PT_TLS segments.
(Layout::linkonce_mapping): Map d.rel.ro.local to
.data.rel.ro.local.
(Layout::output_section_name): Us .data.rel.ro.local for any
section which begins with that.
* layout.h (class Layout): Update add_output_section_data
declaration. Add relro_segment_ field.
* output.cc (Output_section::Output_section): Initialize is_relro_
and is_relro_local_ fields.
(Output_segment::add_output_section): Group relro sections.
(Output_segment::is_first_section_relro): New function.
(Output_segment::maximum_alignment): If there is a relro section,
align the segment to the common page size.
(Output_segment::set_section_addresses): Track whether we are
looking at relro sections. If the last section is a relro
section, align to the common page size.
(Output_segment::set_section_list_addresses): Add in_relro
parameter. Change all callers. Align to the page size when
moving from relro to non-relro section.
(Output_segment::set_offset): Align memsz of a PT_GNU_RELRO
segment.
* output.h (class Output_section): Add is_relro_ and
is_relro_local_ fields.
(Output_section::is_relro): New function.
(Output_section::set_is_relro): New function.
(Output_section::is_relro_local): New function.
(Output_section::set_is_relro_local): New function.
(class Output_segment): Update declarations.
* i386.cc (Target_i386::got_section): Mark .got section as relro.
* sparc.cc (Target_sparc::got_section): Likewise.
* x86_64.cc (Target_x86_64::got_section): Likewise.
* testsuite/relro_test_main.cc: New file.
* testsuite/relro_test.cc: New file.
* testsuite/Makefile.am (check_PROGRAMS): Add relro_test.
(relro_test_SOURCES, relro_test_DEPENDENCIES): New variables.
(relro_test_LDFLAGS, relro_test_LDADD): New variables.
(relro_test.so, relro_test_pic.o): New targets.
* testsuite/Makefile.in: Rebuild.
(Layout::get_output_section): Ignore SHF_WRITE and SHF_EXECINSTR
in the name/type/flags to section mapping. Don't call
allocate_output_section.
(Layout::choose_output_section): Change parameter from adjust_name
to is_input_section. Don't permit input sections after sections
are attached to segments. Don't call allocate_output_section.
(Layout::layout_eh_frame): Call update_flags_for_input_section,
not write_enable_output_section.
(Layout::make_output_section): Don't push to
unattached_section_list_ nor call attach_to_segment. Call
attach_section_to_segment if sections are attached.
(Layout::attach_sections_to_segments): New function.
(Layout::attach_section_to_segment): New function.
(Layout::attach_allocated_section_to_segment): Rename from
attach_to_segment. Remove flags parameter.
(Layout::allocate_output_section): Remove function.
(Layout::write_enable_output_section): Remove function.
* layout.h (class Layout): Update for above changes. Add new
field sections_are_attached_.
* output.h (Output_section::update_flags_for_input_section): New
function.
* output.cc (Output_section::add_input_section): Call
update_flags_for_input_section.
* gold.cc (queue_middle_tasks): Call attach_sections_to_segments.
Add support for TLS descriptors for i386 and x86_64.
* i386.cc (Target_i386::Relocate::tls_desc_gd_to_ie): New function.
(Target_i386::Relocate::tls_desc_gd_to_le): New function.
(Target_i386::Got_type): Add GOT_TYPE_TLS_NOFFSET and
GOT_TYPE_TLS_DESC.
(Target_i386::got_mod_index_entry): Remove unnecessary code.
(Target_i386::Scan::local): Implement R_386_TLS_GOTDESC and
R_386_TLS_DESC_CALL relocations. Fix problem with initial-exec
relocations.
(Target_i386::Scan::global): Fix problem with GD-to-IE relaxation.
Implement R_386_TLS_GOTDESC and R_386_TLS_DESC_CALL relocations;
Fix problem with initial-exec relocations.
(Target_i386::Relocate::relocate_tls): Likewise.
(Target_i386::Relocate::tls_gd_to_ie): Fix problem with GD-to-IE
relaxation.
* output.cc (Output_data_dynamic::Dynamic_entry::write): Add
support for section-plus-offset dynamic table entries.
* output.h (Output_data_dynamic::add_section_plus_offset): New function.
(Output_data_dynamic::Dynamic_entry): Add support for
section-plus-offset dynamic table entries.
(Output_data_dynamic::Classification): Likewise.
(Output_data_dynamic::classification_): Renamed offset_.
* x86_64.cc (Target_x86_64::Relocate::tls_desc_gd_to_ie): New function.
(Target_x86_64::Relocate::tls_desc_gd_to_le): New function.
(Target_x86_64::make_plt_section): New function.
(Target_x86_64::reserve_tlsdesc_entries): New function.
(Output_data_plt_x86_64::Output_data_plt_x86_64): Add new parameter.
(Output_data_plt_x86_64::reserve_tlsdesc_entry): New function.
(Output_data_plt_x86_64::has_tlsdesc_entry): New function.
(Output_data_plt_x86_64::get_tlsdesc_got_offset): New function.
(Output_data_plt_x86_64::get_tlsdesc_plt_offset): New function.
(Output_data_plt_x86_64::tlsdesc_plt_entry): New field.
(Output_data_plt_x86_64::set_final_data_size): Move out of line;
add extra PLT entry for TLS descriptors.
(Output_data_plt_x86_64::got_): New field.
(Output_data_plt_x86_64::tlsdesc_got_offset_): New field.
(Output_data_plt_x86_64::Output_data_plt_x86_64): Initialize new
fields.
(Output_data_plt_x86_64::do_write): Write extra PLT entry for TLS
descriptors.
(Target_x86_64::make_plt_entry): Factor out make_plt_section.
(Target_x86_64::got_mod_index_entry): Remove unnecessary code.
(Target_x86_64::Scan::local): Implement R_386_TLS_GOTDESC and
R_386_TLS_DESC_CALL relocations.
(Target_x86_64::Scan::global): Likewise.
(Target_x86_64::do_finalize_sections): Add dynamic table entries
for TLS descriptors.
(Relocate::relocate_tls): Fix problem with GD-to-IE relaxation.
Implement R_386_TLS_GOTDESC and R_386_TLS_DESC_CALL relocations.
(Target_x86_64::Relocate::tls_gd_to_ie): Fix problem with
GD-to-IE relaxation.
* configure.ac: Export new conditional variables TLS_GNU2_DIALECT
and TLS_DESCRIPTORS.
* Makefile.in: Rebuild.
* configure: Rebuild.
* testsuite/Makefile.am (tls_shared_gd_to_ie_test): New target.
(tls_test_shared2.so): New target.
(tls_shared_gd_to_ie_test_SOURCES): New variable.
(tls_shared_gd_to_ie_test_DEPENDENCIES): New variable.
(tls_shared_gd_to_ie_test_LDFLAGS): New variable.
(tls_shared_gd_to_ie_test_LDADD): New variable.
(tls_shared_gnu2_gd_to_ie_test): New target.
(tls_test_gnu2.o, tls_test_file2_gnu2.o, tls_test_gnu2_shared2.so):
New targets.
(tls_shared_gnu2_gd_to_ie_test_SOURCES): New variable.
(ls_shared_gnu2_gd_to_ie_test_DEPENDENCIES): New variable.
(tls_shared_gnu2_gd_to_ie_test_LDFLAGS): New variable.
(tls_shared_gnu2_gd_to_ie_test_LDADD): New variable.
(tls_shared_gnu2_test): New target.
(tls_test_gnu2_shared.so): New target.
(tls_shared_gnu2_test_SOURCES): New variable.
(tls_shared_gnu2_test_DEPENDENCIES): New variable.
(tls_shared_gnu2_test_LDFLAGS): New variable.
(tls_shared_gnu2_test_LDADD): New variable.
* testsuite/Makefile.in: Rebuild.
* testsuite/Makefile.
addend parameter. Change caller. Handle merge sections.
(Output_reloc<SHT_REL>::symbol_value): Change parameter type from
Address to Addend. Don't add in the result of
local_section_offset, pass down the addend and use the returned
value.
* output.h (class Output_reloc<SHT_REL>): Add Addend typedef.
Update declarations of local_section_offset and symbol_value.
* testsuite/two_file_test_1.cc (t18): New function.
* testsuite/two_file_test_2.cc (f18): New function.
* testsuite/two_file_test_main.cc (main): Call t18.
* testsuite/two_file_test.h (t18, f18): Declare.
(Output_section::Input_section_sort_entry::has_priority): New
function.
(Output_section::Input_section_sort_entry::match_file_name): New
function.
(Output_section::Input_section_sort_entry::match_section_name):
Remove.
(Output_section::Input_section_sort_entry::match_section_name_prefix):
Remove.
(Output_section::Input_section_sort_entry::match_section_file):
Remove.
(Output_section::Input_section_sort_compare::operator()): Rewrite
using new Input_section_sort_entry functions. Sort crtbegin and
crtend first. Sort sections with no priority before sections with
a priority.
* testsuite/initpri1.c (d3): Check j != 4.
(cd5): New constructor/destructor function.
(main): Check j != 2.
name that needs sorting, set the must_sort flag for the output
section.
(Layout::make_output_section): If the name of the output section
indicates that it might require sorting, set the may_sort flag.
* output.h (Output_section::may_sort_attached_input_sections): New
function.
(Output_section::set_may_sort_attached_input_sections): New
function.
(Output_section::must_sort_attached_input_sections): New
function.
(Output_section::set_must_sort_attached_input_sections): New
function.
(class Output_section): Declare Input_section_sort_entry. Define
Input_section_sort_compare. Declare
sort_attached_input_sections. Add new fields:
may_sort_attached_input_sections_,
must_sort_attached_input_sections_,
attached_input_sections_are_sorted_.
* output.cc (Output_section::Output_section): Initialize new
fields.
(Output_section::add_input_section): Add an entry to
input_sections_ if may_sort or must_sort are true.
(Output_section::set_final_data_size): Call
sort_attached_input_sections if necessary.
(Output_section::Input_section_sort_entry): Define new class.
(Output_section::Input_section_sort_compare::operator()): New
function.
(Output_section::sort_attached_input_sections): New function.
* configure.ac: Check whether the compiler supports constructor
priorities. Define a CONSTRUCTOR_PRIORITY automake conditional.
* testsuite/initpri1.c: New file.
* testsuite/Makefile.am (check_PROGRAMS): Add initpri1 if
CONSTRUCTOR_PRIORITY.
(initpri1_SOURCES, initpri1_DEPENDENCIES): New variables.
(initpri1_LDFLAGS): New variable.
* configure, Makefile.in, testsuite/Makefile.in: Rebuild.
Fix problems building gold with gcc 4.3.0.
* gold.h (TEMPLATE_ATTRIBUTE_PRINTF_4): Define.
(gold_error_at_location, gold_warning_at_location): Use it.
* configure.ac: Check whether we can compile and use a template
function with a printf attribute.
* x86_64.cc (Target_x86_64::do_code_fill): Swap out a 32-bit value
when jumping over bytes.
* object.cc: Instantiate Object::read_section_data.
* debug.h: Include <cstring>
* dwarf_reader.cc: Include <algorithm>
* main.cc: Include <cstring>.
* options.cc: Include <cstring>.
* output.cc: Include <cstring>.
* script.cc: Include <cstring>.
* script.h: Include <string>.
* symtab.cc: Include <cstring> and <algorithm>.
* target-select.cc: Include <cstring>.
* version.cc: Include <string>.
* testsuite/testmain.cc: Include <cstdlib>.
* configure, config.in: Rebuild.