binutils-gdb/gold/object.h

3060 lines
94 KiB
C
Raw Permalink Normal View History

2006-08-05 01:10:59 +02:00
// object.h -- support for an object file for linking in gold -*- C++ -*-
// Copyright (C) 2006-2019 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
// MA 02110-1301, USA.
2006-08-05 01:10:59 +02:00
#ifndef GOLD_OBJECT_H
#define GOLD_OBJECT_H
#include <string>
#include <vector>
2006-08-05 01:10:59 +02:00
#include "elfcpp.h"
#include "elfcpp_file.h"
2006-08-05 01:10:59 +02:00
#include "fileread.h"
#include "target.h"
2010-03-22 Rafael Espindola <espindola@google.com> * archive.cc (Should_include): Move to archive.h. (should_include_member): Make it a member of Archive. (Lib_group): New. (Add_lib_group_symbols): New. * archive.h: Include options.h. (Archive_member): Moved from Archive. (Should_include): Moved from archive.cc. (Lib_group): New. (Add_lib_group_symbols): New. * dynobj.cc (do_should_include_member): New. * dynobj.h (do_should_include_member): New. * gold.cc (queue_initial_tasks): Update call to queue. * main.cc (main): Print lib group stats. * object.cc (do_should_include_member): New. * object.h: Include archive.h. (Object::should_include_member): New. (Object::do_should_include_member): New. (Sized_relobj::do_should_include_member): New. * options.cc (General_options::parse_start_lib): New. (General_options::parse_end_lib): New. (Input_arguments::add_file): Handle lib groups. (Input_arguments::start_group): Check we are not in a lib. (Input_arguments::start_lib): New. (Input_arguments::end_lib): New. * options.h (General_options): Add start_lib and end_lib. (Input_argument::lib_): New. (Input_argument::lib): New. (Input_argument::is_lib): New. (Input_file_lib): New. (Input_arguments::in_lib_): New. (Input_arguments::in_lib): New. (Input_arguments::start_lib): New. (Input_arguments::end_lib_): New. * plugin.cc (Pluginobj::get_symbol_resolution_info): Mark symbols in unused members as preempted. (Sized_pluginobj::do_should_include_member): New. * plugin.h (Sized_pluginobj::do_should_include_member): New. * readsyms.cc (Read_symbols::locks): If we are just reading a member, return the blocker. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::do_read_symbols): Handle lib groups. (Read_symbols::get_name): Handle lib groups. * readsyms.h (Read_symbols): Add an archive member pointer. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::member_): New. * script.cc (read_input_script): Update call to queue_soon.
2010-03-22 15:18:24 +01:00
#include "archive.h"
2006-08-05 01:10:59 +02:00
namespace gold
{
class General_options;
class Task;
* cref.cc: New file. * cref.h: New file. * options.h (class General_options): Add --print-symbol-counts. * main.cc (main): Issue defined symbol report if requested. * archive.cc (Archive::interpret_header): Make into a const member function. (Archive::add_symbols): Call Input_objects::archive_start and archive_stop. (Archive::const_iterator): Define new class. (Archive::begin, Archive::end): New functions. (Archive::include_all_members): Rewrite to use iterator. (Archive::count_members): New function. * archive.h (class Archive): Update declarations. (Archive::filename): New function. * object.cc: Include "cref.h". (Sized_relobj::Sized_relobj): Initialize defined_count_. (Sized_relobj::do_get_global_symbol_counts): New function. (Input_objects::add_object): Add object to cross-referencer. (Input_objects::archive_start): New function. (Input_objects::archive_stop): New function. (Input_objects::print_symbol_counts): New function. * object.h: Declare Cref and Archive. (Object::get_global_symbol_counts): New function. (Object::do_get_global_symbol_counts): New pure virtual function. (class Sized_relobj): Add defined_count_ field. Update declarations. (class Input_objects): Add cref_ field. Update constructor. Update declarations. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and defined_count_. (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing symbol counts. (Sized_dynobj::do_get_global_symbol_counts): New function. * dynobj.h (class Sized_dynobj): Add fields symbols_ and defined_count_. Update declarations. Define Symbols typedef. * symtab.cc (Symbol_table::add_from_relobj): Add defined parameter. Change all callers. (Symbol_table::add_from_dynobj): Add sympointers and defined parameters. Change all callers. * symtab.h (class Symbol_table): Update declarations. * Makefile.am (CCFILES): Add cref.cc. (HFILES): Add cref.h. * Makefile.in: Rebuild.
2008-07-23 00:08:43 +02:00
class Cref;
class Layout;
Further improve warnings for relocations referring to discarded sections. Relocations referring to discarded sections are now treated as errors instead of warnings. Also with this patch, we will now print the section group signature and the object file with the prevailing definition of that group along with the name of the symbol that the relocation is referring to. This additional information should be much more useful to anyone trying to track down the source of such errors. To do so, we now map each discarded section to the Kept_section info in the Layout class, and defer the logic that maps a discarded section to its counterpart in the kept group. This gives us the information we need to identify the signature symbol given the discarded section, and the name of the object file that provided the prevailing (i.e., first) definition of that group. gold/ * object.cc (Sized_relobj_file::include_section_group): Store reference to Kept_section info for discarded comdat sections regardless of size. Move size checking to map_to_kept_section. (Sized_relobj_file::include_linkonce_section): Likewise. (Sized_relobj_file::map_to_kept_section): Add section name parameter. Insert size checking logic from above functions. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. * object.h (Sized_relobj_file::map_to_kept_section): Add section_name parameter. Adjust all callers. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. (Sized_relobj_file::Kept_comdat_section): Replace object and shndx fields with sh_size, kept_section, symndx, and is_comdat fields. (Sized_relobj_file::set_kept_comdat_section): Replace kept_object and kept_shndx parameters with is_comdat, symndx, sh_size, and kept_section. (Sized_relobj_file::get_kept_comdat_section): Likewise. * target-reloc.h (enum Comdat_behavior): Change CB_WARNING to CB_ERROR. Adjust all references. (issue_undefined_symbol_error): New function template. (relocate_section): Pass section name to map_to_kept_section. Move discarded section code to new function above. * aarch64.cc (Target_aarch64::scan_reloc_section_for_stubs): Move declaration for gsym out one level. Call issue_discarded_error. * arm.cc (Target_arm::scan_reloc_section_for_stubs): Likewise. * powerpc.cc (Relocate_comdat_behavior): Change CB_WARNING to CB_ERROR.
2018-04-07 01:06:16 +02:00
class Kept_section;
PR 10893 * 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.
2010-08-20 00:50:16 +02:00
class Output_data;
class Output_section;
Remove empty class Merge_map. 2015-03-02 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> * ehframe.cc (Cie::set_output_offset): Pass in and use a Output_section_data instead of a Merge_map. (Eh_frame::Eh_frame): Don't initialize merge_map_. (Eh_frame::read_cie): Use add_merge_mapping instead of Merge_map::add_mapping. (Eh_frame::read_fde): Ditto. (Eh_frame::set_final_data_size): Use this instead of this->merge_map_. (Eh_frame::do_output_offset): Use merge_output_offset istead of merge_map_->get_output_offset. (Eh_frame::do_is_merge_section_for): Delete. * ehframe.h (Fde::add_mapping): Pass in and use a Output_section_data instead of a Merge_map. (Cie::set_output_offset): Pass in a Output_section_data instead of a Merge_map. (Eh_frame::do_is_merge_section_for): Delete. (Eh_frame::merge_map_): Delete. * merge.cc (Object_merge_map::get_or_make_input_merge_map): Pass in and use a Output_section_data instead of a Merge_map. (Object_merge_map::add_mapping): Ditto. (Object_merge_map::get_output_offset): Remove the merge_map argument. (Object_merge_map::is_merge_section_for): Pass in and use a Output_section_data instead of a Merge_map. (Merge_map): Delete. (Output_merge_base::do_output_offset): Use merge_output_offset instead of merge_map_.get_output_offset. (Output_merge_base::do_is_merge_section_for): Delete. (Output_merge_data::do_add_input_section): Use object->add_merge_mapping instead of add_mapping. (Output_merge_string<Char_type>::finalize_merged_data): Ditto. * merge.h (Merge_map): Delete forward declaration. (Object_merge_map::add_mapping): Pass in and use a Output_section_data instead of a Merge_map. (Object_merge_map::get_output_offset): Remove the merge_map argument. (Object_merge_map::is_merge_section_for): Pass in and use a Output_section_data instead of a Merge_map. (Input_merge_map::Object_merge_map::merge_map): Replace with output_data. (Object_merge_map::get_or_make_input_merge_map): Pass in and use a Output_section_data instead of a Merge_map. (Merge_map): Delete. (Output_merge_base::Output_merge_base): Don't initialize merge_map_. (Output_merge_base::do_is_merge_section_for): Delete. (Output_merge_base::add_mapping): Delete. (Output_merge_base::merge_map_): Delete. * object.cc (Relobj::initialize_input_to_output_map): New. (Relobj::initialize_input_to_output_map): New. (Relobj::merge_output_offset): New. (Relobj::is_merge_section_for): New. (Relobj::initialize_input_to_output_map): Instantiate for 32 and 64 bits. * object.h (Relobj::merge_map): Delete. (initialize_input_to_output_map): New. (set_merge_map): Delete. (add_merge_mapping): New. (merge_output_offset): New. (is_merge_section_for): New. * output.cc (Output_section::Input_section::is_merge_section_for): Use object->is_merge_section_for. * output.h (Output_section_data::is_merge_section_for): Delete. (Output_section_data::do_is_merge_section_for): Delete. * reloc.cc (Merged_symbol_value<size>::initialize_input_to_output_map): Use object->initialize_input_to_output_map. (Merged_symbol_value<size>::value_from_output_section): Use object->merge_output_offset.
2015-03-05 00:10:18 +01:00
class Output_section_data;
class Output_file;
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
class Output_symtab_xindex;
Add plugin functionality for link-time optimization (LTO). include/: * plugin-api.h: New file. gold/: * configure.ac (plugins): Add --enable-plugins option. * configure: Regenerate. * config.in: Regenerate. * Makefile.am (LIBDL): New variable. (CCFILES): Add plugin.cc. (HFILES): Add plugin.h. (ldadd_var): Add LIBDL. * Makefile.in: Regenerate. * archive.cc: Include "plugin.h". (Archive::setup): Don't preread archive symbols when using a plugin. (Archive::get_file_and_offset): Add memsize parameter. Change callers. (Archive::get_elf_object_for_member): Call plugin hooks for claiming files. (Archive::include_member): Add symbols from plugin objects. * archive.h (Archive::get_file_and_offset): Add memsize parameter. * descriptors.cc (Descriptors::open): Check for file descriptors abandoned by plugins. (Descriptors::claim_for_plugin): New function. * descriptors.h (Descriptors::claim_for_plugin): New function. (Open_descriptor::is_claimed): New field. (claim_descriptor_for_plugin): New function. * fileread.cc (File_read::claim_for_plugin): New function. * fileread.h (File_read::claim_for_plugin): New function. (File_read::descriptor): New function. * gold.cc: Include "plugin.h". (queue_initial_tasks): Add task to call plugin hooks for generating new object files. * main.cc: Include "plugin.h". (main): Load plugin libraries. * object.h (Pluginobj): Declare. (Object::pluginobj): New function. (Object::do_pluginobj): New function. (Object::set_target): New function. * options.cc: Include "plugin.h". (General_options::parse_plugin): New function. (General_options::General_options): Initialize plugins_ field. (General_options::add_plugin): New function. * options.h (Plugin_manager): Declare. (General_options): Add --plugin option. (General_options::has_plugins): New function. (General_options::plugins): New function. (General_options::add_plugin): New function. (General_options::plugins_): New field. * plugin.cc: New file. * plugin.h: New file. * readsyms.cc: Include "plugin.h". (Read_symbols::do_read_symbols): Check for archive before checking for ELF file. Call plugin hooks to claim files. * resolve.cc (Symbol_table::resolve): Record when symbol is referenced from a real object file; force override when processing replacement files. * symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field. (Symbol::init_base_object): Likewise. (Symbol::init_base_output_data): Likewise. (Symbol::init_base_output_segment): Likewise. (Symbol::init_base_constant): Likewise. (Symbol::init_base_undefined): Likewise. (Symbol::output_section): Assert that object is not a plugin. (Symbol_table::add_from_pluginobj): New function. (Symbol_table::sized_finalize_symbol): Treat symbols from plugins as undefined. (Symbol_table::sized_write_globals): Likewise. (Symbol_table::add_from_pluginobj): Instantiate template. * symtab.h (Sized_pluginobj): Declare. (Symbol::in_real_elf): New function. (Symbol::set_in_real_elf): New function. (Symbol::in_real_elf_): New field. (Symbol_table::add_from_pluginobj): New function. * testsuite/Makefile.am (AM_CFLAGS): New variable. (LIBDL): New variable. (LDADD): Add LIBDL. (check_PROGRAMS): Add plugin_test_1 and plugin_test_2. (check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh. (check_DATA): Add plugin_test_1.err and plugin_test_2.err. (MOSTLYCLEANFILES): Likewise. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c: New file. * testsuite/plugin_test_1.sh: New file. * testsuite/plugin_test_2.sh: New file.
2008-09-20 00:54:57 +02:00
class Pluginobj;
class Dynobj;
2007-11-27 07:13:33 +01:00
class Object_merge_map;
2008-02-06 09:13:50 +01:00
class Relocatable_relocs;
struct Symbols_data;
2007-05-16 19:42:48 +02:00
template<typename Stringpool_char>
class Stringpool_template;
2006-08-05 01:10:59 +02:00
// Data to pass from read_symbols() to add_symbols().
struct Read_symbols_data
{
Read_symbols_data()
: section_headers(NULL), section_names(NULL), symbols(NULL),
symbol_names(NULL), versym(NULL), verdef(NULL), verneed(NULL)
{ }
~Read_symbols_data();
// Section headers.
File_view* section_headers;
// Section names.
File_view* section_names;
// Size of section name data in bytes.
section_size_type section_names_size;
2006-08-05 01:10:59 +02:00
// Symbol data.
File_view* symbols;
// Size of symbol data in bytes.
section_size_type symbols_size;
// Offset of external symbols within symbol data. This structure
// sometimes contains only external symbols, in which case this will
// be zero. Sometimes it contains all symbols.
section_offset_type external_symbols_offset;
2006-08-05 01:10:59 +02:00
// Symbol names.
File_view* symbol_names;
// Size of symbol name data in bytes.
section_size_type symbol_names_size;
// Version information. This is only used on dynamic objects.
// Version symbol data (from SHT_GNU_versym section).
File_view* versym;
section_size_type versym_size;
// Version definition data (from SHT_GNU_verdef section).
File_view* verdef;
section_size_type verdef_size;
unsigned int verdef_info;
// Needed version data (from SHT_GNU_verneed section).
File_view* verneed;
section_size_type verneed_size;
unsigned int verneed_info;
2006-08-05 01:10:59 +02:00
};
// Information used to print error messages.
struct Symbol_location_info
{
std::string source_file;
std::string enclosing_symbol_name;
elfcpp::STT enclosing_symbol_type;
};
// Data about a single relocation section. This is read in
// read_relocs and processed in scan_relocs.
struct Section_relocs
{
Section_relocs()
: contents(NULL)
{ }
~Section_relocs()
{ delete this->contents; }
// Index of reloc section.
unsigned int reloc_shndx;
// Index of section that relocs apply to.
unsigned int data_shndx;
// Contents of reloc section.
File_view* contents;
// Reloc section type.
unsigned int sh_type;
// Number of reloc entries.
size_t reloc_count;
// Output section.
Output_section* output_section;
// Whether this section has special handling for offsets.
bool needs_special_offset_handling;
2008-02-27 23:38:18 +01:00
// Whether the data section is allocated (has the SHF_ALLOC flag set).
bool is_data_section_allocated;
};
// Relocations in an object file. This is read in read_relocs and
// processed in scan_relocs.
struct Read_relocs_data
{
Read_relocs_data()
: local_symbols(NULL)
{ }
~Read_relocs_data()
{ delete this->local_symbols; }
typedef std::vector<Section_relocs> Relocs_list;
// The relocations.
Relocs_list relocs;
// The local symbols.
File_view* local_symbols;
};
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
// The Xindex class manages section indexes for objects with more than
// 0xff00 sections.
class Xindex
{
public:
Xindex(int large_shndx_offset)
: large_shndx_offset_(large_shndx_offset), symtab_xindex_()
{ }
// Initialize the symtab_xindex_ array, given the object and the
// section index of the symbol table to use.
template<int size, bool big_endian>
void
initialize_symtab_xindex(Object*, unsigned int symtab_shndx);
// Read in the symtab_xindex_ array, given its section index.
// PSHDRS may optionally point to the section headers.
template<int size, bool big_endian>
void
read_symtab_xindex(Object*, unsigned int xindex_shndx,
const unsigned char* pshdrs);
// Symbol SYMNDX in OBJECT has a section of SHN_XINDEX; return the
// real section index.
unsigned int
sym_xindex_to_shndx(Object* object, unsigned int symndx);
private:
// The type of the array giving the real section index for symbols
// whose st_shndx field holds SHN_XINDEX.
typedef std::vector<unsigned int> Symtab_xindex;
// Adjust a section index if necessary. This should only be called
// for ordinary section indexes.
unsigned int
adjust_shndx(unsigned int shndx)
{
if (shndx >= elfcpp::SHN_LORESERVE)
shndx += this->large_shndx_offset_;
return shndx;
}
// Adjust to apply to large section indexes.
int large_shndx_offset_;
// The data from the SHT_SYMTAB_SHNDX section.
Symtab_xindex symtab_xindex_;
};
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
// A GOT offset list. A symbol may have more than one GOT offset
// (e.g., when mixing modules compiled with two different TLS models),
// but will usually have at most one. GOT_TYPE identifies the type of
// GOT entry; its values are specific to each target.
class Got_offset_list
{
public:
Got_offset_list()
: got_type_(-1U), got_offset_(0), got_next_(NULL)
{ }
Got_offset_list(unsigned int got_type, unsigned int got_offset)
: got_type_(got_type), got_offset_(got_offset), got_next_(NULL)
{ }
~Got_offset_list()
{
if (this->got_next_ != NULL)
{
delete this->got_next_;
this->got_next_ = NULL;
}
}
// Initialize the fields to their default values.
void
init()
{
this->got_type_ = -1U;
this->got_offset_ = 0;
this->got_next_ = NULL;
}
// Set the offset for the GOT entry of type GOT_TYPE.
void
set_offset(unsigned int got_type, unsigned int got_offset)
{
if (this->got_type_ == -1U)
{
this->got_type_ = got_type;
this->got_offset_ = got_offset;
}
else
{
for (Got_offset_list* g = this; g != NULL; g = g->got_next_)
{
if (g->got_type_ == got_type)
{
g->got_offset_ = got_offset;
return;
}
}
Got_offset_list* g = new Got_offset_list(got_type, got_offset);
g->got_next_ = this->got_next_;
this->got_next_ = g;
}
}
// Return the offset for a GOT entry of type GOT_TYPE.
unsigned int
get_offset(unsigned int got_type) const
{
for (const Got_offset_list* g = this; g != NULL; g = g->got_next_)
{
if (g->got_type_ == got_type)
return g->got_offset_;
}
return -1U;
}
// Return a pointer to the list, or NULL if the list is empty.
const Got_offset_list*
get_list() const
{
if (this->got_type_ == -1U)
return NULL;
return this;
}
// Abstract visitor class for iterating over GOT offsets.
class Visitor
{
public:
Visitor()
{ }
virtual
~Visitor()
{ }
virtual void
visit(unsigned int, unsigned int) = 0;
};
// Loop over all GOT offset entries, calling a visitor class V for each.
void
for_all_got_offsets(Visitor* v) const
{
if (this->got_type_ == -1U)
return;
for (const Got_offset_list* g = this; g != NULL; g = g->got_next_)
v->visit(g->got_type_, g->got_offset_);
}
private:
unsigned int got_type_;
unsigned int got_offset_;
Got_offset_list* got_next_;
};
// The Local_got_entry_key used to index the GOT offsets for local
// non-TLS symbols, and tp-relative offsets for TLS symbols.
class Local_got_entry_key
{
public:
Local_got_entry_key(unsigned int symndx, uint64_t addend)
: symndx_(symndx), addend_(addend)
{}
// Whether this equals to another Local_got_entry_key.
bool
eq(const Local_got_entry_key& key) const
{
return (this->symndx_ == key.symndx_ && this->addend_ == key.addend_);
}
// Compute a hash value for this using 64-bit FNV-1a hash.
size_t
hash_value() const
{
uint64_t h = 14695981039346656037ULL; // FNV offset basis.
uint64_t prime = 1099511628211ULL;
h = (h ^ static_cast<uint64_t>(this->symndx_)) * prime;
h = (h ^ static_cast<uint64_t>(this->addend_)) * prime;
return h;
}
// Functors for associative containers.
struct equal_to
{
bool
operator()(const Local_got_entry_key& key1,
const Local_got_entry_key& key2) const
{ return key1.eq(key2); }
};
struct hash
{
size_t
operator()(const Local_got_entry_key& key) const
{ return key.hash_value(); }
};
private:
// The local symbol index.
unsigned int symndx_;
// The addend.
uint64_t addend_;
};
Support compressed debug sections in dynamic object files. This patch adds support for reading compressed debug info in shared objects. It actually simplifies things, by moving the support for compressed sections all the way up to the top-level Object class, eliminating the need for several virtual methods. gold/ * dwp.cc (Sized_relobj_dwo::do_section_contents): Delete. (Sized_relobj_dwo::setup): Build compressed section map. (Sized_relobj_dwo::do_decompressed_section_contents): Delete. * dynobj.cc (Sized_dynobj::base_read_symbols): Build compressed section map. * object.cc (Sized_relobj_file::Sized_relobj_file): Remove compressed_sections_ field. (build_compressed_section_map): Take Object instead of Sized_relobj_file parameter; add decompress_if_needed parameter. (Sized_relobj_file::do_find_special_sections): Store compressed section map in parent Object. (Sized_relobj_file::do_decompressed_section_contents): Move implementation to Object::decompressed_section_contents. (Sized_relobj_file::do_discard_decompressed_sections): Move implementation to Object::discard_decompressed_sections. * object.h (build_compressed_section_map): Declare. (Object::Object): Add compressed_sections_ field. (Object::section_is_compressed): Move implementation here. (Object::decompressed_section_contents): De-virtualize. (Object::discard_decompressed_sections): De-virtualize. (Object::do_section_is_compressed): Delete. (Object::do_decompressed_section_contents): Delete. (Object::set_compressed_sections): New method. (Object::compressed_sections): New method. (Object::compressed_sections_): New data member. (Compressed_section_info, Compressed_section_map): Move to top of file. (Sized_relobj_file::do_section_is_compressed): Delete. (Sized_relobj_file::do_decompressed_section_contents): Delete. (Sized_relobj_file::do_discard_decompressed_sections): Delete. (Sized_relobj_file::compressed_sections_): Move to Object class.
2015-03-22 02:50:11 +01:00
// Type for mapping section index to uncompressed size and contents.
struct Compressed_section_info
{
section_size_type size;
Add SHF_COMPRESSED section decompression to gold This patch adds SHF_COMPRESSED section decompression to gold. PR gold/18321 * compressed_output.h (decompress_input_section): Add arguments for ELF class, big endian and sh_flags. * compressed_output.cc (decompress_input_section): Likewise. Support the SHF_COMPRESSED section. * dynobj.h (Dynobj): Add elfsize and is_big_endian member functions. * plugin.h (Pluginobj): Likewise. * layout.cc (Layout::get_output_section_flags): Also clear the SHF_COMPRESSED bit. * object.h (Compressed_section_info): Add flag to store sh_flags. (Object): Add pure virtual elfsize and is_big_endian member functions. * object.cc (need_decompressed_section): Don't skip the ".zdebug" prefix here. (build_compressed_section_map): Check SHF_COMPRESSED for uncompressed size. Store sh_flags in Compressed_section_info. Pass size, big_endian and sh_flags to decompress_input_section. Skip the ".debug"/".zdebug" prefix when passing section name to need_decompressed_section. (Sized_relobj_file<size, big_endian>::do_find_special_section): Don't check ".zdebug_*" sections. (Object::decompressed_section_contents): Pass ELF class, big endian and sh_flags to decompress_input_section. * reloc.cc (Sized_relobj_file<size, big_endian>::write_sections): Likewise. * testsuite/Makefile.am (check_DATA): Add debug_msg_cdebug_gabi.err and gdb_index_test_2_gabi.stdout. (MOSTLYCLEANFILES): Add debug_msg_cdebug_gabi.err and gdb_index_test_2_gabi.stdout. (debug_msg_cdebug_gabi.o): New. (odr_violation1_cdebug_gabi.o): Likewise. (odr_violation2_cdebug_gabi.o): Likewise. (debug_msg_cdebug_gabi.err): Likewise. (check_SCRIPTS): Add gdb_index_test_2_gabi.sh. (gdb_index_test_cdebug_gabi.o): Likewise. (gdb_index_test_2_gabi): Likewise. (gdb_index_test_2_gabi.stdout): Likewise. * testsuite/gdb_index_test_2_gabi.sh: New file. * testsuite/Makefile.in: Regenerated.
2015-07-12 19:50:25 +02:00
elfcpp::Elf_Xword flag;
uint64_t addralign;
Support compressed debug sections in dynamic object files. This patch adds support for reading compressed debug info in shared objects. It actually simplifies things, by moving the support for compressed sections all the way up to the top-level Object class, eliminating the need for several virtual methods. gold/ * dwp.cc (Sized_relobj_dwo::do_section_contents): Delete. (Sized_relobj_dwo::setup): Build compressed section map. (Sized_relobj_dwo::do_decompressed_section_contents): Delete. * dynobj.cc (Sized_dynobj::base_read_symbols): Build compressed section map. * object.cc (Sized_relobj_file::Sized_relobj_file): Remove compressed_sections_ field. (build_compressed_section_map): Take Object instead of Sized_relobj_file parameter; add decompress_if_needed parameter. (Sized_relobj_file::do_find_special_sections): Store compressed section map in parent Object. (Sized_relobj_file::do_decompressed_section_contents): Move implementation to Object::decompressed_section_contents. (Sized_relobj_file::do_discard_decompressed_sections): Move implementation to Object::discard_decompressed_sections. * object.h (build_compressed_section_map): Declare. (Object::Object): Add compressed_sections_ field. (Object::section_is_compressed): Move implementation here. (Object::decompressed_section_contents): De-virtualize. (Object::discard_decompressed_sections): De-virtualize. (Object::do_section_is_compressed): Delete. (Object::do_decompressed_section_contents): Delete. (Object::set_compressed_sections): New method. (Object::compressed_sections): New method. (Object::compressed_sections_): New data member. (Compressed_section_info, Compressed_section_map): Move to top of file. (Sized_relobj_file::do_section_is_compressed): Delete. (Sized_relobj_file::do_decompressed_section_contents): Delete. (Sized_relobj_file::do_discard_decompressed_sections): Delete. (Sized_relobj_file::compressed_sections_): Move to Object class.
2015-03-22 02:50:11 +01:00
const unsigned char* contents;
};
typedef std::map<unsigned int, Compressed_section_info> Compressed_section_map;
template<int size, bool big_endian>
Compressed_section_map*
build_compressed_section_map(const unsigned char* pshdrs, unsigned int shnum,
const char* names, section_size_type names_size,
Object* obj, bool decompress_if_needed);
// Object is an abstract base class which represents either a 32-bit
// or a 64-bit input object. This can be a regular object file
// (ET_REL) or a shared object (ET_DYN).
2006-08-05 01:10:59 +02:00
class Object
{
public:
typedef std::vector<Symbol*> Symbols;
2006-08-05 01:10:59 +02:00
// NAME is the name of the object as we would report it to the user
// (e.g., libfoo.a(bar.o) if this is in an archive. INPUT_FILE is
// used to read the file. OFFSET is the offset within the input
// file--0 for a .o or .so file, something else for a .a file.
Object(const std::string& name, Input_file* input_file, bool is_dynamic,
off_t offset = 0)
: name_(name), input_file_(input_file), offset_(offset), shnum_(-1U),
is_dynamic_(is_dynamic), is_needed_(false), uses_split_stack_(false),
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
has_no_split_stack_(false), no_export_(false),
Support compressed debug sections in dynamic object files. This patch adds support for reading compressed debug info in shared objects. It actually simplifies things, by moving the support for compressed sections all the way up to the top-level Object class, eliminating the need for several virtual methods. gold/ * dwp.cc (Sized_relobj_dwo::do_section_contents): Delete. (Sized_relobj_dwo::setup): Build compressed section map. (Sized_relobj_dwo::do_decompressed_section_contents): Delete. * dynobj.cc (Sized_dynobj::base_read_symbols): Build compressed section map. * object.cc (Sized_relobj_file::Sized_relobj_file): Remove compressed_sections_ field. (build_compressed_section_map): Take Object instead of Sized_relobj_file parameter; add decompress_if_needed parameter. (Sized_relobj_file::do_find_special_sections): Store compressed section map in parent Object. (Sized_relobj_file::do_decompressed_section_contents): Move implementation to Object::decompressed_section_contents. (Sized_relobj_file::do_discard_decompressed_sections): Move implementation to Object::discard_decompressed_sections. * object.h (build_compressed_section_map): Declare. (Object::Object): Add compressed_sections_ field. (Object::section_is_compressed): Move implementation here. (Object::decompressed_section_contents): De-virtualize. (Object::discard_decompressed_sections): De-virtualize. (Object::do_section_is_compressed): Delete. (Object::do_decompressed_section_contents): Delete. (Object::set_compressed_sections): New method. (Object::compressed_sections): New method. (Object::compressed_sections_): New data member. (Compressed_section_info, Compressed_section_map): Move to top of file. (Sized_relobj_file::do_section_is_compressed): Delete. (Sized_relobj_file::do_decompressed_section_contents): Delete. (Sized_relobj_file::do_discard_decompressed_sections): Delete. (Sized_relobj_file::compressed_sections_): Move to Object class.
2015-03-22 02:50:11 +01:00
is_in_system_directory_(false), as_needed_(false), xindex_(NULL),
compressed_sections_(NULL)
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{
if (input_file != NULL)
{
input_file->file().add_object();
this->is_in_system_directory_ = input_file->is_in_system_directory();
* dynobj.h (Dynobj::do_dynobj): New function. * incremental-dump.cc (dump_incremental_inputs): Print as_needed flag and soname for shared objects. * incremental.cc (Incremental_inputs::report_object): Make either Incremental_object_entry or Incremental_dynobj_entry; add soname to string table. (Incremental_inputs::report_input_section): Add assertion. (Output_section_incremental_inputs::set_final_data_size): Adjust type of input file entry for shared libraries; adjust size of shared library info entry. (Output_section_incremental_inputs::write_input_files): Write as_needed flag for shared libraries. (Output_section_incremental_inputs::write_info_blocks): Adjust type of input file entry for shared libraries; write soname. (Sized_incr_dynobj::Sized_incr_dynobj): Read as_needed flag and soname from incremental info. * incremental.h (enum Incremental_input_flags): Add INCREMENTAL_INPUT_AS_NEEDED. (Incremental_input_entry::Incremental_input_entry): Initialize new data member. (Incremental_input_entry::set_as_needed): New function. (Incremental_input_entry::as_needed): New function. (Incremental_input_entry::do_dynobj_entry): New function. (Incremental_input_entry::as_needed_): New data member. (Incremental_object_entry::Incremental_object_entry): Don't check for shared library. (Incremental_object_entry::do_type): Likewise. (class Incremental_dynobj_entry): New class. (Incremental_input_entry_reader::as_needed): New function. (Incremental_input_entry_reader::get_soname): New function. (Incremental_input_entry_reader::get_global_symbol_count): Rewrite. (Incremental_input_entry_reader::get_output_symbol_index): Adjust size of shared library info entry. * layout.cc (Layout::finish_dynamic_section): Don't test for incremental link when adding DT_NEEDED entries. * object.h (Object::Object): Initialize new data member. (Object::dynobj): New function. (Object::set_as_needed): New function. (Object::as_needed): New function. (Object::do_dynobj): New function. (Object::as_needed_): New data member.
2011-05-24 23:57:28 +02:00
this->as_needed_ = input_file->options().as_needed();
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
}
}
2006-08-05 01:10:59 +02:00
virtual ~Object()
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{
if (this->input_file_ != NULL)
this->input_file_->file().remove_object();
}
2006-08-05 01:10:59 +02:00
// Return the name of the object as we would report it to the user.
2006-08-05 01:10:59 +02:00
const std::string&
name() const
{ return this->name_; }
// Get the offset into the file.
off_t
offset() const
{ return this->offset_; }
// Return whether this is a dynamic object.
bool
is_dynamic() const
{ return this->is_dynamic_; }
Add SHF_COMPRESSED section decompression to gold This patch adds SHF_COMPRESSED section decompression to gold. PR gold/18321 * compressed_output.h (decompress_input_section): Add arguments for ELF class, big endian and sh_flags. * compressed_output.cc (decompress_input_section): Likewise. Support the SHF_COMPRESSED section. * dynobj.h (Dynobj): Add elfsize and is_big_endian member functions. * plugin.h (Pluginobj): Likewise. * layout.cc (Layout::get_output_section_flags): Also clear the SHF_COMPRESSED bit. * object.h (Compressed_section_info): Add flag to store sh_flags. (Object): Add pure virtual elfsize and is_big_endian member functions. * object.cc (need_decompressed_section): Don't skip the ".zdebug" prefix here. (build_compressed_section_map): Check SHF_COMPRESSED for uncompressed size. Store sh_flags in Compressed_section_info. Pass size, big_endian and sh_flags to decompress_input_section. Skip the ".debug"/".zdebug" prefix when passing section name to need_decompressed_section. (Sized_relobj_file<size, big_endian>::do_find_special_section): Don't check ".zdebug_*" sections. (Object::decompressed_section_contents): Pass ELF class, big endian and sh_flags to decompress_input_section. * reloc.cc (Sized_relobj_file<size, big_endian>::write_sections): Likewise. * testsuite/Makefile.am (check_DATA): Add debug_msg_cdebug_gabi.err and gdb_index_test_2_gabi.stdout. (MOSTLYCLEANFILES): Add debug_msg_cdebug_gabi.err and gdb_index_test_2_gabi.stdout. (debug_msg_cdebug_gabi.o): New. (odr_violation1_cdebug_gabi.o): Likewise. (odr_violation2_cdebug_gabi.o): Likewise. (debug_msg_cdebug_gabi.err): Likewise. (check_SCRIPTS): Add gdb_index_test_2_gabi.sh. (gdb_index_test_cdebug_gabi.o): Likewise. (gdb_index_test_2_gabi): Likewise. (gdb_index_test_2_gabi.stdout): Likewise. * testsuite/gdb_index_test_2_gabi.sh: New file. * testsuite/Makefile.in: Regenerated.
2015-07-12 19:50:25 +02:00
// Return the word size of the object file.
virtual int elfsize() const = 0;
// Return TRUE if this is a big-endian object file.
virtual bool is_big_endian() const = 0;
// Return whether this object is needed--true if it is a dynamic
// object which defines some symbol referenced by a regular object.
// We keep the flag here rather than in Dynobj for convenience when
// setting it.
bool
is_needed() const
{ return this->is_needed_; }
// Record that this object is needed.
void
set_is_needed()
{ this->is_needed_ = true; }
* options.h (class General_options): Define split_stack_adjust_size parameter. * object.h (class Object): Add uses_split_stack_ and has_no_split_stack_ fields. Add uses_split_stack and has_no_split_stack accessor functions. Declare handle_split_stack_section. (class Reloc_symbol_changes): Define. (class Sized_relobj): Define Function_offsets. Declare split_stack_adjust, split_stack_adjust_reltype, and find_functions. * object.cc (Object::handle_split_stack_section): New function. (Sized_relobj::do_layout): Call handle_split_stack_section. * dynobj.cc (Sized_dynobj::do_layout): Call handle_split_stack_section. * reloc.cc (Sized_relobj::relocate_sections): Call split_stack_adjust for executable sections in split_stack objects. Pass reloc_map to relocate_section. (Sized_relobj::split_stack_adjust): New function. (Sized_relobj::split_stack_adjust_reltype): New function. (Sized_relobj::find_functions): New function. * target-reloc.h: Include "object.h". (relocate_section): Add reloc_symbol_changes parameter. Change all callers. * target.h (class Target): Add calls_non_split method. Declare do_calls_non_split virtual method. Declare match_view and set_view_to_nop. * target.cc: Include "elfcpp.h". (Target::do_calls_non_split): New function. (Target::match_view): New function. (Target::set_view_to_nop): New function. * gold.cc (queue_middle_tasks): Give an error if mixing split-stack and non-split-stack objects with -r. * i386.cc (Target_i386::relocate_section): Add reloc_symbol_changes parameter. (Target_i386::do_calls_non_split): New function. * x86_64.cc (Target_x86_64::relocate_section): Add reloc_symbol_changes parameter. (Target_x86_64::do_calls_non_split): New function. * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes parameter. * powerpc.cc (Target_powerpc::relocate_section): Add reloc_symbol_changes parameter. * sparc.cc (Target_sparc::relocate_section): Add reloc_symbol_changes parameter. * configure.ac: Call AM_CONDITIONAL for the default target. * configure: Rebuild. * testsuite/Makefile.am (TEST_AS): New variable. (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh. (check_DATA): Add split_i386 and split_x86_64 files. (SPLIT_DEFSYMS): Define. (split_i386_[1234n].o): New targets. (split_i386_[124]): New targets. (split_i386_[1234r].stdout): New targets. (split_x86_64_[1234n].o): New targets. (split_x86_64_[124]): New targets. (split_x86_64_[1234r].stdout): New targets. (MOSTLYCLEANFILES): Add new executables. * testsuite/split_i386.sh: New file. * testsuite/split_x86_64.sh: New file. * testsuite/split_i386_1.s: New file. * testsuite/split_i386_2.s: New file. * testsuite/split_i386_3.s: New file. * testsuite/split_i386_4.s: New file. * testsuite/split_i386_n.s: New file. * testsuite/split_x86_64_1.s: New file. * testsuite/split_x86_64_2.s: New file. * testsuite/split_x86_64_3.s: New file. * testsuite/split_x86_64_4.s: New file. * testsuite/split_x86_64_n.s: New file. * testsuite/testfile.cc (Target_test): Update relocation_section function. * testsuite/Makefile.in: Rebuild.
2009-10-07 00:58:27 +02:00
// Return whether this object was compiled with -fsplit-stack.
bool
uses_split_stack() const
{ return this->uses_split_stack_; }
// Return whether this object contains any functions compiled with
// the no_split_stack attribute.
bool
has_no_split_stack() const
{ return this->has_no_split_stack_; }
* dynobj.h (Dynobj::do_dynobj): New function. * incremental-dump.cc (dump_incremental_inputs): Print as_needed flag and soname for shared objects. * incremental.cc (Incremental_inputs::report_object): Make either Incremental_object_entry or Incremental_dynobj_entry; add soname to string table. (Incremental_inputs::report_input_section): Add assertion. (Output_section_incremental_inputs::set_final_data_size): Adjust type of input file entry for shared libraries; adjust size of shared library info entry. (Output_section_incremental_inputs::write_input_files): Write as_needed flag for shared libraries. (Output_section_incremental_inputs::write_info_blocks): Adjust type of input file entry for shared libraries; write soname. (Sized_incr_dynobj::Sized_incr_dynobj): Read as_needed flag and soname from incremental info. * incremental.h (enum Incremental_input_flags): Add INCREMENTAL_INPUT_AS_NEEDED. (Incremental_input_entry::Incremental_input_entry): Initialize new data member. (Incremental_input_entry::set_as_needed): New function. (Incremental_input_entry::as_needed): New function. (Incremental_input_entry::do_dynobj_entry): New function. (Incremental_input_entry::as_needed_): New data member. (Incremental_object_entry::Incremental_object_entry): Don't check for shared library. (Incremental_object_entry::do_type): Likewise. (class Incremental_dynobj_entry): New class. (Incremental_input_entry_reader::as_needed): New function. (Incremental_input_entry_reader::get_soname): New function. (Incremental_input_entry_reader::get_global_symbol_count): Rewrite. (Incremental_input_entry_reader::get_output_symbol_index): Adjust size of shared library info entry. * layout.cc (Layout::finish_dynamic_section): Don't test for incremental link when adding DT_NEEDED entries. * object.h (Object::Object): Initialize new data member. (Object::dynobj): New function. (Object::set_as_needed): New function. (Object::as_needed): New function. (Object::do_dynobj): New function. (Object::as_needed_): New data member.
2011-05-24 23:57:28 +02:00
// Returns NULL for Objects that are not dynamic objects. This method
// is overridden in the Dynobj class.
Dynobj*
dynobj()
{ return this->do_dynobj(); }
Add plugin functionality for link-time optimization (LTO). include/: * plugin-api.h: New file. gold/: * configure.ac (plugins): Add --enable-plugins option. * configure: Regenerate. * config.in: Regenerate. * Makefile.am (LIBDL): New variable. (CCFILES): Add plugin.cc. (HFILES): Add plugin.h. (ldadd_var): Add LIBDL. * Makefile.in: Regenerate. * archive.cc: Include "plugin.h". (Archive::setup): Don't preread archive symbols when using a plugin. (Archive::get_file_and_offset): Add memsize parameter. Change callers. (Archive::get_elf_object_for_member): Call plugin hooks for claiming files. (Archive::include_member): Add symbols from plugin objects. * archive.h (Archive::get_file_and_offset): Add memsize parameter. * descriptors.cc (Descriptors::open): Check for file descriptors abandoned by plugins. (Descriptors::claim_for_plugin): New function. * descriptors.h (Descriptors::claim_for_plugin): New function. (Open_descriptor::is_claimed): New field. (claim_descriptor_for_plugin): New function. * fileread.cc (File_read::claim_for_plugin): New function. * fileread.h (File_read::claim_for_plugin): New function. (File_read::descriptor): New function. * gold.cc: Include "plugin.h". (queue_initial_tasks): Add task to call plugin hooks for generating new object files. * main.cc: Include "plugin.h". (main): Load plugin libraries. * object.h (Pluginobj): Declare. (Object::pluginobj): New function. (Object::do_pluginobj): New function. (Object::set_target): New function. * options.cc: Include "plugin.h". (General_options::parse_plugin): New function. (General_options::General_options): Initialize plugins_ field. (General_options::add_plugin): New function. * options.h (Plugin_manager): Declare. (General_options): Add --plugin option. (General_options::has_plugins): New function. (General_options::plugins): New function. (General_options::add_plugin): New function. (General_options::plugins_): New field. * plugin.cc: New file. * plugin.h: New file. * readsyms.cc: Include "plugin.h". (Read_symbols::do_read_symbols): Check for archive before checking for ELF file. Call plugin hooks to claim files. * resolve.cc (Symbol_table::resolve): Record when symbol is referenced from a real object file; force override when processing replacement files. * symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field. (Symbol::init_base_object): Likewise. (Symbol::init_base_output_data): Likewise. (Symbol::init_base_output_segment): Likewise. (Symbol::init_base_constant): Likewise. (Symbol::init_base_undefined): Likewise. (Symbol::output_section): Assert that object is not a plugin. (Symbol_table::add_from_pluginobj): New function. (Symbol_table::sized_finalize_symbol): Treat symbols from plugins as undefined. (Symbol_table::sized_write_globals): Likewise. (Symbol_table::add_from_pluginobj): Instantiate template. * symtab.h (Sized_pluginobj): Declare. (Symbol::in_real_elf): New function. (Symbol::set_in_real_elf): New function. (Symbol::in_real_elf_): New field. (Symbol_table::add_from_pluginobj): New function. * testsuite/Makefile.am (AM_CFLAGS): New variable. (LIBDL): New variable. (LDADD): Add LIBDL. (check_PROGRAMS): Add plugin_test_1 and plugin_test_2. (check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh. (check_DATA): Add plugin_test_1.err and plugin_test_2.err. (MOSTLYCLEANFILES): Likewise. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c: New file. * testsuite/plugin_test_1.sh: New file. * testsuite/plugin_test_2.sh: New file.
2008-09-20 00:54:57 +02:00
// Returns NULL for Objects that are not plugin objects. This method
// is overridden in the Pluginobj class.
Pluginobj*
pluginobj()
{ return this->do_pluginobj(); }
* readsyms.cc (Read_symbols::incompatible_warning): New function. (Read_symbols::requeue): New function. (Read_symbols::do_read_symbols): If make_elf_object fails because the target type is not configured, and the file was searched for, issue a warning and retry with the next directory. (Add_symbols::run): If the file has an incompatible format, and it was searched for, requeue the Read_symbols task. On error, release the object. * readsyms.h (class Read_symbols): Add dirindex_ field. Add dirindex parameter to constructor. Change all callers. Declare incompatible_warning and requeue. (class Add_symbols): Add dirpath_, dirindex_, mapfile_, input_argument_ and input_group_ fields. Add them to constructor. Change all callers. (class Read_script): Add dirindex_ field. Add it to constructor. Change all callers. * archive.cc (Archive::setup): Remove input_objects parameter. Change all callers. (Archive::get_file_and_offset): Likewise. (Archive::read_all_symbols): Likewise. (Archive::read_symbols): Likewise. (Archive::get_elf_object_for_member): Remove input_objects parameter. Add punconfigured parameter. Change all callers. (Archive::add_symbols): Change return type to bool. Check return value of include_member. (Archive::include_all_members): Likewise. (Archive::include_member): Change return type to bool. Return false if first included object has incompatible target. Set included_member_ field. (Add_archive_symbols::run): If add_symbols returns false, requeue Read_symbols task. * archive.h (class Archive): Add included_member_ field. Initialize it in constructor. Add input_file and searched_for methods. Update declarations. (class Add_archive_symbols): Add dirpath_, dirindex_, and input_argument_ fields. Add them to constructor. Change all callers. * script.cc: Include "target-select.h". (class Parser_closure): Add skip_on_incompatible_target_ and found_incompatible_target_ fields. Add skip_on_incompatible_target parameter to constructor. Change all callers. Add methods skip_on_incompatible_target, clear_skip_on_incompatible_target, found_incompatible_target, and set_found_incompatible_target. (read_input_script): Add dirindex parameter. Change all callers. If parser finds an incompatible target, requeue Read_symbols task. (script_set_symbol): Clear skip_on_incompatible_target in closure. (script_add_assertion, script_parse_option): Likewise. (script_start_sections, script_add_phdr): Likewise. (script_check_output_format): New function. * script.h (read_input_script): Update declaration. * script-c.h (script_check_output_format): Declare. * yyscript.y (file_cmd): Handle OUTPUT_FORMAT. (ignore_cmd): Remove OUTPUT_FORMAT. * fileread.cc (Input_file::Input_file): Add explicit this. (Input_file::will_search_for): New function. (Input_file::open): Add pindex parameter. Change all callers. * fileread.h (class Input_file): Add input_file_argument method. Declare will_search_for. Update declarations. * object.cc (make_elf_object): Add punconfigured parameter. Change all callers. * object.h (class Object): Make input_file public. Add searched_for method. (make_elf_object): Update declaration. * dirsearch.cc (Dirsearch::find): Add pindex parameter. Use it to restart search. * dirsearch.h (class Dirsearch): Update declaration. * options.h (class General_options): Add --warn-search-mismatch. * parameters.cc (Parameters::is_compatible_target): New function. * parameters.h (class Parameters): Declare is_compatible_target. * workqueue.cc (Workqueue::add_blocker): New function. * workqueue.h (class Workqueue): Declare add_blocker.
2009-03-14 06:56:46 +01:00
// Get the file. We pass on const-ness.
Input_file*
input_file()
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{
gold_assert(this->input_file_ != NULL);
return this->input_file_;
}
* readsyms.cc (Read_symbols::incompatible_warning): New function. (Read_symbols::requeue): New function. (Read_symbols::do_read_symbols): If make_elf_object fails because the target type is not configured, and the file was searched for, issue a warning and retry with the next directory. (Add_symbols::run): If the file has an incompatible format, and it was searched for, requeue the Read_symbols task. On error, release the object. * readsyms.h (class Read_symbols): Add dirindex_ field. Add dirindex parameter to constructor. Change all callers. Declare incompatible_warning and requeue. (class Add_symbols): Add dirpath_, dirindex_, mapfile_, input_argument_ and input_group_ fields. Add them to constructor. Change all callers. (class Read_script): Add dirindex_ field. Add it to constructor. Change all callers. * archive.cc (Archive::setup): Remove input_objects parameter. Change all callers. (Archive::get_file_and_offset): Likewise. (Archive::read_all_symbols): Likewise. (Archive::read_symbols): Likewise. (Archive::get_elf_object_for_member): Remove input_objects parameter. Add punconfigured parameter. Change all callers. (Archive::add_symbols): Change return type to bool. Check return value of include_member. (Archive::include_all_members): Likewise. (Archive::include_member): Change return type to bool. Return false if first included object has incompatible target. Set included_member_ field. (Add_archive_symbols::run): If add_symbols returns false, requeue Read_symbols task. * archive.h (class Archive): Add included_member_ field. Initialize it in constructor. Add input_file and searched_for methods. Update declarations. (class Add_archive_symbols): Add dirpath_, dirindex_, and input_argument_ fields. Add them to constructor. Change all callers. * script.cc: Include "target-select.h". (class Parser_closure): Add skip_on_incompatible_target_ and found_incompatible_target_ fields. Add skip_on_incompatible_target parameter to constructor. Change all callers. Add methods skip_on_incompatible_target, clear_skip_on_incompatible_target, found_incompatible_target, and set_found_incompatible_target. (read_input_script): Add dirindex parameter. Change all callers. If parser finds an incompatible target, requeue Read_symbols task. (script_set_symbol): Clear skip_on_incompatible_target in closure. (script_add_assertion, script_parse_option): Likewise. (script_start_sections, script_add_phdr): Likewise. (script_check_output_format): New function. * script.h (read_input_script): Update declaration. * script-c.h (script_check_output_format): Declare. * yyscript.y (file_cmd): Handle OUTPUT_FORMAT. (ignore_cmd): Remove OUTPUT_FORMAT. * fileread.cc (Input_file::Input_file): Add explicit this. (Input_file::will_search_for): New function. (Input_file::open): Add pindex parameter. Change all callers. * fileread.h (class Input_file): Add input_file_argument method. Declare will_search_for. Update declarations. * object.cc (make_elf_object): Add punconfigured parameter. Change all callers. * object.h (class Object): Make input_file public. Add searched_for method. (make_elf_object): Update declaration. * dirsearch.cc (Dirsearch::find): Add pindex parameter. Use it to restart search. * dirsearch.h (class Dirsearch): Update declaration. * options.h (class General_options): Add --warn-search-mismatch. * parameters.cc (Parameters::is_compatible_target): New function. * parameters.h (class Parameters): Declare is_compatible_target. * workqueue.cc (Workqueue::add_blocker): New function. * workqueue.h (class Workqueue): Declare add_blocker.
2009-03-14 06:56:46 +01:00
const Input_file*
input_file() const
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{
gold_assert(this->input_file_ != NULL);
return this->input_file_;
}
* readsyms.cc (Read_symbols::incompatible_warning): New function. (Read_symbols::requeue): New function. (Read_symbols::do_read_symbols): If make_elf_object fails because the target type is not configured, and the file was searched for, issue a warning and retry with the next directory. (Add_symbols::run): If the file has an incompatible format, and it was searched for, requeue the Read_symbols task. On error, release the object. * readsyms.h (class Read_symbols): Add dirindex_ field. Add dirindex parameter to constructor. Change all callers. Declare incompatible_warning and requeue. (class Add_symbols): Add dirpath_, dirindex_, mapfile_, input_argument_ and input_group_ fields. Add them to constructor. Change all callers. (class Read_script): Add dirindex_ field. Add it to constructor. Change all callers. * archive.cc (Archive::setup): Remove input_objects parameter. Change all callers. (Archive::get_file_and_offset): Likewise. (Archive::read_all_symbols): Likewise. (Archive::read_symbols): Likewise. (Archive::get_elf_object_for_member): Remove input_objects parameter. Add punconfigured parameter. Change all callers. (Archive::add_symbols): Change return type to bool. Check return value of include_member. (Archive::include_all_members): Likewise. (Archive::include_member): Change return type to bool. Return false if first included object has incompatible target. Set included_member_ field. (Add_archive_symbols::run): If add_symbols returns false, requeue Read_symbols task. * archive.h (class Archive): Add included_member_ field. Initialize it in constructor. Add input_file and searched_for methods. Update declarations. (class Add_archive_symbols): Add dirpath_, dirindex_, and input_argument_ fields. Add them to constructor. Change all callers. * script.cc: Include "target-select.h". (class Parser_closure): Add skip_on_incompatible_target_ and found_incompatible_target_ fields. Add skip_on_incompatible_target parameter to constructor. Change all callers. Add methods skip_on_incompatible_target, clear_skip_on_incompatible_target, found_incompatible_target, and set_found_incompatible_target. (read_input_script): Add dirindex parameter. Change all callers. If parser finds an incompatible target, requeue Read_symbols task. (script_set_symbol): Clear skip_on_incompatible_target in closure. (script_add_assertion, script_parse_option): Likewise. (script_start_sections, script_add_phdr): Likewise. (script_check_output_format): New function. * script.h (read_input_script): Update declaration. * script-c.h (script_check_output_format): Declare. * yyscript.y (file_cmd): Handle OUTPUT_FORMAT. (ignore_cmd): Remove OUTPUT_FORMAT. * fileread.cc (Input_file::Input_file): Add explicit this. (Input_file::will_search_for): New function. (Input_file::open): Add pindex parameter. Change all callers. * fileread.h (class Input_file): Add input_file_argument method. Declare will_search_for. Update declarations. * object.cc (make_elf_object): Add punconfigured parameter. Change all callers. * object.h (class Object): Make input_file public. Add searched_for method. (make_elf_object): Update declaration. * dirsearch.cc (Dirsearch::find): Add pindex parameter. Use it to restart search. * dirsearch.h (class Dirsearch): Update declaration. * options.h (class General_options): Add --warn-search-mismatch. * parameters.cc (Parameters::is_compatible_target): New function. * parameters.h (class Parameters): Declare is_compatible_target. * workqueue.cc (Workqueue::add_blocker): New function. * workqueue.h (class Workqueue): Declare add_blocker.
2009-03-14 06:56:46 +01:00
// Lock the underlying file.
void
lock(const Task* t)
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{
if (this->input_file_ != NULL)
this->input_file_->file().lock(t);
}
// Unlock the underlying file.
void
unlock(const Task* t)
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{
if (this->input_file_ != NULL)
this->input_file()->file().unlock(t);
}
// Return whether the underlying file is locked.
bool
is_locked() const
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{ return this->input_file_ != NULL && this->input_file_->file().is_locked(); }
// Return the token, so that the task can be queued.
Task_token*
token()
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{
if (this->input_file_ == NULL)
return NULL;
return this->input_file()->file().token();
}
// Release the underlying file.
void
release()
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{
if (this->input_file_ != NULL)
this->input_file()->file().release();
}
// Return whether we should just read symbols from this file.
bool
just_symbols() const
{ return this->input_file()->just_symbols(); }
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
// Return whether this is an incremental object.
bool
is_incremental() const
{ return this->do_is_incremental(); }
// Return the last modified time of the file.
Timespec
get_mtime()
{ return this->do_get_mtime(); }
// Get the number of sections.
unsigned int
shnum() const
{ return this->shnum_; }
// Return a view of the contents of a section. Set *PLEN to the
// size. CACHE is a hint as in File_read::get_view.
const unsigned char*
section_contents(unsigned int shndx, section_size_type* plen, bool cache);
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
// Adjust a symbol's section index as needed. SYMNDX is the index
// of the symbol and SHNDX is the symbol's section from
// get_st_shndx. This returns the section index. It sets
// *IS_ORDINARY to indicate whether this is a normal section index,
// rather than a special code between SHN_LORESERVE and
// SHN_HIRESERVE.
unsigned int
adjust_sym_shndx(unsigned int symndx, unsigned int shndx, bool* is_ordinary)
{
if (shndx < elfcpp::SHN_LORESERVE)
*is_ordinary = true;
else if (shndx == elfcpp::SHN_XINDEX)
{
if (this->xindex_ == NULL)
this->xindex_ = this->do_initialize_xindex();
shndx = this->xindex_->sym_xindex_to_shndx(this, symndx);
*is_ordinary = true;
}
else
*is_ordinary = false;
return shndx;
}
2008-02-04 06:43:05 +01:00
// Return the size of a section given a section index.
uint64_t
section_size(unsigned int shndx)
{ return this->do_section_size(shndx); }
// Return the name of a section given a section index.
std::string
section_name(unsigned int shndx) const
{ return this->do_section_name(shndx); }
// Return the section flags given a section index.
uint64_t
section_flags(unsigned int shndx)
{ return this->do_section_flags(shndx); }
2009-08-05 22:51:56 +02:00
// Return the section entsize given a section index.
uint64_t
section_entsize(unsigned int shndx)
{ return this->do_section_entsize(shndx); }
// Return the section address given a section index.
uint64_t
section_address(unsigned int shndx)
{ return this->do_section_address(shndx); }
// Return the section type given a section index.
unsigned int
section_type(unsigned int shndx)
{ return this->do_section_type(shndx); }
// Return the section link field given a section index.
unsigned int
section_link(unsigned int shndx)
{ return this->do_section_link(shndx); }
// Return the section info field given a section index.
unsigned int
section_info(unsigned int shndx)
{ return this->do_section_info(shndx); }
2008-02-04 06:43:05 +01:00
// Return the required section alignment given a section index.
uint64_t
section_addralign(unsigned int shndx)
{ return this->do_section_addralign(shndx); }
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Return the output section given a section index.
Output_section*
output_section(unsigned int shndx) const
{ return this->do_output_section(shndx); }
// Given a section index, return its address.
// The return value will be -1U if the section is specially mapped,
// such as a merge section.
uint64_t
output_section_address(unsigned int shndx)
{ return this->do_output_section_address(shndx); }
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Given a section index, return the offset in the Output_section.
// The return value will be -1U if the section is specially mapped,
// such as a merge section.
uint64_t
output_section_offset(unsigned int shndx) const
{ return this->do_output_section_offset(shndx); }
// Read the symbol information.
void
read_symbols(Read_symbols_data* sd)
{ return this->do_read_symbols(sd); }
// Pass sections which should be included in the link to the Layout
// object, and record where the sections go in the output file.
void
layout(Symbol_table* symtab, Layout* layout, Read_symbols_data* sd)
{ this->do_layout(symtab, layout, sd); }
// Add symbol information to the global symbol table.
void
add_symbols(Symbol_table* symtab, Read_symbols_data* sd, Layout *layout)
{ this->do_add_symbols(symtab, sd, layout); }
2010-03-22 Rafael Espindola <espindola@google.com> * archive.cc (Should_include): Move to archive.h. (should_include_member): Make it a member of Archive. (Lib_group): New. (Add_lib_group_symbols): New. * archive.h: Include options.h. (Archive_member): Moved from Archive. (Should_include): Moved from archive.cc. (Lib_group): New. (Add_lib_group_symbols): New. * dynobj.cc (do_should_include_member): New. * dynobj.h (do_should_include_member): New. * gold.cc (queue_initial_tasks): Update call to queue. * main.cc (main): Print lib group stats. * object.cc (do_should_include_member): New. * object.h: Include archive.h. (Object::should_include_member): New. (Object::do_should_include_member): New. (Sized_relobj::do_should_include_member): New. * options.cc (General_options::parse_start_lib): New. (General_options::parse_end_lib): New. (Input_arguments::add_file): Handle lib groups. (Input_arguments::start_group): Check we are not in a lib. (Input_arguments::start_lib): New. (Input_arguments::end_lib): New. * options.h (General_options): Add start_lib and end_lib. (Input_argument::lib_): New. (Input_argument::lib): New. (Input_argument::is_lib): New. (Input_file_lib): New. (Input_arguments::in_lib_): New. (Input_arguments::in_lib): New. (Input_arguments::start_lib): New. (Input_arguments::end_lib_): New. * plugin.cc (Pluginobj::get_symbol_resolution_info): Mark symbols in unused members as preempted. (Sized_pluginobj::do_should_include_member): New. * plugin.h (Sized_pluginobj::do_should_include_member): New. * readsyms.cc (Read_symbols::locks): If we are just reading a member, return the blocker. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::do_read_symbols): Handle lib groups. (Read_symbols::get_name): Handle lib groups. * readsyms.h (Read_symbols): Add an archive member pointer. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::member_): New. * script.cc (read_input_script): Update call to queue_soon.
2010-03-22 15:18:24 +01:00
// Add symbol information to the global symbol table.
Archive::Should_include
PR 11855 * script.cc (Script_options::Script_options): Initialize symbol_definitions_ and symbol_references_. (Script_options::add_symbol_assignment): Update symbol_definitions_ and symbol_references_. (Script_options::add_symbol_reference): New function. (script_symbol): New function. * script.h (class Script_options): Add symbol_definitions_ and symbol_references_ fields. (Script_options::referenced_const_iterator): New type. (Script_options::referenced_begin): New function. (Script_options::referenced_end): New function. (Script_options::is_referenced): New function. (Script_options::any_unreferenced): New function. * script-c.h (script_symbol): Declare. * yyscript.y (exp): Call script_symbol. * symtab.cc: Include "script.h". (Symbol_table::gc_mark_undef_symbols): Add layout parameter. Change all callers. Check symbols referenced by scripts. (Symbol_table::add_undefined_symbols_from_command_line): Add layout parameter. Change all callers. (Symbol_table::do_add_undefined_symbols_from_command_line): Likewise. Break out loop body. Check symbols referenced by scripts. (Symbol_table::add_undefined_symbol_from_command_line): New function broken out of do_add_undefined_symbols_from_command_line. * symtab.h (class Symbol_table): Update declarations. * archive.cc: Include "layout.h". (Archive::should_include_member): Add layout parameter. Change all callers. Check for symbol mentioned in expression. * archive.h (class Archive): Update declaration. * object.cc (Sized_relobj::do_should_include_member): Add layout parameter. * object.h (Object::should_include_member): Add layout parameter. Change all callers. (Object::do_should_include_member): Add layout parameter. (class Sized_relobj): Update declaration. * dynobj.cc (Sized_dynobj::do_should_include_member): Add layout parameter. * dynobj.h (class Sized_dynobj): Update declaration. * plugin.cc (Sized_pluginobj::do_should_include_member): Add layout parameter. * plugin.h (class Sized_pluginobj): Update declaration.
2010-08-02 15:34:33 +02:00
should_include_member(Symbol_table* symtab, Layout* layout,
Read_symbols_data* sd, std::string* why)
{ return this->do_should_include_member(symtab, layout, sd, why); }
2010-03-22 Rafael Espindola <espindola@google.com> * archive.cc (Should_include): Move to archive.h. (should_include_member): Make it a member of Archive. (Lib_group): New. (Add_lib_group_symbols): New. * archive.h: Include options.h. (Archive_member): Moved from Archive. (Should_include): Moved from archive.cc. (Lib_group): New. (Add_lib_group_symbols): New. * dynobj.cc (do_should_include_member): New. * dynobj.h (do_should_include_member): New. * gold.cc (queue_initial_tasks): Update call to queue. * main.cc (main): Print lib group stats. * object.cc (do_should_include_member): New. * object.h: Include archive.h. (Object::should_include_member): New. (Object::do_should_include_member): New. (Sized_relobj::do_should_include_member): New. * options.cc (General_options::parse_start_lib): New. (General_options::parse_end_lib): New. (Input_arguments::add_file): Handle lib groups. (Input_arguments::start_group): Check we are not in a lib. (Input_arguments::start_lib): New. (Input_arguments::end_lib): New. * options.h (General_options): Add start_lib and end_lib. (Input_argument::lib_): New. (Input_argument::lib): New. (Input_argument::is_lib): New. (Input_file_lib): New. (Input_arguments::in_lib_): New. (Input_arguments::in_lib): New. (Input_arguments::start_lib): New. (Input_arguments::end_lib_): New. * plugin.cc (Pluginobj::get_symbol_resolution_info): Mark symbols in unused members as preempted. (Sized_pluginobj::do_should_include_member): New. * plugin.h (Sized_pluginobj::do_should_include_member): New. * readsyms.cc (Read_symbols::locks): If we are just reading a member, return the blocker. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::do_read_symbols): Handle lib groups. (Read_symbols::get_name): Handle lib groups. * readsyms.h (Read_symbols): Add an archive member pointer. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::member_): New. * script.cc (read_input_script): Update call to queue_soon.
2010-03-22 15:18:24 +01:00
* archive.cc (Library_base::should_include_member): Move method here from class Archive. (Archive::Archive): Initialize base class. (Archive::should_include_member): Move to base class. (Archive::do_for_all_unused_symbols): New function. (Add_archive_symbols::run): Remove redundant access to incremental_inputs. (Lib_group::Lib_group): Initialize base class. (Lib_group::do_filename): New function. (Lib_group::include_member): Pass pointer to Lib_group to report_object. (Lib_group::do_for_all_unused_symbols): New function. (Add_lib_group_symbols::run): Report archive information for incremental links. * archive.h (class Library_base): New base class. (class Archive): Derive from Library_base. (Archive::filename): Move to base class. (Archive::set_incremental_info): Likewise. (Archive::incremental_info): Likewise. (Archive::Should_include): Likewise. (Archive::should_include_member): Likewise. (Archive::Armap_entry): Remove. (Archive::Unused_symbol_iterator): Remove. (Archive::unused_symbols_begin): Remove. (Archive::unused_symbols_end): Remove. (Archive::do_filename): New function. (Archive::do_get_mtime): New function. (Archive::do_for_all_unused_symbols): New function. (Archive::task_): Move to base class. (Archive::incremental_info_): Likewise. (class Lib_group): Derive from Library_base. (Lib_group::do_filename): New function. (Lib_group::do_get_mtime): New function. (Lib_group::do_for_all_unused_symbols): New function. (Lib_group::task_): Move to base class. * dynobj.cc (Sized_dynobj::do_for_all_global_symbols): New function. * dynobj.h (Sized_dynobj::do_for_all_global_symbols): New function. * incremental.cc (Incremental_inputs::report_archive_begin): Use Library_base; call library's get_mtime; add incremental inputs entry before members. (class Unused_symbol_visitor): New class. (Incremental_inputs::report_archive_end): Use Library_base; use visitor class to record unused symbols; don't add incremental inputs entry after members. (Incremental_inputs::report_object): Use Library_base. * incremental.h (Incremental_archive_entry::Incremental_archive_entry): Remove unused Archive parameter. (Incremental_inputs::report_archive_begin): Use Library_base. (Incremental_inputs::report_archive_end): Likewise. (Incremental_inputs::report_object): Likewise. * object.cc (Sized_relobj::do_for_all_global_symbols): New function. * object.h (Object::for_all_global_symbols): New function. (Object::do_for_all_global_symbols): New function. (Sized_relobj::do_for_all_global_symbols): New function. * plugin.cc (Sized_pluginobj::do_for_all_global_symbols): New function. * plugin.h (Sized_pluginobj::do_for_all_global_symbols): New function.
2011-03-30 03:31:57 +02:00
// Iterate over global symbols, calling a visitor class V for each.
void
for_all_global_symbols(Read_symbols_data* sd,
Library_base::Symbol_visitor_base* v)
{ return this->do_for_all_global_symbols(sd, v); }
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
// Iterate over local symbols, calling a visitor class V for each GOT offset
// associated with a local symbol.
void
for_all_local_got_entries(Got_offset_list::Visitor* v) const
{ this->do_for_all_local_got_entries(v); }
// Functions and types for the elfcpp::Elf_file interface. This
// permit us to use Object as the File template parameter for
// elfcpp::Elf_file.
// The View class is returned by view. It must support a single
// method, data(). This is trivial, because get_view does what we
// need.
class View
{
public:
View(const unsigned char* p)
: p_(p)
{ }
const unsigned char*
data() const
{ return this->p_; }
private:
const unsigned char* p_;
};
// Return a View.
View
view(off_t file_offset, section_size_type data_size)
{ return View(this->get_view(file_offset, data_size, true, true)); }
// Report an error.
void
error(const char* format, ...) const ATTRIBUTE_PRINTF_2;
// A location in the file.
struct Location
{
off_t file_offset;
off_t data_size;
Location(off_t fo, section_size_type ds)
: file_offset(fo), data_size(ds)
{ }
};
// Get a View given a Location.
View view(Location loc)
{ return View(this->get_view(loc.file_offset, loc.data_size, true, true)); }
// Get a view into the underlying file.
const unsigned char*
get_view(off_t start, section_size_type size, bool aligned, bool cache)
{
return this->input_file()->file().get_view(this->offset_, start, size,
aligned, cache);
}
// Get a lasting view into the underlying file.
File_view*
get_lasting_view(off_t start, section_size_type size, bool aligned,
bool cache)
{
return this->input_file()->file().get_lasting_view(this->offset_, start,
size, aligned, cache);
}
// Read data from the underlying file.
void
read(off_t start, section_size_type size, void* p)
{ this->input_file()->file().read(start + this->offset_, size, p); }
// Read multiple data from the underlying file.
void
read_multiple(const File_read::Read_multiple& rm)
{ this->input_file()->file().read_multiple(this->offset_, rm); }
// Stop caching views in the underlying file.
void
clear_view_cache_marks()
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{
if (this->input_file_ != NULL)
this->input_file_->file().clear_view_cache_marks();
}
* cref.cc: New file. * cref.h: New file. * options.h (class General_options): Add --print-symbol-counts. * main.cc (main): Issue defined symbol report if requested. * archive.cc (Archive::interpret_header): Make into a const member function. (Archive::add_symbols): Call Input_objects::archive_start and archive_stop. (Archive::const_iterator): Define new class. (Archive::begin, Archive::end): New functions. (Archive::include_all_members): Rewrite to use iterator. (Archive::count_members): New function. * archive.h (class Archive): Update declarations. (Archive::filename): New function. * object.cc: Include "cref.h". (Sized_relobj::Sized_relobj): Initialize defined_count_. (Sized_relobj::do_get_global_symbol_counts): New function. (Input_objects::add_object): Add object to cross-referencer. (Input_objects::archive_start): New function. (Input_objects::archive_stop): New function. (Input_objects::print_symbol_counts): New function. * object.h: Declare Cref and Archive. (Object::get_global_symbol_counts): New function. (Object::do_get_global_symbol_counts): New pure virtual function. (class Sized_relobj): Add defined_count_ field. Update declarations. (class Input_objects): Add cref_ field. Update constructor. Update declarations. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and defined_count_. (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing symbol counts. (Sized_dynobj::do_get_global_symbol_counts): New function. * dynobj.h (class Sized_dynobj): Add fields symbols_ and defined_count_. Update declarations. Define Symbols typedef. * symtab.cc (Symbol_table::add_from_relobj): Add defined parameter. Change all callers. (Symbol_table::add_from_dynobj): Add sympointers and defined parameters. Change all callers. * symtab.h (class Symbol_table): Update declarations. * Makefile.am (CCFILES): Add cref.cc. (HFILES): Add cref.h. * Makefile.in: Rebuild.
2008-07-23 00:08:43 +02:00
// Get the number of global symbols defined by this object, and the
// number of the symbols whose final definition came from this
// object.
void
get_global_symbol_counts(const Symbol_table* symtab, size_t* defined,
size_t* used) const
{ this->do_get_global_symbol_counts(symtab, defined, used); }
// Get the symbols defined in this object.
const Symbols*
get_global_symbols() const
{ return this->do_get_global_symbols(); }
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
// Set flag that this object was found in a system directory.
void
set_is_in_system_directory()
{ this->is_in_system_directory_ = true; }
// Return whether this object was found in a system directory.
bool
is_in_system_directory() const
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{ return this->is_in_system_directory_; }
* dynobj.h (Dynobj::do_dynobj): New function. * incremental-dump.cc (dump_incremental_inputs): Print as_needed flag and soname for shared objects. * incremental.cc (Incremental_inputs::report_object): Make either Incremental_object_entry or Incremental_dynobj_entry; add soname to string table. (Incremental_inputs::report_input_section): Add assertion. (Output_section_incremental_inputs::set_final_data_size): Adjust type of input file entry for shared libraries; adjust size of shared library info entry. (Output_section_incremental_inputs::write_input_files): Write as_needed flag for shared libraries. (Output_section_incremental_inputs::write_info_blocks): Adjust type of input file entry for shared libraries; write soname. (Sized_incr_dynobj::Sized_incr_dynobj): Read as_needed flag and soname from incremental info. * incremental.h (enum Incremental_input_flags): Add INCREMENTAL_INPUT_AS_NEEDED. (Incremental_input_entry::Incremental_input_entry): Initialize new data member. (Incremental_input_entry::set_as_needed): New function. (Incremental_input_entry::as_needed): New function. (Incremental_input_entry::do_dynobj_entry): New function. (Incremental_input_entry::as_needed_): New data member. (Incremental_object_entry::Incremental_object_entry): Don't check for shared library. (Incremental_object_entry::do_type): Likewise. (class Incremental_dynobj_entry): New class. (Incremental_input_entry_reader::as_needed): New function. (Incremental_input_entry_reader::get_soname): New function. (Incremental_input_entry_reader::get_global_symbol_count): Rewrite. (Incremental_input_entry_reader::get_output_symbol_index): Adjust size of shared library info entry. * layout.cc (Layout::finish_dynamic_section): Don't test for incremental link when adding DT_NEEDED entries. * object.h (Object::Object): Initialize new data member. (Object::dynobj): New function. (Object::set_as_needed): New function. (Object::as_needed): New function. (Object::do_dynobj): New function. (Object::as_needed_): New data member.
2011-05-24 23:57:28 +02:00
// Set flag that this object was linked with --as-needed.
void
set_as_needed()
{ this->as_needed_ = true; }
// Clear flag that this object was linked with --as-needed.
void
clear_as_needed()
{ this->as_needed_ = false; }
* dynobj.h (Dynobj::do_dynobj): New function. * incremental-dump.cc (dump_incremental_inputs): Print as_needed flag and soname for shared objects. * incremental.cc (Incremental_inputs::report_object): Make either Incremental_object_entry or Incremental_dynobj_entry; add soname to string table. (Incremental_inputs::report_input_section): Add assertion. (Output_section_incremental_inputs::set_final_data_size): Adjust type of input file entry for shared libraries; adjust size of shared library info entry. (Output_section_incremental_inputs::write_input_files): Write as_needed flag for shared libraries. (Output_section_incremental_inputs::write_info_blocks): Adjust type of input file entry for shared libraries; write soname. (Sized_incr_dynobj::Sized_incr_dynobj): Read as_needed flag and soname from incremental info. * incremental.h (enum Incremental_input_flags): Add INCREMENTAL_INPUT_AS_NEEDED. (Incremental_input_entry::Incremental_input_entry): Initialize new data member. (Incremental_input_entry::set_as_needed): New function. (Incremental_input_entry::as_needed): New function. (Incremental_input_entry::do_dynobj_entry): New function. (Incremental_input_entry::as_needed_): New data member. (Incremental_object_entry::Incremental_object_entry): Don't check for shared library. (Incremental_object_entry::do_type): Likewise. (class Incremental_dynobj_entry): New class. (Incremental_input_entry_reader::as_needed): New function. (Incremental_input_entry_reader::get_soname): New function. (Incremental_input_entry_reader::get_global_symbol_count): Rewrite. (Incremental_input_entry_reader::get_output_symbol_index): Adjust size of shared library info entry. * layout.cc (Layout::finish_dynamic_section): Don't test for incremental link when adding DT_NEEDED entries. * object.h (Object::Object): Initialize new data member. (Object::dynobj): New function. (Object::set_as_needed): New function. (Object::as_needed): New function. (Object::do_dynobj): New function. (Object::as_needed_): New data member.
2011-05-24 23:57:28 +02:00
// Return whether this object was linked with --as-needed.
bool
as_needed() const
{ return this->as_needed_; }
* readsyms.cc (Read_symbols::incompatible_warning): New function. (Read_symbols::requeue): New function. (Read_symbols::do_read_symbols): If make_elf_object fails because the target type is not configured, and the file was searched for, issue a warning and retry with the next directory. (Add_symbols::run): If the file has an incompatible format, and it was searched for, requeue the Read_symbols task. On error, release the object. * readsyms.h (class Read_symbols): Add dirindex_ field. Add dirindex parameter to constructor. Change all callers. Declare incompatible_warning and requeue. (class Add_symbols): Add dirpath_, dirindex_, mapfile_, input_argument_ and input_group_ fields. Add them to constructor. Change all callers. (class Read_script): Add dirindex_ field. Add it to constructor. Change all callers. * archive.cc (Archive::setup): Remove input_objects parameter. Change all callers. (Archive::get_file_and_offset): Likewise. (Archive::read_all_symbols): Likewise. (Archive::read_symbols): Likewise. (Archive::get_elf_object_for_member): Remove input_objects parameter. Add punconfigured parameter. Change all callers. (Archive::add_symbols): Change return type to bool. Check return value of include_member. (Archive::include_all_members): Likewise. (Archive::include_member): Change return type to bool. Return false if first included object has incompatible target. Set included_member_ field. (Add_archive_symbols::run): If add_symbols returns false, requeue Read_symbols task. * archive.h (class Archive): Add included_member_ field. Initialize it in constructor. Add input_file and searched_for methods. Update declarations. (class Add_archive_symbols): Add dirpath_, dirindex_, and input_argument_ fields. Add them to constructor. Change all callers. * script.cc: Include "target-select.h". (class Parser_closure): Add skip_on_incompatible_target_ and found_incompatible_target_ fields. Add skip_on_incompatible_target parameter to constructor. Change all callers. Add methods skip_on_incompatible_target, clear_skip_on_incompatible_target, found_incompatible_target, and set_found_incompatible_target. (read_input_script): Add dirindex parameter. Change all callers. If parser finds an incompatible target, requeue Read_symbols task. (script_set_symbol): Clear skip_on_incompatible_target in closure. (script_add_assertion, script_parse_option): Likewise. (script_start_sections, script_add_phdr): Likewise. (script_check_output_format): New function. * script.h (read_input_script): Update declaration. * script-c.h (script_check_output_format): Declare. * yyscript.y (file_cmd): Handle OUTPUT_FORMAT. (ignore_cmd): Remove OUTPUT_FORMAT. * fileread.cc (Input_file::Input_file): Add explicit this. (Input_file::will_search_for): New function. (Input_file::open): Add pindex parameter. Change all callers. * fileread.h (class Input_file): Add input_file_argument method. Declare will_search_for. Update declarations. * object.cc (make_elf_object): Add punconfigured parameter. Change all callers. * object.h (class Object): Make input_file public. Add searched_for method. (make_elf_object): Update declaration. * dirsearch.cc (Dirsearch::find): Add pindex parameter. Use it to restart search. * dirsearch.h (class Dirsearch): Update declaration. * options.h (class General_options): Add --warn-search-mismatch. * parameters.cc (Parameters::is_compatible_target): New function. * parameters.h (class Parameters): Declare is_compatible_target. * workqueue.cc (Workqueue::add_blocker): New function. * workqueue.h (class Workqueue): Declare add_blocker.
2009-03-14 06:56:46 +01:00
// Return whether we found this object by searching a directory.
bool
searched_for() const
{ return this->input_file()->will_search_for(); }
2009-05-19 Doug Kwan <dougkwan@google.com> * 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.
2009-05-20 00:14:17 +02:00
bool
no_export() const
{ return this->no_export_; }
void
set_no_export(bool value)
{ this->no_export_ = value; }
bool
section_is_compressed(unsigned int shndx,
section_size_type* uncompressed_size,
elfcpp::Elf_Xword* palign = NULL) const
Support compressed debug sections in dynamic object files. This patch adds support for reading compressed debug info in shared objects. It actually simplifies things, by moving the support for compressed sections all the way up to the top-level Object class, eliminating the need for several virtual methods. gold/ * dwp.cc (Sized_relobj_dwo::do_section_contents): Delete. (Sized_relobj_dwo::setup): Build compressed section map. (Sized_relobj_dwo::do_decompressed_section_contents): Delete. * dynobj.cc (Sized_dynobj::base_read_symbols): Build compressed section map. * object.cc (Sized_relobj_file::Sized_relobj_file): Remove compressed_sections_ field. (build_compressed_section_map): Take Object instead of Sized_relobj_file parameter; add decompress_if_needed parameter. (Sized_relobj_file::do_find_special_sections): Store compressed section map in parent Object. (Sized_relobj_file::do_decompressed_section_contents): Move implementation to Object::decompressed_section_contents. (Sized_relobj_file::do_discard_decompressed_sections): Move implementation to Object::discard_decompressed_sections. * object.h (build_compressed_section_map): Declare. (Object::Object): Add compressed_sections_ field. (Object::section_is_compressed): Move implementation here. (Object::decompressed_section_contents): De-virtualize. (Object::discard_decompressed_sections): De-virtualize. (Object::do_section_is_compressed): Delete. (Object::do_decompressed_section_contents): Delete. (Object::set_compressed_sections): New method. (Object::compressed_sections): New method. (Object::compressed_sections_): New data member. (Compressed_section_info, Compressed_section_map): Move to top of file. (Sized_relobj_file::do_section_is_compressed): Delete. (Sized_relobj_file::do_decompressed_section_contents): Delete. (Sized_relobj_file::do_discard_decompressed_sections): Delete. (Sized_relobj_file::compressed_sections_): Move to Object class.
2015-03-22 02:50:11 +01:00
{
if (this->compressed_sections_ == NULL)
return false;
Compressed_section_map::const_iterator p =
this->compressed_sections_->find(shndx);
if (p != this->compressed_sections_->end())
{
if (uncompressed_size != NULL)
*uncompressed_size = p->second.size;
if (palign != NULL)
*palign = p->second.addralign;
Support compressed debug sections in dynamic object files. This patch adds support for reading compressed debug info in shared objects. It actually simplifies things, by moving the support for compressed sections all the way up to the top-level Object class, eliminating the need for several virtual methods. gold/ * dwp.cc (Sized_relobj_dwo::do_section_contents): Delete. (Sized_relobj_dwo::setup): Build compressed section map. (Sized_relobj_dwo::do_decompressed_section_contents): Delete. * dynobj.cc (Sized_dynobj::base_read_symbols): Build compressed section map. * object.cc (Sized_relobj_file::Sized_relobj_file): Remove compressed_sections_ field. (build_compressed_section_map): Take Object instead of Sized_relobj_file parameter; add decompress_if_needed parameter. (Sized_relobj_file::do_find_special_sections): Store compressed section map in parent Object. (Sized_relobj_file::do_decompressed_section_contents): Move implementation to Object::decompressed_section_contents. (Sized_relobj_file::do_discard_decompressed_sections): Move implementation to Object::discard_decompressed_sections. * object.h (build_compressed_section_map): Declare. (Object::Object): Add compressed_sections_ field. (Object::section_is_compressed): Move implementation here. (Object::decompressed_section_contents): De-virtualize. (Object::discard_decompressed_sections): De-virtualize. (Object::do_section_is_compressed): Delete. (Object::do_decompressed_section_contents): Delete. (Object::set_compressed_sections): New method. (Object::compressed_sections): New method. (Object::compressed_sections_): New data member. (Compressed_section_info, Compressed_section_map): Move to top of file. (Sized_relobj_file::do_section_is_compressed): Delete. (Sized_relobj_file::do_decompressed_section_contents): Delete. (Sized_relobj_file::do_discard_decompressed_sections): Delete. (Sized_relobj_file::compressed_sections_): Move to Object class.
2015-03-22 02:50:11 +01:00
return true;
}
return false;
}
2012-03-21 Cary Coutant <ccoutant@google.com> * Makefile.am: Add gdb-index.cc, gdb-index.h. * Makefile.in: Regenerate. * dwarf_reader.cc (Sized_elf_reloc_mapper::do_initialize): New function. (Sized_elf_reloc_mapper::symbol_section): New function. (Sized_elf_reloc_mapper::do_get_reloc_target): New function. (make_elf_reloc_mapper): New function. (Dwarf_abbrev_table::clear_abbrev_codes): New function. (Dwarf_abbrev_table::do_read_abbrevs): New function. (Dwarf_abbrev_table::do_get_abbrev): New function. (Dwarf_ranges_table::read_ranges_table): New function. (Dwarf_ranges_table::read_range_list): New function. (Dwarf_pubnames_table::read_section): New function. (Dwarf_pubnames_table::read_header): New function. (Dwarf_pubnames_table::next_name): New function. (Dwarf_die::Dwarf_die): New function. (Dwarf_die::read_attributes): New function. (Dwarf_die::skip_attributes): New function. (Dwarf_die::set_name): New function. (Dwarf_die::set_linkage_name): New function. (Dwarf_die::attribute): New function. (Dwarf_die::string_attribute): New function. (Dwarf_die::int_attribute): New function. (Dwarf_die::uint_attribute): New function. (Dwarf_die::ref_attribute): New function. (Dwarf_die::child_offset): New function. (Dwarf_die::sibling_offset): New function. (Dwarf_info_reader::check_buffer): New function. (Dwarf_info_reader::parse): New function. (Dwarf_info_reader::do_parse): New function. (Dwarf_info_reader::do_read_string_table): New function. (Dwarf_info_reader::lookup_reloc): New function. (Dwarf_info_reader::get_string): New function. (Dwarf_info_reader::visit_compilation_unit): New function. (Dwarf_info_reader::visit_type_unit): New function. (Sized_dwarf_line_info::Sized_dwarf_line_info): Use Sized_elf_reloc_mapper. (Sized_dwarf_line_info::symbol_section): Remove function. (Sized_dwarf_line_info::read_relocs): Use Sized_elf_reloc_mapper. (Sized_dwarf_line_info::read_line_mappings): Remove object parameter, adjust callers. (Sized_dwarf_line_info::format_file_lineno): Fix type of cast. * dwarf_reader.h: Include <sys/types.h>. (class Track_relocs): Remove forward declaration. (class Elf_reloc_mapper): New class. (class Sized_elf_reloc_mapper): New class. (class Dwarf_abbrev_table): New class. (class Dwarf_range_list): New class. (class Dwarf_ranges_table): New class. (class Dwarf_pubnames_table): New class. (class Dwarf_die): New class. (class Dwarf_info_reader): New class. (Sized_dwarf_line_info::read_line_mappings): Remove object parameter. (Sized_dwarf_line_info::symbol_section): Remove member function. * dynobj.h (Sized_dynobj::do_section_contents): Refactor code from base class. * gdb-index.cc: New source file. * gdb-index.h: New source file. * incremental.cc (Sized_relobj_incr::do_layout): Track .debug_info and .debug_types sections, call Layout::add_to_gdb_index. (Sized_relobj_incr::do_section_name): Implement. (Sized_relobj_incr::do_section_contents): Adjust parameter list and return type; Implement. (Sized_incr_dynobj::do_section_contents): Adjust parameter list and return type. * incremental.h (Sized_relobj_incr::do_section_contents): Adjust parameter list and return type. (Sized_incr_dynobj::do_section_contents): Likewise. * layout.cc: Include gdb-index.h. (Layout::Layout): Initialize gdb_index_data_. (Layout::init_fixed_output_section): Check for .gdb_index section. (Layout::add_to_gdb_index): New function. Instantiate. * layout.h: Add forward declaration for class Gdb_index. (Layout::add_to_gdb_index): New member function. (Layout::gdb_index_data_): New data member. * main.cc: Include gdb-index.h. (main): Print statistics for gdb index. * object.cc (Object::section_contents): Move code into do_section_contents. (need_decompressed_section): Check for sections needed when building gdb index. (build_compressed_section_map): Likewise. (Sized_relobj_file::do_read_symbols): Need local symbols when building gdb index. (Sized_relobj_file::do_layout): Track .debug_info and .debug_types sections; call Layout::add_to_gdb_index. (Sized_relobj_file::do_decompressed_section_contents): Call do_section_contents directly. * object.h (Object::do_section_contents): Adjust parameter list and return type. (Object::do_decompressed_section_contents): Call do_section_contents directly. (Sized_relobj_file::do_section_contents): Adjust parameter list and return type. * options.h (class General_options): Add --gdb-index option. * plugin.cc (Sized_pluginobj::do_section_contents): Adjust parameter list and return type. * plugin.h (Sized_pluginobj::do_section_contents): Likewise. * reloc.h (Track_relocs::checkpoint): New function. (Track_relocs::reset): New function. * testsuite/Makefile.am (gdb_index_test_1.sh, gdb_index_test_2.sh): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/gdb_index_test.cc: New test source file. * testsuite/gdb_index_test_1.sh: New test source file. * testsuite/gdb_index_test_2.sh: New test source file.
2012-03-21 20:02:22 +01:00
// Return a view of the decompressed contents of a section. Set *PLEN
// to the size. Set *IS_NEW to true if the contents need to be freed
// by the caller.
const unsigned char*
decompressed_section_contents(unsigned int shndx, section_size_type* plen,
bool* is_cached, uint64_t* palign = NULL);
// Discard any buffers of decompressed sections. This is done
// at the end of the Add_symbols task.
void
Support compressed debug sections in dynamic object files. This patch adds support for reading compressed debug info in shared objects. It actually simplifies things, by moving the support for compressed sections all the way up to the top-level Object class, eliminating the need for several virtual methods. gold/ * dwp.cc (Sized_relobj_dwo::do_section_contents): Delete. (Sized_relobj_dwo::setup): Build compressed section map. (Sized_relobj_dwo::do_decompressed_section_contents): Delete. * dynobj.cc (Sized_dynobj::base_read_symbols): Build compressed section map. * object.cc (Sized_relobj_file::Sized_relobj_file): Remove compressed_sections_ field. (build_compressed_section_map): Take Object instead of Sized_relobj_file parameter; add decompress_if_needed parameter. (Sized_relobj_file::do_find_special_sections): Store compressed section map in parent Object. (Sized_relobj_file::do_decompressed_section_contents): Move implementation to Object::decompressed_section_contents. (Sized_relobj_file::do_discard_decompressed_sections): Move implementation to Object::discard_decompressed_sections. * object.h (build_compressed_section_map): Declare. (Object::Object): Add compressed_sections_ field. (Object::section_is_compressed): Move implementation here. (Object::decompressed_section_contents): De-virtualize. (Object::discard_decompressed_sections): De-virtualize. (Object::do_section_is_compressed): Delete. (Object::do_decompressed_section_contents): Delete. (Object::set_compressed_sections): New method. (Object::compressed_sections): New method. (Object::compressed_sections_): New data member. (Compressed_section_info, Compressed_section_map): Move to top of file. (Sized_relobj_file::do_section_is_compressed): Delete. (Sized_relobj_file::do_decompressed_section_contents): Delete. (Sized_relobj_file::do_discard_decompressed_sections): Delete. (Sized_relobj_file::compressed_sections_): Move to Object class.
2015-03-22 02:50:11 +01:00
discard_decompressed_sections();
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Return the index of the first incremental relocation for symbol SYMNDX.
unsigned int
get_incremental_reloc_base(unsigned int symndx) const
{ return this->do_get_incremental_reloc_base(symndx); }
// Return the number of incremental relocations for symbol SYMNDX.
unsigned int
get_incremental_reloc_count(unsigned int symndx) const
{ return this->do_get_incremental_reloc_count(symndx); }
// Return the output view for section SHNDX.
unsigned char*
get_output_view(unsigned int shndx, section_size_type* plen) const
{ return this->do_get_output_view(shndx, plen); }
protected:
* dynobj.h (Dynobj::do_dynobj): New function. * incremental-dump.cc (dump_incremental_inputs): Print as_needed flag and soname for shared objects. * incremental.cc (Incremental_inputs::report_object): Make either Incremental_object_entry or Incremental_dynobj_entry; add soname to string table. (Incremental_inputs::report_input_section): Add assertion. (Output_section_incremental_inputs::set_final_data_size): Adjust type of input file entry for shared libraries; adjust size of shared library info entry. (Output_section_incremental_inputs::write_input_files): Write as_needed flag for shared libraries. (Output_section_incremental_inputs::write_info_blocks): Adjust type of input file entry for shared libraries; write soname. (Sized_incr_dynobj::Sized_incr_dynobj): Read as_needed flag and soname from incremental info. * incremental.h (enum Incremental_input_flags): Add INCREMENTAL_INPUT_AS_NEEDED. (Incremental_input_entry::Incremental_input_entry): Initialize new data member. (Incremental_input_entry::set_as_needed): New function. (Incremental_input_entry::as_needed): New function. (Incremental_input_entry::do_dynobj_entry): New function. (Incremental_input_entry::as_needed_): New data member. (Incremental_object_entry::Incremental_object_entry): Don't check for shared library. (Incremental_object_entry::do_type): Likewise. (class Incremental_dynobj_entry): New class. (Incremental_input_entry_reader::as_needed): New function. (Incremental_input_entry_reader::get_soname): New function. (Incremental_input_entry_reader::get_global_symbol_count): Rewrite. (Incremental_input_entry_reader::get_output_symbol_index): Adjust size of shared library info entry. * layout.cc (Layout::finish_dynamic_section): Don't test for incremental link when adding DT_NEEDED entries. * object.h (Object::Object): Initialize new data member. (Object::dynobj): New function. (Object::set_as_needed): New function. (Object::as_needed): New function. (Object::do_dynobj): New function. (Object::as_needed_): New data member.
2011-05-24 23:57:28 +02:00
// Returns NULL for Objects that are not dynamic objects. This method
// is overridden in the Dynobj class.
virtual Dynobj*
do_dynobj()
{ return NULL; }
Add plugin functionality for link-time optimization (LTO). include/: * plugin-api.h: New file. gold/: * configure.ac (plugins): Add --enable-plugins option. * configure: Regenerate. * config.in: Regenerate. * Makefile.am (LIBDL): New variable. (CCFILES): Add plugin.cc. (HFILES): Add plugin.h. (ldadd_var): Add LIBDL. * Makefile.in: Regenerate. * archive.cc: Include "plugin.h". (Archive::setup): Don't preread archive symbols when using a plugin. (Archive::get_file_and_offset): Add memsize parameter. Change callers. (Archive::get_elf_object_for_member): Call plugin hooks for claiming files. (Archive::include_member): Add symbols from plugin objects. * archive.h (Archive::get_file_and_offset): Add memsize parameter. * descriptors.cc (Descriptors::open): Check for file descriptors abandoned by plugins. (Descriptors::claim_for_plugin): New function. * descriptors.h (Descriptors::claim_for_plugin): New function. (Open_descriptor::is_claimed): New field. (claim_descriptor_for_plugin): New function. * fileread.cc (File_read::claim_for_plugin): New function. * fileread.h (File_read::claim_for_plugin): New function. (File_read::descriptor): New function. * gold.cc: Include "plugin.h". (queue_initial_tasks): Add task to call plugin hooks for generating new object files. * main.cc: Include "plugin.h". (main): Load plugin libraries. * object.h (Pluginobj): Declare. (Object::pluginobj): New function. (Object::do_pluginobj): New function. (Object::set_target): New function. * options.cc: Include "plugin.h". (General_options::parse_plugin): New function. (General_options::General_options): Initialize plugins_ field. (General_options::add_plugin): New function. * options.h (Plugin_manager): Declare. (General_options): Add --plugin option. (General_options::has_plugins): New function. (General_options::plugins): New function. (General_options::add_plugin): New function. (General_options::plugins_): New field. * plugin.cc: New file. * plugin.h: New file. * readsyms.cc: Include "plugin.h". (Read_symbols::do_read_symbols): Check for archive before checking for ELF file. Call plugin hooks to claim files. * resolve.cc (Symbol_table::resolve): Record when symbol is referenced from a real object file; force override when processing replacement files. * symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field. (Symbol::init_base_object): Likewise. (Symbol::init_base_output_data): Likewise. (Symbol::init_base_output_segment): Likewise. (Symbol::init_base_constant): Likewise. (Symbol::init_base_undefined): Likewise. (Symbol::output_section): Assert that object is not a plugin. (Symbol_table::add_from_pluginobj): New function. (Symbol_table::sized_finalize_symbol): Treat symbols from plugins as undefined. (Symbol_table::sized_write_globals): Likewise. (Symbol_table::add_from_pluginobj): Instantiate template. * symtab.h (Sized_pluginobj): Declare. (Symbol::in_real_elf): New function. (Symbol::set_in_real_elf): New function. (Symbol::in_real_elf_): New field. (Symbol_table::add_from_pluginobj): New function. * testsuite/Makefile.am (AM_CFLAGS): New variable. (LIBDL): New variable. (LDADD): Add LIBDL. (check_PROGRAMS): Add plugin_test_1 and plugin_test_2. (check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh. (check_DATA): Add plugin_test_1.err and plugin_test_2.err. (MOSTLYCLEANFILES): Likewise. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c: New file. * testsuite/plugin_test_1.sh: New file. * testsuite/plugin_test_2.sh: New file.
2008-09-20 00:54:57 +02:00
// Returns NULL for Objects that are not plugin objects. This method
// is overridden in the Pluginobj class.
virtual Pluginobj*
do_pluginobj()
{ return NULL; }
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
// Return TRUE if this is an incremental (unchanged) input file.
// We return FALSE by default; the incremental object classes
// override this method.
virtual bool
do_is_incremental() const
{ return false; }
// Return the last modified time of the file. This method may be
// overridden for subclasses that don't use an actual file (e.g.,
// Incremental objects).
virtual Timespec
do_get_mtime()
{ return this->input_file()->file().get_mtime(); }
// Read the symbols--implemented by child class.
virtual void
do_read_symbols(Read_symbols_data*) = 0;
// Lay out sections--implemented by child class.
virtual void
2007-09-21 09:20:01 +02:00
do_layout(Symbol_table*, Layout*, Read_symbols_data*) = 0;
// Add symbol information to the global symbol table--implemented by
// child class.
virtual void
do_add_symbols(Symbol_table*, Read_symbols_data*, Layout*) = 0;
2010-03-22 Rafael Espindola <espindola@google.com> * archive.cc (Should_include): Move to archive.h. (should_include_member): Make it a member of Archive. (Lib_group): New. (Add_lib_group_symbols): New. * archive.h: Include options.h. (Archive_member): Moved from Archive. (Should_include): Moved from archive.cc. (Lib_group): New. (Add_lib_group_symbols): New. * dynobj.cc (do_should_include_member): New. * dynobj.h (do_should_include_member): New. * gold.cc (queue_initial_tasks): Update call to queue. * main.cc (main): Print lib group stats. * object.cc (do_should_include_member): New. * object.h: Include archive.h. (Object::should_include_member): New. (Object::do_should_include_member): New. (Sized_relobj::do_should_include_member): New. * options.cc (General_options::parse_start_lib): New. (General_options::parse_end_lib): New. (Input_arguments::add_file): Handle lib groups. (Input_arguments::start_group): Check we are not in a lib. (Input_arguments::start_lib): New. (Input_arguments::end_lib): New. * options.h (General_options): Add start_lib and end_lib. (Input_argument::lib_): New. (Input_argument::lib): New. (Input_argument::is_lib): New. (Input_file_lib): New. (Input_arguments::in_lib_): New. (Input_arguments::in_lib): New. (Input_arguments::start_lib): New. (Input_arguments::end_lib_): New. * plugin.cc (Pluginobj::get_symbol_resolution_info): Mark symbols in unused members as preempted. (Sized_pluginobj::do_should_include_member): New. * plugin.h (Sized_pluginobj::do_should_include_member): New. * readsyms.cc (Read_symbols::locks): If we are just reading a member, return the blocker. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::do_read_symbols): Handle lib groups. (Read_symbols::get_name): Handle lib groups. * readsyms.h (Read_symbols): Add an archive member pointer. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::member_): New. * script.cc (read_input_script): Update call to queue_soon.
2010-03-22 15:18:24 +01:00
virtual Archive::Should_include
PR 11855 * script.cc (Script_options::Script_options): Initialize symbol_definitions_ and symbol_references_. (Script_options::add_symbol_assignment): Update symbol_definitions_ and symbol_references_. (Script_options::add_symbol_reference): New function. (script_symbol): New function. * script.h (class Script_options): Add symbol_definitions_ and symbol_references_ fields. (Script_options::referenced_const_iterator): New type. (Script_options::referenced_begin): New function. (Script_options::referenced_end): New function. (Script_options::is_referenced): New function. (Script_options::any_unreferenced): New function. * script-c.h (script_symbol): Declare. * yyscript.y (exp): Call script_symbol. * symtab.cc: Include "script.h". (Symbol_table::gc_mark_undef_symbols): Add layout parameter. Change all callers. Check symbols referenced by scripts. (Symbol_table::add_undefined_symbols_from_command_line): Add layout parameter. Change all callers. (Symbol_table::do_add_undefined_symbols_from_command_line): Likewise. Break out loop body. Check symbols referenced by scripts. (Symbol_table::add_undefined_symbol_from_command_line): New function broken out of do_add_undefined_symbols_from_command_line. * symtab.h (class Symbol_table): Update declarations. * archive.cc: Include "layout.h". (Archive::should_include_member): Add layout parameter. Change all callers. Check for symbol mentioned in expression. * archive.h (class Archive): Update declaration. * object.cc (Sized_relobj::do_should_include_member): Add layout parameter. * object.h (Object::should_include_member): Add layout parameter. Change all callers. (Object::do_should_include_member): Add layout parameter. (class Sized_relobj): Update declaration. * dynobj.cc (Sized_dynobj::do_should_include_member): Add layout parameter. * dynobj.h (class Sized_dynobj): Update declaration. * plugin.cc (Sized_pluginobj::do_should_include_member): Add layout parameter. * plugin.h (class Sized_pluginobj): Update declaration.
2010-08-02 15:34:33 +02:00
do_should_include_member(Symbol_table* symtab, Layout*, Read_symbols_data*,
2010-03-22 Rafael Espindola <espindola@google.com> * archive.cc (Should_include): Move to archive.h. (should_include_member): Make it a member of Archive. (Lib_group): New. (Add_lib_group_symbols): New. * archive.h: Include options.h. (Archive_member): Moved from Archive. (Should_include): Moved from archive.cc. (Lib_group): New. (Add_lib_group_symbols): New. * dynobj.cc (do_should_include_member): New. * dynobj.h (do_should_include_member): New. * gold.cc (queue_initial_tasks): Update call to queue. * main.cc (main): Print lib group stats. * object.cc (do_should_include_member): New. * object.h: Include archive.h. (Object::should_include_member): New. (Object::do_should_include_member): New. (Sized_relobj::do_should_include_member): New. * options.cc (General_options::parse_start_lib): New. (General_options::parse_end_lib): New. (Input_arguments::add_file): Handle lib groups. (Input_arguments::start_group): Check we are not in a lib. (Input_arguments::start_lib): New. (Input_arguments::end_lib): New. * options.h (General_options): Add start_lib and end_lib. (Input_argument::lib_): New. (Input_argument::lib): New. (Input_argument::is_lib): New. (Input_file_lib): New. (Input_arguments::in_lib_): New. (Input_arguments::in_lib): New. (Input_arguments::start_lib): New. (Input_arguments::end_lib_): New. * plugin.cc (Pluginobj::get_symbol_resolution_info): Mark symbols in unused members as preempted. (Sized_pluginobj::do_should_include_member): New. * plugin.h (Sized_pluginobj::do_should_include_member): New. * readsyms.cc (Read_symbols::locks): If we are just reading a member, return the blocker. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::do_read_symbols): Handle lib groups. (Read_symbols::get_name): Handle lib groups. * readsyms.h (Read_symbols): Add an archive member pointer. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::member_): New. * script.cc (read_input_script): Update call to queue_soon.
2010-03-22 15:18:24 +01:00
std::string* why) = 0;
* archive.cc (Library_base::should_include_member): Move method here from class Archive. (Archive::Archive): Initialize base class. (Archive::should_include_member): Move to base class. (Archive::do_for_all_unused_symbols): New function. (Add_archive_symbols::run): Remove redundant access to incremental_inputs. (Lib_group::Lib_group): Initialize base class. (Lib_group::do_filename): New function. (Lib_group::include_member): Pass pointer to Lib_group to report_object. (Lib_group::do_for_all_unused_symbols): New function. (Add_lib_group_symbols::run): Report archive information for incremental links. * archive.h (class Library_base): New base class. (class Archive): Derive from Library_base. (Archive::filename): Move to base class. (Archive::set_incremental_info): Likewise. (Archive::incremental_info): Likewise. (Archive::Should_include): Likewise. (Archive::should_include_member): Likewise. (Archive::Armap_entry): Remove. (Archive::Unused_symbol_iterator): Remove. (Archive::unused_symbols_begin): Remove. (Archive::unused_symbols_end): Remove. (Archive::do_filename): New function. (Archive::do_get_mtime): New function. (Archive::do_for_all_unused_symbols): New function. (Archive::task_): Move to base class. (Archive::incremental_info_): Likewise. (class Lib_group): Derive from Library_base. (Lib_group::do_filename): New function. (Lib_group::do_get_mtime): New function. (Lib_group::do_for_all_unused_symbols): New function. (Lib_group::task_): Move to base class. * dynobj.cc (Sized_dynobj::do_for_all_global_symbols): New function. * dynobj.h (Sized_dynobj::do_for_all_global_symbols): New function. * incremental.cc (Incremental_inputs::report_archive_begin): Use Library_base; call library's get_mtime; add incremental inputs entry before members. (class Unused_symbol_visitor): New class. (Incremental_inputs::report_archive_end): Use Library_base; use visitor class to record unused symbols; don't add incremental inputs entry after members. (Incremental_inputs::report_object): Use Library_base. * incremental.h (Incremental_archive_entry::Incremental_archive_entry): Remove unused Archive parameter. (Incremental_inputs::report_archive_begin): Use Library_base. (Incremental_inputs::report_archive_end): Likewise. (Incremental_inputs::report_object): Likewise. * object.cc (Sized_relobj::do_for_all_global_symbols): New function. * object.h (Object::for_all_global_symbols): New function. (Object::do_for_all_global_symbols): New function. (Sized_relobj::do_for_all_global_symbols): New function. * plugin.cc (Sized_pluginobj::do_for_all_global_symbols): New function. * plugin.h (Sized_pluginobj::do_for_all_global_symbols): New function.
2011-03-30 03:31:57 +02:00
// Iterate over global symbols, calling a visitor class V for each.
virtual void
do_for_all_global_symbols(Read_symbols_data* sd,
Library_base::Symbol_visitor_base* v) = 0;
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
// Iterate over local symbols, calling a visitor class V for each GOT offset
// associated with a local symbol.
virtual void
do_for_all_local_got_entries(Got_offset_list::Visitor* v) const = 0;
// Return the location of the contents of a section. Implemented by
// child class.
2012-03-21 Cary Coutant <ccoutant@google.com> * Makefile.am: Add gdb-index.cc, gdb-index.h. * Makefile.in: Regenerate. * dwarf_reader.cc (Sized_elf_reloc_mapper::do_initialize): New function. (Sized_elf_reloc_mapper::symbol_section): New function. (Sized_elf_reloc_mapper::do_get_reloc_target): New function. (make_elf_reloc_mapper): New function. (Dwarf_abbrev_table::clear_abbrev_codes): New function. (Dwarf_abbrev_table::do_read_abbrevs): New function. (Dwarf_abbrev_table::do_get_abbrev): New function. (Dwarf_ranges_table::read_ranges_table): New function. (Dwarf_ranges_table::read_range_list): New function. (Dwarf_pubnames_table::read_section): New function. (Dwarf_pubnames_table::read_header): New function. (Dwarf_pubnames_table::next_name): New function. (Dwarf_die::Dwarf_die): New function. (Dwarf_die::read_attributes): New function. (Dwarf_die::skip_attributes): New function. (Dwarf_die::set_name): New function. (Dwarf_die::set_linkage_name): New function. (Dwarf_die::attribute): New function. (Dwarf_die::string_attribute): New function. (Dwarf_die::int_attribute): New function. (Dwarf_die::uint_attribute): New function. (Dwarf_die::ref_attribute): New function. (Dwarf_die::child_offset): New function. (Dwarf_die::sibling_offset): New function. (Dwarf_info_reader::check_buffer): New function. (Dwarf_info_reader::parse): New function. (Dwarf_info_reader::do_parse): New function. (Dwarf_info_reader::do_read_string_table): New function. (Dwarf_info_reader::lookup_reloc): New function. (Dwarf_info_reader::get_string): New function. (Dwarf_info_reader::visit_compilation_unit): New function. (Dwarf_info_reader::visit_type_unit): New function. (Sized_dwarf_line_info::Sized_dwarf_line_info): Use Sized_elf_reloc_mapper. (Sized_dwarf_line_info::symbol_section): Remove function. (Sized_dwarf_line_info::read_relocs): Use Sized_elf_reloc_mapper. (Sized_dwarf_line_info::read_line_mappings): Remove object parameter, adjust callers. (Sized_dwarf_line_info::format_file_lineno): Fix type of cast. * dwarf_reader.h: Include <sys/types.h>. (class Track_relocs): Remove forward declaration. (class Elf_reloc_mapper): New class. (class Sized_elf_reloc_mapper): New class. (class Dwarf_abbrev_table): New class. (class Dwarf_range_list): New class. (class Dwarf_ranges_table): New class. (class Dwarf_pubnames_table): New class. (class Dwarf_die): New class. (class Dwarf_info_reader): New class. (Sized_dwarf_line_info::read_line_mappings): Remove object parameter. (Sized_dwarf_line_info::symbol_section): Remove member function. * dynobj.h (Sized_dynobj::do_section_contents): Refactor code from base class. * gdb-index.cc: New source file. * gdb-index.h: New source file. * incremental.cc (Sized_relobj_incr::do_layout): Track .debug_info and .debug_types sections, call Layout::add_to_gdb_index. (Sized_relobj_incr::do_section_name): Implement. (Sized_relobj_incr::do_section_contents): Adjust parameter list and return type; Implement. (Sized_incr_dynobj::do_section_contents): Adjust parameter list and return type. * incremental.h (Sized_relobj_incr::do_section_contents): Adjust parameter list and return type. (Sized_incr_dynobj::do_section_contents): Likewise. * layout.cc: Include gdb-index.h. (Layout::Layout): Initialize gdb_index_data_. (Layout::init_fixed_output_section): Check for .gdb_index section. (Layout::add_to_gdb_index): New function. Instantiate. * layout.h: Add forward declaration for class Gdb_index. (Layout::add_to_gdb_index): New member function. (Layout::gdb_index_data_): New data member. * main.cc: Include gdb-index.h. (main): Print statistics for gdb index. * object.cc (Object::section_contents): Move code into do_section_contents. (need_decompressed_section): Check for sections needed when building gdb index. (build_compressed_section_map): Likewise. (Sized_relobj_file::do_read_symbols): Need local symbols when building gdb index. (Sized_relobj_file::do_layout): Track .debug_info and .debug_types sections; call Layout::add_to_gdb_index. (Sized_relobj_file::do_decompressed_section_contents): Call do_section_contents directly. * object.h (Object::do_section_contents): Adjust parameter list and return type. (Object::do_decompressed_section_contents): Call do_section_contents directly. (Sized_relobj_file::do_section_contents): Adjust parameter list and return type. * options.h (class General_options): Add --gdb-index option. * plugin.cc (Sized_pluginobj::do_section_contents): Adjust parameter list and return type. * plugin.h (Sized_pluginobj::do_section_contents): Likewise. * reloc.h (Track_relocs::checkpoint): New function. (Track_relocs::reset): New function. * testsuite/Makefile.am (gdb_index_test_1.sh, gdb_index_test_2.sh): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/gdb_index_test.cc: New test source file. * testsuite/gdb_index_test_1.sh: New test source file. * testsuite/gdb_index_test_2.sh: New test source file.
2012-03-21 20:02:22 +01:00
virtual const unsigned char*
do_section_contents(unsigned int shndx, section_size_type* plen,
bool cache) = 0;
2008-02-04 06:43:05 +01:00
// Get the size of a section--implemented by child class.
virtual uint64_t
do_section_size(unsigned int shndx) = 0;
// Get the name of a section--implemented by child class.
virtual std::string
do_section_name(unsigned int shndx) const = 0;
// Get section flags--implemented by child class.
virtual uint64_t
do_section_flags(unsigned int shndx) = 0;
2009-08-05 22:51:56 +02:00
// Get section entsize--implemented by child class.
virtual uint64_t
do_section_entsize(unsigned int shndx) = 0;
// Get section address--implemented by child class.
virtual uint64_t
do_section_address(unsigned int shndx) = 0;
// Get section type--implemented by child class.
virtual unsigned int
do_section_type(unsigned int shndx) = 0;
// Get section link field--implemented by child class.
virtual unsigned int
do_section_link(unsigned int shndx) = 0;
// Get section info field--implemented by child class.
virtual unsigned int
do_section_info(unsigned int shndx) = 0;
2008-02-04 06:43:05 +01:00
// Get section alignment--implemented by child class.
virtual uint64_t
do_section_addralign(unsigned int shndx) = 0;
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Return the output section given a section index--implemented
// by child class.
virtual Output_section*
do_output_section(unsigned int) const
{ gold_unreachable(); }
// Get the address of a section--implemented by child class.
virtual uint64_t
do_output_section_address(unsigned int)
{ gold_unreachable(); }
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Get the offset of a section--implemented by child class.
virtual uint64_t
do_output_section_offset(unsigned int) const
{ gold_unreachable(); }
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
// Return the Xindex structure to use.
virtual Xindex*
do_initialize_xindex() = 0;
* cref.cc: New file. * cref.h: New file. * options.h (class General_options): Add --print-symbol-counts. * main.cc (main): Issue defined symbol report if requested. * archive.cc (Archive::interpret_header): Make into a const member function. (Archive::add_symbols): Call Input_objects::archive_start and archive_stop. (Archive::const_iterator): Define new class. (Archive::begin, Archive::end): New functions. (Archive::include_all_members): Rewrite to use iterator. (Archive::count_members): New function. * archive.h (class Archive): Update declarations. (Archive::filename): New function. * object.cc: Include "cref.h". (Sized_relobj::Sized_relobj): Initialize defined_count_. (Sized_relobj::do_get_global_symbol_counts): New function. (Input_objects::add_object): Add object to cross-referencer. (Input_objects::archive_start): New function. (Input_objects::archive_stop): New function. (Input_objects::print_symbol_counts): New function. * object.h: Declare Cref and Archive. (Object::get_global_symbol_counts): New function. (Object::do_get_global_symbol_counts): New pure virtual function. (class Sized_relobj): Add defined_count_ field. Update declarations. (class Input_objects): Add cref_ field. Update constructor. Update declarations. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and defined_count_. (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing symbol counts. (Sized_dynobj::do_get_global_symbol_counts): New function. * dynobj.h (class Sized_dynobj): Add fields symbols_ and defined_count_. Update declarations. Define Symbols typedef. * symtab.cc (Symbol_table::add_from_relobj): Add defined parameter. Change all callers. (Symbol_table::add_from_dynobj): Add sympointers and defined parameters. Change all callers. * symtab.h (class Symbol_table): Update declarations. * Makefile.am (CCFILES): Add cref.cc. (HFILES): Add cref.h. * Makefile.in: Rebuild.
2008-07-23 00:08:43 +02:00
// Implement get_global_symbol_counts--implemented by child class.
virtual void
do_get_global_symbol_counts(const Symbol_table*, size_t*, size_t*) const = 0;
virtual const Symbols*
do_get_global_symbols() const = 0;
// Set the number of sections.
void
set_shnum(int shnum)
{ this->shnum_ = shnum; }
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
// Functions used by both Sized_relobj_file and Sized_dynobj.
// Read the section data into a Read_symbols_data object.
template<int size, bool big_endian>
void
read_section_data(elfcpp::Elf_file<size, big_endian, Object>*,
Read_symbols_data*);
// Find the section header with the given NAME. If HDR is non-NULL
// then it is a section header returned from a previous call to this
// function and the next section header with the same name will be
// returned.
template<int size, bool big_endian>
const unsigned char*
find_shdr(const unsigned char* pshdrs, const char* name,
const char* names, section_size_type names_size,
const unsigned char* hdr) const;
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
// Let the child class initialize the xindex object directly.
void
set_xindex(Xindex* xindex)
{
gold_assert(this->xindex_ == NULL);
this->xindex_ = xindex;
}
// If NAME is the name of a special .gnu.warning section, arrange
// for the warning to be issued. SHNDX is the section index.
// Return whether it is a warning section.
bool
handle_gnu_warning_section(const char* name, unsigned int shndx,
Symbol_table*);
* options.h (class General_options): Define split_stack_adjust_size parameter. * object.h (class Object): Add uses_split_stack_ and has_no_split_stack_ fields. Add uses_split_stack and has_no_split_stack accessor functions. Declare handle_split_stack_section. (class Reloc_symbol_changes): Define. (class Sized_relobj): Define Function_offsets. Declare split_stack_adjust, split_stack_adjust_reltype, and find_functions. * object.cc (Object::handle_split_stack_section): New function. (Sized_relobj::do_layout): Call handle_split_stack_section. * dynobj.cc (Sized_dynobj::do_layout): Call handle_split_stack_section. * reloc.cc (Sized_relobj::relocate_sections): Call split_stack_adjust for executable sections in split_stack objects. Pass reloc_map to relocate_section. (Sized_relobj::split_stack_adjust): New function. (Sized_relobj::split_stack_adjust_reltype): New function. (Sized_relobj::find_functions): New function. * target-reloc.h: Include "object.h". (relocate_section): Add reloc_symbol_changes parameter. Change all callers. * target.h (class Target): Add calls_non_split method. Declare do_calls_non_split virtual method. Declare match_view and set_view_to_nop. * target.cc: Include "elfcpp.h". (Target::do_calls_non_split): New function. (Target::match_view): New function. (Target::set_view_to_nop): New function. * gold.cc (queue_middle_tasks): Give an error if mixing split-stack and non-split-stack objects with -r. * i386.cc (Target_i386::relocate_section): Add reloc_symbol_changes parameter. (Target_i386::do_calls_non_split): New function. * x86_64.cc (Target_x86_64::relocate_section): Add reloc_symbol_changes parameter. (Target_x86_64::do_calls_non_split): New function. * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes parameter. * powerpc.cc (Target_powerpc::relocate_section): Add reloc_symbol_changes parameter. * sparc.cc (Target_sparc::relocate_section): Add reloc_symbol_changes parameter. * configure.ac: Call AM_CONDITIONAL for the default target. * configure: Rebuild. * testsuite/Makefile.am (TEST_AS): New variable. (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh. (check_DATA): Add split_i386 and split_x86_64 files. (SPLIT_DEFSYMS): Define. (split_i386_[1234n].o): New targets. (split_i386_[124]): New targets. (split_i386_[1234r].stdout): New targets. (split_x86_64_[1234n].o): New targets. (split_x86_64_[124]): New targets. (split_x86_64_[1234r].stdout): New targets. (MOSTLYCLEANFILES): Add new executables. * testsuite/split_i386.sh: New file. * testsuite/split_x86_64.sh: New file. * testsuite/split_i386_1.s: New file. * testsuite/split_i386_2.s: New file. * testsuite/split_i386_3.s: New file. * testsuite/split_i386_4.s: New file. * testsuite/split_i386_n.s: New file. * testsuite/split_x86_64_1.s: New file. * testsuite/split_x86_64_2.s: New file. * testsuite/split_x86_64_3.s: New file. * testsuite/split_x86_64_4.s: New file. * testsuite/split_x86_64_n.s: New file. * testsuite/testfile.cc (Target_test): Update relocation_section function. * testsuite/Makefile.in: Rebuild.
2009-10-07 00:58:27 +02:00
// If NAME is the name of the special section which indicates that
// this object was compiled with -fsplit-stack, mark it accordingly,
* options.h (class General_options): Define split_stack_adjust_size parameter. * object.h (class Object): Add uses_split_stack_ and has_no_split_stack_ fields. Add uses_split_stack and has_no_split_stack accessor functions. Declare handle_split_stack_section. (class Reloc_symbol_changes): Define. (class Sized_relobj): Define Function_offsets. Declare split_stack_adjust, split_stack_adjust_reltype, and find_functions. * object.cc (Object::handle_split_stack_section): New function. (Sized_relobj::do_layout): Call handle_split_stack_section. * dynobj.cc (Sized_dynobj::do_layout): Call handle_split_stack_section. * reloc.cc (Sized_relobj::relocate_sections): Call split_stack_adjust for executable sections in split_stack objects. Pass reloc_map to relocate_section. (Sized_relobj::split_stack_adjust): New function. (Sized_relobj::split_stack_adjust_reltype): New function. (Sized_relobj::find_functions): New function. * target-reloc.h: Include "object.h". (relocate_section): Add reloc_symbol_changes parameter. Change all callers. * target.h (class Target): Add calls_non_split method. Declare do_calls_non_split virtual method. Declare match_view and set_view_to_nop. * target.cc: Include "elfcpp.h". (Target::do_calls_non_split): New function. (Target::match_view): New function. (Target::set_view_to_nop): New function. * gold.cc (queue_middle_tasks): Give an error if mixing split-stack and non-split-stack objects with -r. * i386.cc (Target_i386::relocate_section): Add reloc_symbol_changes parameter. (Target_i386::do_calls_non_split): New function. * x86_64.cc (Target_x86_64::relocate_section): Add reloc_symbol_changes parameter. (Target_x86_64::do_calls_non_split): New function. * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes parameter. * powerpc.cc (Target_powerpc::relocate_section): Add reloc_symbol_changes parameter. * sparc.cc (Target_sparc::relocate_section): Add reloc_symbol_changes parameter. * configure.ac: Call AM_CONDITIONAL for the default target. * configure: Rebuild. * testsuite/Makefile.am (TEST_AS): New variable. (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh. (check_DATA): Add split_i386 and split_x86_64 files. (SPLIT_DEFSYMS): Define. (split_i386_[1234n].o): New targets. (split_i386_[124]): New targets. (split_i386_[1234r].stdout): New targets. (split_x86_64_[1234n].o): New targets. (split_x86_64_[124]): New targets. (split_x86_64_[1234r].stdout): New targets. (MOSTLYCLEANFILES): Add new executables. * testsuite/split_i386.sh: New file. * testsuite/split_x86_64.sh: New file. * testsuite/split_i386_1.s: New file. * testsuite/split_i386_2.s: New file. * testsuite/split_i386_3.s: New file. * testsuite/split_i386_4.s: New file. * testsuite/split_i386_n.s: New file. * testsuite/split_x86_64_1.s: New file. * testsuite/split_x86_64_2.s: New file. * testsuite/split_x86_64_3.s: New file. * testsuite/split_x86_64_4.s: New file. * testsuite/split_x86_64_n.s: New file. * testsuite/testfile.cc (Target_test): Update relocation_section function. * testsuite/Makefile.in: Rebuild.
2009-10-07 00:58:27 +02:00
// and return true. Otherwise return false.
bool
handle_split_stack_section(const char* name);
// Discard any buffers of decompressed sections. This is done
// at the end of the Add_symbols task.
virtual void
do_discard_decompressed_sections()
{ }
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Return the index of the first incremental relocation for symbol SYMNDX--
// implemented by child class.
virtual unsigned int
do_get_incremental_reloc_base(unsigned int) const
{ gold_unreachable(); }
// Return the number of incremental relocations for symbol SYMNDX--
// implemented by child class.
virtual unsigned int
do_get_incremental_reloc_count(unsigned int) const
{ gold_unreachable(); }
// Return the output view for a section.
virtual unsigned char*
do_get_output_view(unsigned int, section_size_type*) const
{ gold_unreachable(); }
Support compressed debug sections in dynamic object files. This patch adds support for reading compressed debug info in shared objects. It actually simplifies things, by moving the support for compressed sections all the way up to the top-level Object class, eliminating the need for several virtual methods. gold/ * dwp.cc (Sized_relobj_dwo::do_section_contents): Delete. (Sized_relobj_dwo::setup): Build compressed section map. (Sized_relobj_dwo::do_decompressed_section_contents): Delete. * dynobj.cc (Sized_dynobj::base_read_symbols): Build compressed section map. * object.cc (Sized_relobj_file::Sized_relobj_file): Remove compressed_sections_ field. (build_compressed_section_map): Take Object instead of Sized_relobj_file parameter; add decompress_if_needed parameter. (Sized_relobj_file::do_find_special_sections): Store compressed section map in parent Object. (Sized_relobj_file::do_decompressed_section_contents): Move implementation to Object::decompressed_section_contents. (Sized_relobj_file::do_discard_decompressed_sections): Move implementation to Object::discard_decompressed_sections. * object.h (build_compressed_section_map): Declare. (Object::Object): Add compressed_sections_ field. (Object::section_is_compressed): Move implementation here. (Object::decompressed_section_contents): De-virtualize. (Object::discard_decompressed_sections): De-virtualize. (Object::do_section_is_compressed): Delete. (Object::do_decompressed_section_contents): Delete. (Object::set_compressed_sections): New method. (Object::compressed_sections): New method. (Object::compressed_sections_): New data member. (Compressed_section_info, Compressed_section_map): Move to top of file. (Sized_relobj_file::do_section_is_compressed): Delete. (Sized_relobj_file::do_decompressed_section_contents): Delete. (Sized_relobj_file::do_discard_decompressed_sections): Delete. (Sized_relobj_file::compressed_sections_): Move to Object class.
2015-03-22 02:50:11 +01:00
void
set_compressed_sections(Compressed_section_map* compressed_sections)
{ this->compressed_sections_ = compressed_sections; }
Compressed_section_map*
compressed_sections()
{ return this->compressed_sections_; }
private:
// This class may not be copied.
Object(const Object&);
Object& operator=(const Object&);
// Name of object as printed to user.
std::string name_;
// For reading the file.
Input_file* input_file_;
// Offset within the file--0 for an object file, non-0 for an
// archive.
off_t offset_;
// Number of input sections.
unsigned int shnum_;
// Whether this is a dynamic object.
bool is_dynamic_ : 1;
// Whether this object is needed. This is only set for dynamic
// objects, and means that the object defined a symbol which was
// used by a reference from a regular object.
bool is_needed_ : 1;
* options.h (class General_options): Define split_stack_adjust_size parameter. * object.h (class Object): Add uses_split_stack_ and has_no_split_stack_ fields. Add uses_split_stack and has_no_split_stack accessor functions. Declare handle_split_stack_section. (class Reloc_symbol_changes): Define. (class Sized_relobj): Define Function_offsets. Declare split_stack_adjust, split_stack_adjust_reltype, and find_functions. * object.cc (Object::handle_split_stack_section): New function. (Sized_relobj::do_layout): Call handle_split_stack_section. * dynobj.cc (Sized_dynobj::do_layout): Call handle_split_stack_section. * reloc.cc (Sized_relobj::relocate_sections): Call split_stack_adjust for executable sections in split_stack objects. Pass reloc_map to relocate_section. (Sized_relobj::split_stack_adjust): New function. (Sized_relobj::split_stack_adjust_reltype): New function. (Sized_relobj::find_functions): New function. * target-reloc.h: Include "object.h". (relocate_section): Add reloc_symbol_changes parameter. Change all callers. * target.h (class Target): Add calls_non_split method. Declare do_calls_non_split virtual method. Declare match_view and set_view_to_nop. * target.cc: Include "elfcpp.h". (Target::do_calls_non_split): New function. (Target::match_view): New function. (Target::set_view_to_nop): New function. * gold.cc (queue_middle_tasks): Give an error if mixing split-stack and non-split-stack objects with -r. * i386.cc (Target_i386::relocate_section): Add reloc_symbol_changes parameter. (Target_i386::do_calls_non_split): New function. * x86_64.cc (Target_x86_64::relocate_section): Add reloc_symbol_changes parameter. (Target_x86_64::do_calls_non_split): New function. * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes parameter. * powerpc.cc (Target_powerpc::relocate_section): Add reloc_symbol_changes parameter. * sparc.cc (Target_sparc::relocate_section): Add reloc_symbol_changes parameter. * configure.ac: Call AM_CONDITIONAL for the default target. * configure: Rebuild. * testsuite/Makefile.am (TEST_AS): New variable. (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh. (check_DATA): Add split_i386 and split_x86_64 files. (SPLIT_DEFSYMS): Define. (split_i386_[1234n].o): New targets. (split_i386_[124]): New targets. (split_i386_[1234r].stdout): New targets. (split_x86_64_[1234n].o): New targets. (split_x86_64_[124]): New targets. (split_x86_64_[1234r].stdout): New targets. (MOSTLYCLEANFILES): Add new executables. * testsuite/split_i386.sh: New file. * testsuite/split_x86_64.sh: New file. * testsuite/split_i386_1.s: New file. * testsuite/split_i386_2.s: New file. * testsuite/split_i386_3.s: New file. * testsuite/split_i386_4.s: New file. * testsuite/split_i386_n.s: New file. * testsuite/split_x86_64_1.s: New file. * testsuite/split_x86_64_2.s: New file. * testsuite/split_x86_64_3.s: New file. * testsuite/split_x86_64_4.s: New file. * testsuite/split_x86_64_n.s: New file. * testsuite/testfile.cc (Target_test): Update relocation_section function. * testsuite/Makefile.in: Rebuild.
2009-10-07 00:58:27 +02:00
// Whether this object was compiled with -fsplit-stack.
bool uses_split_stack_ : 1;
* options.h (class General_options): Define split_stack_adjust_size parameter. * object.h (class Object): Add uses_split_stack_ and has_no_split_stack_ fields. Add uses_split_stack and has_no_split_stack accessor functions. Declare handle_split_stack_section. (class Reloc_symbol_changes): Define. (class Sized_relobj): Define Function_offsets. Declare split_stack_adjust, split_stack_adjust_reltype, and find_functions. * object.cc (Object::handle_split_stack_section): New function. (Sized_relobj::do_layout): Call handle_split_stack_section. * dynobj.cc (Sized_dynobj::do_layout): Call handle_split_stack_section. * reloc.cc (Sized_relobj::relocate_sections): Call split_stack_adjust for executable sections in split_stack objects. Pass reloc_map to relocate_section. (Sized_relobj::split_stack_adjust): New function. (Sized_relobj::split_stack_adjust_reltype): New function. (Sized_relobj::find_functions): New function. * target-reloc.h: Include "object.h". (relocate_section): Add reloc_symbol_changes parameter. Change all callers. * target.h (class Target): Add calls_non_split method. Declare do_calls_non_split virtual method. Declare match_view and set_view_to_nop. * target.cc: Include "elfcpp.h". (Target::do_calls_non_split): New function. (Target::match_view): New function. (Target::set_view_to_nop): New function. * gold.cc (queue_middle_tasks): Give an error if mixing split-stack and non-split-stack objects with -r. * i386.cc (Target_i386::relocate_section): Add reloc_symbol_changes parameter. (Target_i386::do_calls_non_split): New function. * x86_64.cc (Target_x86_64::relocate_section): Add reloc_symbol_changes parameter. (Target_x86_64::do_calls_non_split): New function. * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes parameter. * powerpc.cc (Target_powerpc::relocate_section): Add reloc_symbol_changes parameter. * sparc.cc (Target_sparc::relocate_section): Add reloc_symbol_changes parameter. * configure.ac: Call AM_CONDITIONAL for the default target. * configure: Rebuild. * testsuite/Makefile.am (TEST_AS): New variable. (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh. (check_DATA): Add split_i386 and split_x86_64 files. (SPLIT_DEFSYMS): Define. (split_i386_[1234n].o): New targets. (split_i386_[124]): New targets. (split_i386_[1234r].stdout): New targets. (split_x86_64_[1234n].o): New targets. (split_x86_64_[124]): New targets. (split_x86_64_[1234r].stdout): New targets. (MOSTLYCLEANFILES): Add new executables. * testsuite/split_i386.sh: New file. * testsuite/split_x86_64.sh: New file. * testsuite/split_i386_1.s: New file. * testsuite/split_i386_2.s: New file. * testsuite/split_i386_3.s: New file. * testsuite/split_i386_4.s: New file. * testsuite/split_i386_n.s: New file. * testsuite/split_x86_64_1.s: New file. * testsuite/split_x86_64_2.s: New file. * testsuite/split_x86_64_3.s: New file. * testsuite/split_x86_64_4.s: New file. * testsuite/split_x86_64_n.s: New file. * testsuite/testfile.cc (Target_test): Update relocation_section function. * testsuite/Makefile.in: Rebuild.
2009-10-07 00:58:27 +02:00
// Whether this object contains any functions compiled with the
// no_split_stack attribute.
bool has_no_split_stack_ : 1;
2009-05-19 Doug Kwan <dougkwan@google.com> * 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.
2009-05-20 00:14:17 +02:00
// True if exclude this object from automatic symbol export.
// This is used only for archive objects.
bool no_export_ : 1;
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
// True if the object was found in a system directory.
bool is_in_system_directory_ : 1;
* dynobj.h (Dynobj::do_dynobj): New function. * incremental-dump.cc (dump_incremental_inputs): Print as_needed flag and soname for shared objects. * incremental.cc (Incremental_inputs::report_object): Make either Incremental_object_entry or Incremental_dynobj_entry; add soname to string table. (Incremental_inputs::report_input_section): Add assertion. (Output_section_incremental_inputs::set_final_data_size): Adjust type of input file entry for shared libraries; adjust size of shared library info entry. (Output_section_incremental_inputs::write_input_files): Write as_needed flag for shared libraries. (Output_section_incremental_inputs::write_info_blocks): Adjust type of input file entry for shared libraries; write soname. (Sized_incr_dynobj::Sized_incr_dynobj): Read as_needed flag and soname from incremental info. * incremental.h (enum Incremental_input_flags): Add INCREMENTAL_INPUT_AS_NEEDED. (Incremental_input_entry::Incremental_input_entry): Initialize new data member. (Incremental_input_entry::set_as_needed): New function. (Incremental_input_entry::as_needed): New function. (Incremental_input_entry::do_dynobj_entry): New function. (Incremental_input_entry::as_needed_): New data member. (Incremental_object_entry::Incremental_object_entry): Don't check for shared library. (Incremental_object_entry::do_type): Likewise. (class Incremental_dynobj_entry): New class. (Incremental_input_entry_reader::as_needed): New function. (Incremental_input_entry_reader::get_soname): New function. (Incremental_input_entry_reader::get_global_symbol_count): Rewrite. (Incremental_input_entry_reader::get_output_symbol_index): Adjust size of shared library info entry. * layout.cc (Layout::finish_dynamic_section): Don't test for incremental link when adding DT_NEEDED entries. * object.h (Object::Object): Initialize new data member. (Object::dynobj): New function. (Object::set_as_needed): New function. (Object::as_needed): New function. (Object::do_dynobj): New function. (Object::as_needed_): New data member.
2011-05-24 23:57:28 +02:00
// True if the object was linked with --as-needed.
bool as_needed_ : 1;
// Many sections for objects with more than SHN_LORESERVE sections.
Xindex* xindex_;
Support compressed debug sections in dynamic object files. This patch adds support for reading compressed debug info in shared objects. It actually simplifies things, by moving the support for compressed sections all the way up to the top-level Object class, eliminating the need for several virtual methods. gold/ * dwp.cc (Sized_relobj_dwo::do_section_contents): Delete. (Sized_relobj_dwo::setup): Build compressed section map. (Sized_relobj_dwo::do_decompressed_section_contents): Delete. * dynobj.cc (Sized_dynobj::base_read_symbols): Build compressed section map. * object.cc (Sized_relobj_file::Sized_relobj_file): Remove compressed_sections_ field. (build_compressed_section_map): Take Object instead of Sized_relobj_file parameter; add decompress_if_needed parameter. (Sized_relobj_file::do_find_special_sections): Store compressed section map in parent Object. (Sized_relobj_file::do_decompressed_section_contents): Move implementation to Object::decompressed_section_contents. (Sized_relobj_file::do_discard_decompressed_sections): Move implementation to Object::discard_decompressed_sections. * object.h (build_compressed_section_map): Declare. (Object::Object): Add compressed_sections_ field. (Object::section_is_compressed): Move implementation here. (Object::decompressed_section_contents): De-virtualize. (Object::discard_decompressed_sections): De-virtualize. (Object::do_section_is_compressed): Delete. (Object::do_decompressed_section_contents): Delete. (Object::set_compressed_sections): New method. (Object::compressed_sections): New method. (Object::compressed_sections_): New data member. (Compressed_section_info, Compressed_section_map): Move to top of file. (Sized_relobj_file::do_section_is_compressed): Delete. (Sized_relobj_file::do_decompressed_section_contents): Delete. (Sized_relobj_file::do_discard_decompressed_sections): Delete. (Sized_relobj_file::compressed_sections_): Move to Object class.
2015-03-22 02:50:11 +01:00
// For compressed debug sections, map section index to uncompressed size
// and contents.
Compressed_section_map* compressed_sections_;
};
// A regular object (ET_REL). This is an abstract base class itself.
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
// The implementation is the template class Sized_relobj_file.
class Relobj : public Object
{
public:
Relobj(const std::string& name, Input_file* input_file, off_t offset = 0)
: Object(name, input_file, false, offset),
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
output_sections_(),
2008-02-06 09:13:50 +01:00
map_to_relocatable_relocs_(NULL),
2007-11-27 07:13:33 +01:00
object_merge_map_(NULL),
2009-08-05 22:51:56 +02:00
relocs_must_follow_section_writes_(false),
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
sd_(NULL),
reloc_counts_(NULL),
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
reloc_bases_(NULL),
first_dyn_reloc_(0),
dyn_reloc_count_(0)
{ }
2009-01-20 Sriraman Tallam <tmsriram@google.com> * 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.
2009-01-28 03:25:33 +01:00
// During garbage collection, the Read_symbols_data pass for
// each object is stored as layout needs to be done after
// reloc processing.
Symbols_data*
get_symbols_data()
{ return this->sd_; }
// Decides which section names have to be included in the worklist
// as roots.
bool
is_section_name_included(const char* name);
2009-01-20 Sriraman Tallam <tmsriram@google.com> * 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.
2009-01-28 03:25:33 +01:00
void
copy_symbols_data(Symbols_data* gc_sd, Read_symbols_data* sd,
unsigned int section_header_size);
void
set_symbols_data(Symbols_data* sd)
{ this->sd_ = sd; }
// During garbage collection, the Read_relocs pass for all objects
// is done before scanning the relocs. In that case, this->rd_ is
// used to store the information from Read_relocs for each object.
// This data is also used to compute the list of relevant sections.
Read_relocs_data*
get_relocs_data()
{ return this->rd_; }
void
set_relocs_data(Read_relocs_data* rd)
{ this->rd_ = rd; }
virtual bool
is_output_section_offset_invalid(unsigned int shndx) const = 0;
// Read the relocs.
void
read_relocs(Read_relocs_data* rd)
{ return this->do_read_relocs(rd); }
2009-01-20 Sriraman Tallam <tmsriram@google.com> * 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.
2009-01-28 03:25:33 +01:00
// Process the relocs, during garbage collection only.
void
gc_process_relocs(Symbol_table* symtab, Layout* layout, Read_relocs_data* rd)
{ return this->do_gc_process_relocs(symtab, layout, rd); }
2009-01-20 Sriraman Tallam <tmsriram@google.com> * 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.
2009-01-28 03:25:33 +01:00
// Scan the relocs and adjust the symbol table.
void
scan_relocs(Symbol_table* symtab, Layout* layout, Read_relocs_data* rd)
{ return this->do_scan_relocs(symtab, layout, rd); }
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
// Return the value of the local symbol whose index is SYMNDX, plus
// ADDEND. ADDEND is passed in so that we can correctly handle the
// section symbol for a merge section.
uint64_t
local_symbol_value(unsigned int symndx, uint64_t addend) const
{ return this->do_local_symbol_value(symndx, addend); }
// Return the PLT offset for a local symbol. It is an error to call
// this if it doesn't have one.
unsigned int
local_plt_offset(unsigned int symndx) const
{ return this->do_local_plt_offset(symndx); }
// Return whether the local symbol SYMNDX has a GOT offset of type
// GOT_TYPE.
bool
local_has_got_offset(unsigned int symndx, unsigned int got_type) const
{ return this->do_local_has_got_offset(symndx, got_type, 0); }
// Return whether the local symbol SYMNDX plus ADDEND has a GOT offset
// of type GOT_TYPE.
bool
local_has_got_offset(unsigned int symndx, unsigned int got_type,
uint64_t addend) const
{ return this->do_local_has_got_offset(symndx, got_type, addend); }
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
// Return the GOT offset of type GOT_TYPE of the local symbol
// SYMNDX. It is an error to call this if the symbol does not have
// a GOT offset of the specified type.
unsigned int
local_got_offset(unsigned int symndx, unsigned int got_type) const
{ return this->do_local_got_offset(symndx, got_type, 0); }
// Return the GOT offset of type GOT_TYPE of the local symbol
// SYMNDX plus ADDEND. It is an error to call this if the symbol
// does not have a GOT offset of the specified type.
unsigned int
local_got_offset(unsigned int symndx, unsigned int got_type,
uint64_t addend) const
{ return this->do_local_got_offset(symndx, got_type, addend); }
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
// Set the GOT offset with type GOT_TYPE of the local symbol SYMNDX
// to GOT_OFFSET.
void
set_local_got_offset(unsigned int symndx, unsigned int got_type,
unsigned int got_offset)
{ this->do_set_local_got_offset(symndx, got_type, got_offset, 0); }
// Set the GOT offset with type GOT_TYPE of the local symbol SYMNDX
// plus ADDEND to GOT_OFFSET.
void
set_local_got_offset(unsigned int symndx, unsigned int got_type,
unsigned int got_offset, uint64_t addend)
{ this->do_set_local_got_offset(symndx, got_type, got_offset, addend); }
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
// Return whether the local symbol SYMNDX is a TLS symbol.
bool
local_is_tls(unsigned int symndx) const
{ return this->do_local_is_tls(symndx); }
// The number of local symbols in the input symbol table.
virtual unsigned int
local_symbol_count() const
{ return this->do_local_symbol_count(); }
* incremental-dump.cc (dump_incremental_inputs): Print local symbol info for each input file. * incremental.cc (Output_section_incremental_inputs::set_final_data_size): Add local symbol info to input file entries in incremental info. (Output_section_incremental_inputs::write_info_blocks): Likewise. (Sized_incr_relobj::Sized_incr_relobj): Initialize new data members. (Sized_incr_relobj::do_add_symbols): Cosmetic change. (Sized_incr_relobj::do_count_local_symbols): Replace stub with implementation. (Sized_incr_relobj::do_finalize_local_symbols): Likewise. (Sized_incr_relobj::do_relocate): Write the local symbols. (Sized_incr_dynobj::do_add_symbols): Cosmetic change. * incremental.h (Incremental_inputs_reader::get_symbol_offset): Adjust size of input file header. (Incremental_inputs_reader::get_local_symbol_offset): New function. (Incremental_inputs_reader::get_local_symbol_count): New function. (Incremental_inputs_reader::get_input_section): Adjust size of input file header. (Incremental_inputs_reader::get_global_symbol_reader): Likewise. (Sized_incr_relobj::This): New typedef. (Sized_incr_relobj::sym_size): New const data member. (Sized_incr_relobj::Local_symbol): New struct. (Sized_incr_relobj::do_output_local_symbol_count): New function. (Sized_incr_relobj::do_local_symbol_offset): New function. (Sized_incr_relobj::local_symbol_count_): New data member. (Sized_incr_relobj::output_local_dynsym_count_): New data member. (Sized_incr_relobj::local_symbol_index_): New data member. (Sized_incr_relobj::local_symbol_offset_): New data member. (Sized_incr_relobj::local_dynsym_offset_): New data member. (Sized_incr_relobj::local_symbols_): New data member. * object.h (Relobj::output_local_symbol_count): New function. (Relobj::local_symbol_offset): New function. (Relobj::do_output_local_symbol_count): New function. (Relobj::do_local_symbol_offset): New function. (Sized_relobj::do_output_local_symbol_count): New function. (Sized_relobj::do_local_symbol_offset): New function.
2011-04-25 22:28:48 +02:00
// The number of local symbols in the output symbol table.
virtual unsigned int
output_local_symbol_count() const
{ return this->do_output_local_symbol_count(); }
// The file offset for local symbols in the output symbol table.
virtual off_t
local_symbol_offset() const
{ return this->do_local_symbol_offset(); }
// Initial local symbol processing: count the number of local symbols
// in the output symbol table and dynamic symbol table; add local symbol
// names to *POOL and *DYNPOOL.
void
count_local_symbols(Stringpool_template<char>* pool,
Stringpool_template<char>* dynpool)
{ return this->do_count_local_symbols(pool, dynpool); }
// Set the values of the local symbols, set the output symbol table
// indexes for the local variables, and set the offset where local
// symbol information will be stored. Returns the new local symbol index.
unsigned int
2009-08-05 22:51:56 +02:00
finalize_local_symbols(unsigned int index, off_t off, Symbol_table* symtab)
{ return this->do_finalize_local_symbols(index, off, symtab); }
// Set the output dynamic symbol table indexes for the local variables.
unsigned int
set_local_dynsym_indexes(unsigned int index)
{ return this->do_set_local_dynsym_indexes(index); }
// Set the offset where local dynamic symbol information will be stored.
unsigned int
set_local_dynsym_offset(off_t off)
{ return this->do_set_local_dynsym_offset(off); }
2006-09-28 00:53:42 +02:00
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
// Record a dynamic relocation against an input section from this object.
void
add_dyn_reloc(unsigned int index)
{
if (this->dyn_reloc_count_ == 0)
this->first_dyn_reloc_ = index;
++this->dyn_reloc_count_;
}
// Return the index of the first dynamic relocation.
unsigned int
first_dyn_reloc() const
{ return this->first_dyn_reloc_; }
// Return the count of dynamic relocations.
unsigned int
dyn_reloc_count() const
{ return this->dyn_reloc_count_; }
// Relocate the input sections and write out the local symbols.
void
relocate(const Symbol_table* symtab, const Layout* layout, Output_file* of)
{ return this->do_relocate(symtab, layout, of); }
// Return whether an input section is being included in the link.
bool
is_section_included(unsigned int shndx) const
{
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
gold_assert(shndx < this->output_sections_.size());
return this->output_sections_[shndx] != NULL;
}
// The output section of the input section with index SHNDX.
2010-01-26 Doug Kwan <dougkwan@google.com> * arm.cc (set): Include. (class Arm_exidx_fixup): Change type of last_input_section_ to const pointer type. (Arm_output_section::Text_section_list): New type. (Arm_output_section::append_text_sections_to_list): New method. (Arm_output_section::fix_exidx_coverage): Ditto. (Arm_relobj::Arm_relobj): Initialize exidx_section_map_. (Arm_relobj::convert_input_section_to_relaxed_section): Use Relobj::set_section_offset() instead of Sized_relobj::invalidate_section_offset(). (Arm_relobj::section_needs_reloc_stub_scanning): Add an extra parameter for section headers. Ignore relocation sections for unallocated sections and EXIDX sections. (Target_arm::fix_exidx_coverage): New method. (Target_arm::output_section_address_less_than): New type. (Arm_exidx_fixup::add_exidx_cantunwind_as_needed): Use index of the linked text section instead of the EXIDX section. (Arm_output_section::create_stub_group): Add an assertion to check that this is not an EXIDX output section. (Arm_output_section::append_text_sections_to_list): New method. (Arm_output_section::fix_exidx_coverage): Ditto. (Arm_relobj::scan_sections_for_stubs): Adjust call to Arm_relobj::section_needs_reloc_stub_scanning. (Target_arm::do_relax): Fix EXIDX output section coverage in the first pass. (Target_arm::fix_exidx_coverage): New method. * object.h (Relobj::set_output_section): New method. (Sized_relobj::invalidate_section_offset): Remove method. (Sized_relobj::do_invalidate_section_offset): Remove method. (Sized_relobj::do_set_section_offset): Handle offset value -1.
2010-01-26 22:29:10 +01:00
// This is only used currently to remove a section from the link in
// relaxation.
void
set_output_section(unsigned int shndx, Output_section* os)
{
gold_assert(shndx < this->output_sections_.size());
this->output_sections_[shndx] = os;
}
// Set the offset of an input section within its output section.
void
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
set_section_offset(unsigned int shndx, uint64_t off)
{ this->do_set_section_offset(shndx, off); }
* layout.cc (Layout::include_section): Refactored check for debug info section. (Layout::add_comdat): Add new parameters. Change type of signature parameter. Add object and shndx to signatures table. (Layout::find_kept_object): New function. * layout.h: Include <cstring>. (Layout::is_debug_info_section): New function. (Layout::add_comdat): Add new parameters. (Layout::find_kept_object): New function. (Layout::Kept_section): New struct. (Layout::Signatures): Change type of map range. * object.cc (Relobj::output_section_address): New function. (Sized_relobj::include_section_group): Add new parameters. Change calls to Layout::add_comdat. Change to build table of kept comdat groups and table mapping discarded sections to kept sections. (Sized_relobj::include_linkonce_section): Likewise. Add new parameter. (Sized_relobj::do_layout): Change calls to include_section_group and include_linkonce_section. (Sized_relobj::do_finalize_local_symbols): Do not set local symbol value to zero when section is discarded. (Sized_relobj::map_to_kept_section): New function. * object.h (Relobj::output_section_address): New function. (Relobj::Comdat_group): New type. (Relobj::find_comdat_group): New function. (Relobj::Comdat_group_table): New type. (Relobj::Kept_comdat_section): New type. (Relobj::Kept_comdat_section_table): New type. (Relobj::add_comdat_group): New function. (Relobj::set_kept_comdat_section): New function. (Relobj::get_kept_comdat_section): New function. (Relobj::comdat_groups_): New field. (Relobj::kept_comdat_sections_): New field. (Symbol_value::input_value): Update comment. (Sized_relobj::map_to_kept_section) New function. (Sized_relobj::include_linkonce_section): Add new parameter. * target-reloc.h (Comdat_behavior): New type. (get_comdat_behavior): New function. (relocate_section): Add code to map a discarded section to the corresponding kept section when applying a relocation.
2008-05-01 03:23:21 +02:00
// Return true if we need to wait for output sections to be written
// before we can apply relocations. This is true if the object has
// any relocations for sections which require special handling, such
// as the exception frame section.
bool
relocs_must_follow_section_writes() const
{ return this->relocs_must_follow_section_writes_; }
Object_merge_map*
get_or_create_merge_map();
Remove empty class Merge_map. 2015-03-02 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> * ehframe.cc (Cie::set_output_offset): Pass in and use a Output_section_data instead of a Merge_map. (Eh_frame::Eh_frame): Don't initialize merge_map_. (Eh_frame::read_cie): Use add_merge_mapping instead of Merge_map::add_mapping. (Eh_frame::read_fde): Ditto. (Eh_frame::set_final_data_size): Use this instead of this->merge_map_. (Eh_frame::do_output_offset): Use merge_output_offset istead of merge_map_->get_output_offset. (Eh_frame::do_is_merge_section_for): Delete. * ehframe.h (Fde::add_mapping): Pass in and use a Output_section_data instead of a Merge_map. (Cie::set_output_offset): Pass in a Output_section_data instead of a Merge_map. (Eh_frame::do_is_merge_section_for): Delete. (Eh_frame::merge_map_): Delete. * merge.cc (Object_merge_map::get_or_make_input_merge_map): Pass in and use a Output_section_data instead of a Merge_map. (Object_merge_map::add_mapping): Ditto. (Object_merge_map::get_output_offset): Remove the merge_map argument. (Object_merge_map::is_merge_section_for): Pass in and use a Output_section_data instead of a Merge_map. (Merge_map): Delete. (Output_merge_base::do_output_offset): Use merge_output_offset instead of merge_map_.get_output_offset. (Output_merge_base::do_is_merge_section_for): Delete. (Output_merge_data::do_add_input_section): Use object->add_merge_mapping instead of add_mapping. (Output_merge_string<Char_type>::finalize_merged_data): Ditto. * merge.h (Merge_map): Delete forward declaration. (Object_merge_map::add_mapping): Pass in and use a Output_section_data instead of a Merge_map. (Object_merge_map::get_output_offset): Remove the merge_map argument. (Object_merge_map::is_merge_section_for): Pass in and use a Output_section_data instead of a Merge_map. (Input_merge_map::Object_merge_map::merge_map): Replace with output_data. (Object_merge_map::get_or_make_input_merge_map): Pass in and use a Output_section_data instead of a Merge_map. (Merge_map): Delete. (Output_merge_base::Output_merge_base): Don't initialize merge_map_. (Output_merge_base::do_is_merge_section_for): Delete. (Output_merge_base::add_mapping): Delete. (Output_merge_base::merge_map_): Delete. * object.cc (Relobj::initialize_input_to_output_map): New. (Relobj::initialize_input_to_output_map): New. (Relobj::merge_output_offset): New. (Relobj::is_merge_section_for): New. (Relobj::initialize_input_to_output_map): Instantiate for 32 and 64 bits. * object.h (Relobj::merge_map): Delete. (initialize_input_to_output_map): New. (set_merge_map): Delete. (add_merge_mapping): New. (merge_output_offset): New. (is_merge_section_for): New. * output.cc (Output_section::Input_section::is_merge_section_for): Use object->is_merge_section_for. * output.h (Output_section_data::is_merge_section_for): Delete. (Output_section_data::do_is_merge_section_for): Delete. * reloc.cc (Merged_symbol_value<size>::initialize_input_to_output_map): Use object->initialize_input_to_output_map. (Merged_symbol_value<size>::value_from_output_section): Use object->merge_output_offset.
2015-03-05 00:10:18 +01:00
template<int size>
void
initialize_input_to_output_map(unsigned int shndx,
typename elfcpp::Elf_types<size>::Elf_Addr starting_address,
Unordered_map<section_offset_type,
typename elfcpp::Elf_types<size>::Elf_Addr>* output_address) const;
2007-11-27 07:13:33 +01:00
void
Remove empty class Merge_map. 2015-03-02 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> * ehframe.cc (Cie::set_output_offset): Pass in and use a Output_section_data instead of a Merge_map. (Eh_frame::Eh_frame): Don't initialize merge_map_. (Eh_frame::read_cie): Use add_merge_mapping instead of Merge_map::add_mapping. (Eh_frame::read_fde): Ditto. (Eh_frame::set_final_data_size): Use this instead of this->merge_map_. (Eh_frame::do_output_offset): Use merge_output_offset istead of merge_map_->get_output_offset. (Eh_frame::do_is_merge_section_for): Delete. * ehframe.h (Fde::add_mapping): Pass in and use a Output_section_data instead of a Merge_map. (Cie::set_output_offset): Pass in a Output_section_data instead of a Merge_map. (Eh_frame::do_is_merge_section_for): Delete. (Eh_frame::merge_map_): Delete. * merge.cc (Object_merge_map::get_or_make_input_merge_map): Pass in and use a Output_section_data instead of a Merge_map. (Object_merge_map::add_mapping): Ditto. (Object_merge_map::get_output_offset): Remove the merge_map argument. (Object_merge_map::is_merge_section_for): Pass in and use a Output_section_data instead of a Merge_map. (Merge_map): Delete. (Output_merge_base::do_output_offset): Use merge_output_offset instead of merge_map_.get_output_offset. (Output_merge_base::do_is_merge_section_for): Delete. (Output_merge_data::do_add_input_section): Use object->add_merge_mapping instead of add_mapping. (Output_merge_string<Char_type>::finalize_merged_data): Ditto. * merge.h (Merge_map): Delete forward declaration. (Object_merge_map::add_mapping): Pass in and use a Output_section_data instead of a Merge_map. (Object_merge_map::get_output_offset): Remove the merge_map argument. (Object_merge_map::is_merge_section_for): Pass in and use a Output_section_data instead of a Merge_map. (Input_merge_map::Object_merge_map::merge_map): Replace with output_data. (Object_merge_map::get_or_make_input_merge_map): Pass in and use a Output_section_data instead of a Merge_map. (Merge_map): Delete. (Output_merge_base::Output_merge_base): Don't initialize merge_map_. (Output_merge_base::do_is_merge_section_for): Delete. (Output_merge_base::add_mapping): Delete. (Output_merge_base::merge_map_): Delete. * object.cc (Relobj::initialize_input_to_output_map): New. (Relobj::initialize_input_to_output_map): New. (Relobj::merge_output_offset): New. (Relobj::is_merge_section_for): New. (Relobj::initialize_input_to_output_map): Instantiate for 32 and 64 bits. * object.h (Relobj::merge_map): Delete. (initialize_input_to_output_map): New. (set_merge_map): Delete. (add_merge_mapping): New. (merge_output_offset): New. (is_merge_section_for): New. * output.cc (Output_section::Input_section::is_merge_section_for): Use object->is_merge_section_for. * output.h (Output_section_data::is_merge_section_for): Delete. (Output_section_data::do_is_merge_section_for): Delete. * reloc.cc (Merged_symbol_value<size>::initialize_input_to_output_map): Use object->initialize_input_to_output_map. (Merged_symbol_value<size>::value_from_output_section): Use object->merge_output_offset.
2015-03-05 00:10:18 +01:00
add_merge_mapping(Output_section_data *output_data,
unsigned int shndx, section_offset_type offset,
section_size_type length,
section_offset_type output_offset);
bool
merge_output_offset(unsigned int shndx, section_offset_type offset,
section_offset_type *poutput) const;
const Output_section_data*
find_merge_section(unsigned int shndx) const;
2007-11-27 07:13:33 +01:00
2008-02-06 09:13:50 +01:00
// Record the relocatable reloc info for an input reloc section.
void
set_relocatable_relocs(unsigned int reloc_shndx, Relocatable_relocs* rr)
{
gold_assert(reloc_shndx < this->shnum());
(*this->map_to_relocatable_relocs_)[reloc_shndx] = rr;
}
// Get the relocatable reloc info for an input reloc section.
Relocatable_relocs*
relocatable_relocs(unsigned int reloc_shndx)
{
gold_assert(reloc_shndx < this->shnum());
return (*this->map_to_relocatable_relocs_)[reloc_shndx];
}
// Layout sections whose layout was deferred while waiting for
// input files from a plugin.
void
layout_deferred_sections(Layout* layout)
{ this->do_layout_deferred_sections(layout); }
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Return the index of the first incremental relocation for symbol SYMNDX.
virtual unsigned int
do_get_incremental_reloc_base(unsigned int symndx) const
{ return this->reloc_bases_[symndx]; }
// Return the number of incremental relocations for symbol SYMNDX.
virtual unsigned int
do_get_incremental_reloc_count(unsigned int symndx) const
{ return this->reloc_counts_[symndx]; }
// Return the word size of the object file.
int
elfsize() const
{ return this->do_elfsize(); }
// Return TRUE if this is a big-endian object file.
bool
is_big_endian() const
{ return this->do_is_big_endian(); }
protected:
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
// The output section to be used for each input section, indexed by
// the input section number. The output section is NULL if the
// input section is to be discarded.
typedef std::vector<Output_section*> Output_sections;
* layout.cc (Layout::include_section): Refactored check for debug info section. (Layout::add_comdat): Add new parameters. Change type of signature parameter. Add object and shndx to signatures table. (Layout::find_kept_object): New function. * layout.h: Include <cstring>. (Layout::is_debug_info_section): New function. (Layout::add_comdat): Add new parameters. (Layout::find_kept_object): New function. (Layout::Kept_section): New struct. (Layout::Signatures): Change type of map range. * object.cc (Relobj::output_section_address): New function. (Sized_relobj::include_section_group): Add new parameters. Change calls to Layout::add_comdat. Change to build table of kept comdat groups and table mapping discarded sections to kept sections. (Sized_relobj::include_linkonce_section): Likewise. Add new parameter. (Sized_relobj::do_layout): Change calls to include_section_group and include_linkonce_section. (Sized_relobj::do_finalize_local_symbols): Do not set local symbol value to zero when section is discarded. (Sized_relobj::map_to_kept_section): New function. * object.h (Relobj::output_section_address): New function. (Relobj::Comdat_group): New type. (Relobj::find_comdat_group): New function. (Relobj::Comdat_group_table): New type. (Relobj::Kept_comdat_section): New type. (Relobj::Kept_comdat_section_table): New type. (Relobj::add_comdat_group): New function. (Relobj::set_kept_comdat_section): New function. (Relobj::get_kept_comdat_section): New function. (Relobj::comdat_groups_): New field. (Relobj::kept_comdat_sections_): New field. (Symbol_value::input_value): Update comment. (Sized_relobj::map_to_kept_section) New function. (Sized_relobj::include_linkonce_section): Add new parameter. * target-reloc.h (Comdat_behavior): New type. (get_comdat_behavior): New function. (relocate_section): Add code to map a discarded section to the corresponding kept section when applying a relocation.
2008-05-01 03:23:21 +02:00
// Read the relocs--implemented by child class.
virtual void
do_read_relocs(Read_relocs_data*) = 0;
2009-01-20 Sriraman Tallam <tmsriram@google.com> * 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.
2009-01-28 03:25:33 +01:00
// Process the relocs--implemented by child class.
virtual void
do_gc_process_relocs(Symbol_table*, Layout*, Read_relocs_data*) = 0;
2009-01-20 Sriraman Tallam <tmsriram@google.com> * 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.
2009-01-28 03:25:33 +01:00
// Scan the relocs--implemented by child class.
virtual void
do_scan_relocs(Symbol_table*, Layout*, Read_relocs_data*) = 0;
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
// Return the value of a local symbol.
virtual uint64_t
do_local_symbol_value(unsigned int symndx, uint64_t addend) const = 0;
// Return the PLT offset of a local symbol.
virtual unsigned int
do_local_plt_offset(unsigned int symndx) const = 0;
// Return whether a local symbol plus addend has a GOT offset
// of a given type.
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
virtual bool
do_local_has_got_offset(unsigned int symndx,
unsigned int got_type, uint64_t addend) const = 0;
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
// Return the GOT offset of a given type of a local symbol plus addend.
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
virtual unsigned int
do_local_got_offset(unsigned int symndx, unsigned int got_type,
uint64_t addend) const = 0;
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
// Set the GOT offset with a given type for a local symbol plus addend.
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
virtual void
do_set_local_got_offset(unsigned int symndx, unsigned int got_type,
unsigned int got_offset, uint64_t addend) = 0;
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
// Return whether local symbol SYMNDX is a TLS symbol.
virtual bool
do_local_is_tls(unsigned int symndx) const = 0;
// Return the number of local symbols--implemented by child class.
virtual unsigned int
do_local_symbol_count() const = 0;
* incremental-dump.cc (dump_incremental_inputs): Print local symbol info for each input file. * incremental.cc (Output_section_incremental_inputs::set_final_data_size): Add local symbol info to input file entries in incremental info. (Output_section_incremental_inputs::write_info_blocks): Likewise. (Sized_incr_relobj::Sized_incr_relobj): Initialize new data members. (Sized_incr_relobj::do_add_symbols): Cosmetic change. (Sized_incr_relobj::do_count_local_symbols): Replace stub with implementation. (Sized_incr_relobj::do_finalize_local_symbols): Likewise. (Sized_incr_relobj::do_relocate): Write the local symbols. (Sized_incr_dynobj::do_add_symbols): Cosmetic change. * incremental.h (Incremental_inputs_reader::get_symbol_offset): Adjust size of input file header. (Incremental_inputs_reader::get_local_symbol_offset): New function. (Incremental_inputs_reader::get_local_symbol_count): New function. (Incremental_inputs_reader::get_input_section): Adjust size of input file header. (Incremental_inputs_reader::get_global_symbol_reader): Likewise. (Sized_incr_relobj::This): New typedef. (Sized_incr_relobj::sym_size): New const data member. (Sized_incr_relobj::Local_symbol): New struct. (Sized_incr_relobj::do_output_local_symbol_count): New function. (Sized_incr_relobj::do_local_symbol_offset): New function. (Sized_incr_relobj::local_symbol_count_): New data member. (Sized_incr_relobj::output_local_dynsym_count_): New data member. (Sized_incr_relobj::local_symbol_index_): New data member. (Sized_incr_relobj::local_symbol_offset_): New data member. (Sized_incr_relobj::local_dynsym_offset_): New data member. (Sized_incr_relobj::local_symbols_): New data member. * object.h (Relobj::output_local_symbol_count): New function. (Relobj::local_symbol_offset): New function. (Relobj::do_output_local_symbol_count): New function. (Relobj::do_local_symbol_offset): New function. (Sized_relobj::do_output_local_symbol_count): New function. (Sized_relobj::do_local_symbol_offset): New function.
2011-04-25 22:28:48 +02:00
// Return the number of output local symbols--implemented by child class.
virtual unsigned int
do_output_local_symbol_count() const = 0;
// Return the file offset for local symbols--implemented by child class.
virtual off_t
do_local_symbol_offset() const = 0;
// Count local symbols--implemented by child class.
virtual void
do_count_local_symbols(Stringpool_template<char>*,
2008-02-06 09:13:50 +01:00
Stringpool_template<char>*) = 0;
2006-09-28 00:53:42 +02:00
2008-02-06 09:13:50 +01:00
// Finalize the local symbols. Set the output symbol table indexes
// for the local variables, and set the offset where local symbol
// information will be stored.
virtual unsigned int
2009-08-05 22:51:56 +02:00
do_finalize_local_symbols(unsigned int, off_t, Symbol_table*) = 0;
// Set the output dynamic symbol table indexes for the local variables.
virtual unsigned int
do_set_local_dynsym_indexes(unsigned int) = 0;
// Set the offset where local dynamic symbol information will be stored.
virtual unsigned int
do_set_local_dynsym_offset(off_t) = 0;
// Relocate the input sections and write out the local
// symbols--implemented by child class.
virtual void
do_relocate(const Symbol_table* symtab, const Layout*, Output_file* of) = 0;
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
// Set the offset of a section--implemented by child class.
virtual void
do_set_section_offset(unsigned int shndx, uint64_t off) = 0;
* layout.cc (Layout::include_section): Refactored check for debug info section. (Layout::add_comdat): Add new parameters. Change type of signature parameter. Add object and shndx to signatures table. (Layout::find_kept_object): New function. * layout.h: Include <cstring>. (Layout::is_debug_info_section): New function. (Layout::add_comdat): Add new parameters. (Layout::find_kept_object): New function. (Layout::Kept_section): New struct. (Layout::Signatures): Change type of map range. * object.cc (Relobj::output_section_address): New function. (Sized_relobj::include_section_group): Add new parameters. Change calls to Layout::add_comdat. Change to build table of kept comdat groups and table mapping discarded sections to kept sections. (Sized_relobj::include_linkonce_section): Likewise. Add new parameter. (Sized_relobj::do_layout): Change calls to include_section_group and include_linkonce_section. (Sized_relobj::do_finalize_local_symbols): Do not set local symbol value to zero when section is discarded. (Sized_relobj::map_to_kept_section): New function. * object.h (Relobj::output_section_address): New function. (Relobj::Comdat_group): New type. (Relobj::find_comdat_group): New function. (Relobj::Comdat_group_table): New type. (Relobj::Kept_comdat_section): New type. (Relobj::Kept_comdat_section_table): New type. (Relobj::add_comdat_group): New function. (Relobj::set_kept_comdat_section): New function. (Relobj::get_kept_comdat_section): New function. (Relobj::comdat_groups_): New field. (Relobj::kept_comdat_sections_): New field. (Symbol_value::input_value): Update comment. (Sized_relobj::map_to_kept_section) New function. (Sized_relobj::include_linkonce_section): Add new parameter. * target-reloc.h (Comdat_behavior): New type. (get_comdat_behavior): New function. (relocate_section): Add code to map a discarded section to the corresponding kept section when applying a relocation.
2008-05-01 03:23:21 +02:00
// Layout sections whose layout was deferred while waiting for
// input files from a plugin--implemented by child class.
virtual void
do_layout_deferred_sections(Layout*) = 0;
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Given a section index, return the corresponding Output_section.
// The return value will be NULL if the section is not included in
// the link.
Output_section*
do_output_section(unsigned int shndx) const
{
gold_assert(shndx < this->output_sections_.size());
return this->output_sections_[shndx];
}
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
// Return the vector mapping input sections to output sections.
Output_sections&
output_sections()
{ return this->output_sections_; }
* layout.cc (Layout::include_section): Refactored check for debug info section. (Layout::add_comdat): Add new parameters. Change type of signature parameter. Add object and shndx to signatures table. (Layout::find_kept_object): New function. * layout.h: Include <cstring>. (Layout::is_debug_info_section): New function. (Layout::add_comdat): Add new parameters. (Layout::find_kept_object): New function. (Layout::Kept_section): New struct. (Layout::Signatures): Change type of map range. * object.cc (Relobj::output_section_address): New function. (Sized_relobj::include_section_group): Add new parameters. Change calls to Layout::add_comdat. Change to build table of kept comdat groups and table mapping discarded sections to kept sections. (Sized_relobj::include_linkonce_section): Likewise. Add new parameter. (Sized_relobj::do_layout): Change calls to include_section_group and include_linkonce_section. (Sized_relobj::do_finalize_local_symbols): Do not set local symbol value to zero when section is discarded. (Sized_relobj::map_to_kept_section): New function. * object.h (Relobj::output_section_address): New function. (Relobj::Comdat_group): New type. (Relobj::find_comdat_group): New function. (Relobj::Comdat_group_table): New type. (Relobj::Kept_comdat_section): New type. (Relobj::Kept_comdat_section_table): New type. (Relobj::add_comdat_group): New function. (Relobj::set_kept_comdat_section): New function. (Relobj::get_kept_comdat_section): New function. (Relobj::comdat_groups_): New field. (Relobj::kept_comdat_sections_): New field. (Symbol_value::input_value): Update comment. (Sized_relobj::map_to_kept_section) New function. (Sized_relobj::include_linkonce_section): Add new parameter. * target-reloc.h (Comdat_behavior): New type. (get_comdat_behavior): New function. (relocate_section): Add code to map a discarded section to the corresponding kept section when applying a relocation.
2008-05-01 03:23:21 +02:00
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
const Output_sections&
output_sections() const
{ return this->output_sections_; }
* layout.cc (Layout::include_section): Refactored check for debug info section. (Layout::add_comdat): Add new parameters. Change type of signature parameter. Add object and shndx to signatures table. (Layout::find_kept_object): New function. * layout.h: Include <cstring>. (Layout::is_debug_info_section): New function. (Layout::add_comdat): Add new parameters. (Layout::find_kept_object): New function. (Layout::Kept_section): New struct. (Layout::Signatures): Change type of map range. * object.cc (Relobj::output_section_address): New function. (Sized_relobj::include_section_group): Add new parameters. Change calls to Layout::add_comdat. Change to build table of kept comdat groups and table mapping discarded sections to kept sections. (Sized_relobj::include_linkonce_section): Likewise. Add new parameter. (Sized_relobj::do_layout): Change calls to include_section_group and include_linkonce_section. (Sized_relobj::do_finalize_local_symbols): Do not set local symbol value to zero when section is discarded. (Sized_relobj::map_to_kept_section): New function. * object.h (Relobj::output_section_address): New function. (Relobj::Comdat_group): New type. (Relobj::find_comdat_group): New function. (Relobj::Comdat_group_table): New type. (Relobj::Kept_comdat_section): New type. (Relobj::Kept_comdat_section_table): New type. (Relobj::add_comdat_group): New function. (Relobj::set_kept_comdat_section): New function. (Relobj::get_kept_comdat_section): New function. (Relobj::comdat_groups_): New field. (Relobj::kept_comdat_sections_): New field. (Symbol_value::input_value): Update comment. (Sized_relobj::map_to_kept_section) New function. (Sized_relobj::include_linkonce_section): Add new parameter. * target-reloc.h (Comdat_behavior): New type. (get_comdat_behavior): New function. (relocate_section): Add code to map a discarded section to the corresponding kept section when applying a relocation.
2008-05-01 03:23:21 +02:00
2008-02-06 09:13:50 +01:00
// Set the size of the relocatable relocs array.
void
size_relocatable_relocs()
{
this->map_to_relocatable_relocs_ =
new std::vector<Relocatable_relocs*>(this->shnum());
}
// Record that we must wait for the output sections to be written
// before applying relocations.
void
set_relocs_must_follow_section_writes()
{ this->relocs_must_follow_section_writes_ = true; }
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Allocate the array for counting incremental relocations.
void
allocate_incremental_reloc_counts()
{
unsigned int nsyms = this->do_get_global_symbols()->size();
this->reloc_counts_ = new unsigned int[nsyms];
gold_assert(this->reloc_counts_ != NULL);
memset(this->reloc_counts_, 0, nsyms * sizeof(unsigned int));
}
// Record a relocation in this object referencing global symbol SYMNDX.
// Used for tracking incremental link information.
void
count_incremental_reloc(unsigned int symndx)
{
unsigned int nsyms = this->do_get_global_symbols()->size();
gold_assert(symndx < nsyms);
gold_assert(this->reloc_counts_ != NULL);
++this->reloc_counts_[symndx];
}
// Finalize the incremental relocation information.
void
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
finalize_incremental_relocs(Layout* layout, bool clear_counts);
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Return the index of the next relocation to be written for global symbol
// SYMNDX. Only valid after finalize_incremental_relocs() has been called.
unsigned int
next_incremental_reloc_index(unsigned int symndx)
{
unsigned int nsyms = this->do_get_global_symbols()->size();
gold_assert(this->reloc_counts_ != NULL);
gold_assert(this->reloc_bases_ != NULL);
gold_assert(symndx < nsyms);
unsigned int counter = this->reloc_counts_[symndx]++;
return this->reloc_bases_[symndx] + counter;
}
// Return the word size of the object file--
// implemented by child class.
virtual int
do_elfsize() const = 0;
// Return TRUE if this is a big-endian object file--
// implemented by child class.
virtual bool
do_is_big_endian() const = 0;
2006-08-05 01:10:59 +02:00
private:
// Mapping from input sections to output section.
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
Output_sections output_sections_;
2008-02-06 09:13:50 +01:00
// Mapping from input section index to the information recorded for
// the relocations. This is only used for a relocatable link.
std::vector<Relocatable_relocs*>* map_to_relocatable_relocs_;
2007-11-27 07:13:33 +01:00
// Mappings for merge sections. This is managed by the code in the
// Merge_map class.
Object_merge_map* object_merge_map_;
// Whether we need to wait for output sections to be written before
// we can apply relocations.
bool relocs_must_follow_section_writes_;
2009-01-20 Sriraman Tallam <tmsriram@google.com> * 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.
2009-01-28 03:25:33 +01:00
// Used to store the relocs data computed by the Read_relocs pass.
// Used during garbage collection of unused sections.
Read_relocs_data* rd_;
// Used to store the symbols data computed by the Read_symbols pass.
// Again used during garbage collection when laying out referenced
// sections.
gold::Symbols_data* sd_;
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Per-symbol counts of relocations, for incremental links.
unsigned int* reloc_counts_;
// Per-symbol base indexes of relocations, for incremental links.
unsigned int* reloc_bases_;
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
// Index of the first dynamic relocation for this object.
unsigned int first_dyn_reloc_;
// Count of dynamic relocations for this object.
unsigned int dyn_reloc_count_;
2006-08-05 01:10:59 +02:00
};
// This class is used to handle relocations against a section symbol
// in an SHF_MERGE section. For such a symbol, we need to know the
// addend of the relocation before we can determine the final value.
// The addend gives us the location in the input section, and we can
// determine how it is mapped to the output section. For a
// non-section symbol, we apply the addend to the final value of the
// symbol; that is done in finalize_local_symbols, and does not use
// this class.
template<int size>
class Merged_symbol_value
{
public:
typedef typename elfcpp::Elf_types<size>::Elf_Addr Value;
// We use a hash table to map offsets in the input section to output
// addresses.
typedef Unordered_map<section_offset_type, Value> Output_addresses;
Merged_symbol_value(Value input_value, Value output_start_address)
: input_value_(input_value), output_start_address_(output_start_address),
output_addresses_()
{ }
// Initialize the hash table.
void
initialize_input_to_output_map(const Relobj*, unsigned int input_shndx);
// Release the hash table to save space.
void
free_input_to_output_map()
{ this->output_addresses_.clear(); }
// Get the output value corresponding to an addend. The object and
// input section index are passed in because the caller will have
// them; otherwise we could store them here.
Value
value(const Relobj* object, unsigned int input_shndx, Value addend) const
{
// This is a relocation against a section symbol. ADDEND is the
// offset in the section. The result should be the start of some
// merge area. If the object file wants something else, it should
// use a regular symbol rather than a section symbol.
// Unfortunately, PR 6658 shows a case in which the object file
// refers to the section symbol, but uses a negative ADDEND to
// compensate for a PC relative reloc. We can't handle the
// general case. However, we can handle the special case of a
// negative addend, by assuming that it refers to the start of the
// section. Of course, that means that we have to guess when
// ADDEND is negative. It is normal to see a 32-bit value here
// even when the template parameter size is 64, as 64-bit object
// file formats have 32-bit relocations. We know this is a merge
// section, so we know it has to fit into memory. So we assume
// that we won't see a value larger than a large 32-bit unsigned
// value. This will break objects with very very large merge
// sections; they probably break in other ways anyhow.
Value input_offset = this->input_value_;
if (addend < 0xffffff00)
{
input_offset += addend;
addend = 0;
}
typename Output_addresses::const_iterator p =
this->output_addresses_.find(input_offset);
if (p != this->output_addresses_.end())
return p->second + addend;
return (this->value_from_output_section(object, input_shndx, input_offset)
+ addend);
}
private:
// Get the output value for an input offset if we couldn't find it
// in the hash table.
Value
value_from_output_section(const Relobj*, unsigned int input_shndx,
Value input_offset) const;
// The value of the section symbol in the input file. This is
// normally zero, but could in principle be something else.
Value input_value_;
// The start address of this merged section in the output file.
Value output_start_address_;
// A hash table which maps offsets in the input section to output
// addresses. This only maps specific offsets, not all offsets.
Output_addresses output_addresses_;
};
2007-05-16 19:42:48 +02:00
// This POD class is holds the value of a symbol. This is used for
// local symbols, and for all symbols during relocation processing.
// For special sections, such as SHF_MERGE sections, this calls a
// function to get the final symbol value.
2007-05-16 19:42:48 +02:00
template<int size>
class Symbol_value
{
public:
typedef typename elfcpp::Elf_types<size>::Elf_Addr Value;
Symbol_value()
: output_symtab_index_(0), output_dynsym_index_(-1U), input_shndx_(0),
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
is_ordinary_shndx_(false), is_section_symbol_(false),
PR 10893 * 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.
2010-08-20 00:50:16 +02:00
is_tls_symbol_(false), is_ifunc_symbol_(false), has_output_value_(true)
{ this->u_.value = 0; }
2007-05-16 19:42:48 +02:00
2010-09-08 Doug Kwan <dougkwan@google.com> * arm.cc (Arm_exidx_cantunwind::do_print_to_mapfile): New method. (Arm_relobj::do_relocate_sections): Add new parameter for output file to match the parent. (Target_arm::scan_reloc_section_for_stubs): Use would-be final values of local symbols instead of input values. Update code to track changes in gold::relocate_section. * object.cc (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. (Sized_relobj::do_finalize_local_symbols): Move code from loop body into private version of Sized_relobj::compute_final_local_value. Call the inline method. * object.h (Symbol_value::Symbol_value): Define destructor. Free merged symbol value if there is one. (Symbol_value::has_output_value): New method defintiion. (Sized_relobj::Compute_final_local_value_status): New enum type. (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. * Makefile.am (check_SCRIPTS): Add arm_branch_out_of_range.sh and arm_cortex_a8.sh. (thumb_bl_out_of_range_local, arm_cortex_a8_b_cond, arm_cortex_a8_bl, arm_cortex_a8_blx, arm_cortex_a8_local, arm_corte_a8_local_reloc): New tests. * Makefile.in: Regenerate. * testsuite/arm_bl_out_of_range.s: Update test. * testsuite/thumb_bl_out_of_range.s: Ditto. * testsuite/thumb_blx_out_of_range.s: Ditto. * testsuite/arm_branch_out_of_range.sh: New file. * testsuite/arm_cortex_a8.sh: Ditto. * testsuite/arm_cortex_a8_b.s: Ditto. * testsuite/arm_cortex_a8_b_cond.s: Ditto. * testsuite/arm_cortex_a8_b_local.s: Ditto. * testsuite/arm_cortex_a8_bl.s: Ditto. * testsuite/arm_cortex_a8_blx.s: Ditto. * testsuite/arm_cortex_a8_local.s: Ditto. * testsuite/arm_cortex_a8_local_reloc.s: Ditto. * testsuite/thumb_bl_out_of_range_local.s: Ditto.
2010-09-09 01:54:51 +02:00
~Symbol_value()
{
if (!this->has_output_value_)
delete this->u_.merged_symbol_value;
}
2007-05-16 19:42:48 +02:00
// Get the value of this symbol. OBJECT is the object in which this
// symbol is defined, and ADDEND is an addend to add to the value.
template<bool big_endian>
Value
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
value(const Sized_relobj_file<size, big_endian>* object, Value addend) const
2007-05-16 19:42:48 +02:00
{
if (this->has_output_value_)
return this->u_.value + addend;
else
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
{
gold_assert(this->is_ordinary_shndx_);
return this->u_.merged_symbol_value->value(object, this->input_shndx_,
addend);
}
2007-05-16 19:42:48 +02:00
}
// Set the value of this symbol in the output symbol table.
void
set_output_value(Value value)
{ this->u_.value = value; }
// For a section symbol in a merged section, we need more
// information.
void
set_merged_symbol_value(Merged_symbol_value<size>* msv)
2007-05-16 19:42:48 +02:00
{
gold_assert(this->is_section_symbol_);
this->has_output_value_ = false;
this->u_.merged_symbol_value = msv;
2007-05-16 19:42:48 +02:00
}
// Initialize the input to output map for a section symbol in a
// merged section. We also initialize the value of a non-section
// symbol in a merged section.
2007-05-16 19:42:48 +02:00
void
initialize_input_to_output_map(const Relobj* object)
2007-05-16 19:42:48 +02:00
{
if (!this->has_output_value_)
{
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
gold_assert(this->is_section_symbol_ && this->is_ordinary_shndx_);
Merged_symbol_value<size>* msv = this->u_.merged_symbol_value;
msv->initialize_input_to_output_map(object, this->input_shndx_);
}
2007-05-16 19:42:48 +02:00
}
// Free the input to output map for a section symbol in a merged
// section.
void
free_input_to_output_map()
{
if (!this->has_output_value_)
this->u_.merged_symbol_value->free_input_to_output_map();
}
// Set the value of the symbol from the input file. This is only
// called by count_local_symbols, to communicate the value to
// finalize_local_symbols.
void
set_input_value(Value value)
{ this->u_.value = value; }
// Return the input value. This is only called by
* layout.cc (Layout::include_section): Refactored check for debug info section. (Layout::add_comdat): Add new parameters. Change type of signature parameter. Add object and shndx to signatures table. (Layout::find_kept_object): New function. * layout.h: Include <cstring>. (Layout::is_debug_info_section): New function. (Layout::add_comdat): Add new parameters. (Layout::find_kept_object): New function. (Layout::Kept_section): New struct. (Layout::Signatures): Change type of map range. * object.cc (Relobj::output_section_address): New function. (Sized_relobj::include_section_group): Add new parameters. Change calls to Layout::add_comdat. Change to build table of kept comdat groups and table mapping discarded sections to kept sections. (Sized_relobj::include_linkonce_section): Likewise. Add new parameter. (Sized_relobj::do_layout): Change calls to include_section_group and include_linkonce_section. (Sized_relobj::do_finalize_local_symbols): Do not set local symbol value to zero when section is discarded. (Sized_relobj::map_to_kept_section): New function. * object.h (Relobj::output_section_address): New function. (Relobj::Comdat_group): New type. (Relobj::find_comdat_group): New function. (Relobj::Comdat_group_table): New type. (Relobj::Kept_comdat_section): New type. (Relobj::Kept_comdat_section_table): New type. (Relobj::add_comdat_group): New function. (Relobj::set_kept_comdat_section): New function. (Relobj::get_kept_comdat_section): New function. (Relobj::comdat_groups_): New field. (Relobj::kept_comdat_sections_): New field. (Symbol_value::input_value): Update comment. (Sized_relobj::map_to_kept_section) New function. (Sized_relobj::include_linkonce_section): Add new parameter. * target-reloc.h (Comdat_behavior): New type. (get_comdat_behavior): New function. (relocate_section): Add code to map a discarded section to the corresponding kept section when applying a relocation.
2008-05-01 03:23:21 +02:00
// finalize_local_symbols and (in special cases) relocate_section.
Value
input_value() const
{ return this->u_.value; }
* target-reloc.h (relocate_section): Check the symbol table index for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-03-03 20:31:54 +01:00
// Return whether we have set the index in the output symbol table
// yet.
bool
is_output_symtab_index_set() const
{
return (this->output_symtab_index_ != 0
&& this->output_symtab_index_ != -2U);
}
// Return whether this symbol may be discarded from the normal
// symbol table.
bool
may_be_discarded_from_output_symtab() const
{
gold_assert(!this->is_output_symtab_index_set());
return this->output_symtab_index_ != -2U;
}
// Return whether this symbol has an entry in the output symbol
2007-05-16 19:42:48 +02:00
// table.
bool
* target-reloc.h (relocate_section): Check the symbol table index for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-03-03 20:31:54 +01:00
has_output_symtab_entry() const
{
gold_assert(this->is_output_symtab_index_set());
return this->output_symtab_index_ != -1U;
}
2007-05-16 19:42:48 +02:00
// Return the index in the output symbol table.
unsigned int
output_symtab_index() const
{
* target-reloc.h (relocate_section): Check the symbol table index for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-03-03 20:31:54 +01:00
gold_assert(this->is_output_symtab_index_set()
&& this->output_symtab_index_ != -1U);
2007-05-16 19:42:48 +02:00
return this->output_symtab_index_;
}
// Set the index in the output symbol table.
void
set_output_symtab_index(unsigned int i)
{
* target-reloc.h (relocate_section): Check the symbol table index for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-03-03 20:31:54 +01:00
gold_assert(!this->is_output_symtab_index_set());
gold_assert(i != 0 && i != -1U && i != -2U);
2007-05-16 19:42:48 +02:00
this->output_symtab_index_ = i;
}
// Record that this symbol should not go into the output symbol
// table.
void
set_no_output_symtab_entry()
{
gold_assert(this->output_symtab_index_ == 0);
this->output_symtab_index_ = -1U;
}
* target-reloc.h (relocate_section): Check the symbol table index for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-03-03 20:31:54 +01:00
// Record that this symbol must go into the output symbol table,
// because it there is a relocation that uses it.
void
set_must_have_output_symtab_entry()
{
gold_assert(!this->is_output_symtab_index_set());
this->output_symtab_index_ = -2U;
}
// Set the index in the output dynamic symbol table.
void
set_needs_output_dynsym_entry()
{
gold_assert(!this->is_section_symbol());
this->output_dynsym_index_ = 0;
}
* target-reloc.h (relocate_section): Check the symbol table index for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-03-03 20:31:54 +01:00
// Return whether this symbol should go into the dynamic symbol
// table.
bool
needs_output_dynsym_entry() const
{
return this->output_dynsym_index_ != -1U;
}
* target-reloc.h (relocate_section): Check the symbol table index for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-03-03 20:31:54 +01:00
// Return whether this symbol has an entry in the dynamic symbol
// table.
bool
has_output_dynsym_entry() const
{
gold_assert(this->output_dynsym_index_ != 0);
return this->output_dynsym_index_ != -1U;
}
// Record that this symbol should go into the dynamic symbol table.
void
set_output_dynsym_index(unsigned int i)
{
gold_assert(this->output_dynsym_index_ == 0);
* target-reloc.h (relocate_section): Check the symbol table index for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-03-03 20:31:54 +01:00
gold_assert(i != 0 && i != -1U);
this->output_dynsym_index_ = i;
}
// Return the index in the output dynamic symbol table.
unsigned int
output_dynsym_index() const
{
gold_assert(this->output_dynsym_index_ != 0
&& this->output_dynsym_index_ != -1U);
return this->output_dynsym_index_;
}
2007-05-16 19:42:48 +02:00
// Set the index of the input section in the input file.
void
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
set_input_shndx(unsigned int i, bool is_ordinary)
{
this->input_shndx_ = i;
// input_shndx_ field is a bitfield, so make sure that the value
// fits.
gold_assert(this->input_shndx_ == i);
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
this->is_ordinary_shndx_ = is_ordinary;
}
2007-05-16 19:42:48 +02:00
// Return the index of the input section in the input file.
unsigned int
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
input_shndx(bool* is_ordinary) const
{
*is_ordinary = this->is_ordinary_shndx_;
return this->input_shndx_;
}
// Whether this is a section symbol.
bool
is_section_symbol() const
{ return this->is_section_symbol_; }
// Record that this is a section symbol.
void
set_is_section_symbol()
{
gold_assert(!this->needs_output_dynsym_entry());
this->is_section_symbol_ = true;
}
// Record that this is a TLS symbol.
void
set_is_tls_symbol()
{ this->is_tls_symbol_ = true; }
PR 10893 * 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.
2010-08-20 00:50:16 +02:00
// Return true if this is a TLS symbol.
bool
is_tls_symbol() const
{ return this->is_tls_symbol_; }
PR 10893 * 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.
2010-08-20 00:50:16 +02:00
// Record that this is an IFUNC symbol.
void
set_is_ifunc_symbol()
{ this->is_ifunc_symbol_ = true; }
// Return true if this is an IFUNC symbol.
bool
is_ifunc_symbol() const
{ return this->is_ifunc_symbol_; }
2010-09-08 Doug Kwan <dougkwan@google.com> * arm.cc (Arm_exidx_cantunwind::do_print_to_mapfile): New method. (Arm_relobj::do_relocate_sections): Add new parameter for output file to match the parent. (Target_arm::scan_reloc_section_for_stubs): Use would-be final values of local symbols instead of input values. Update code to track changes in gold::relocate_section. * object.cc (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. (Sized_relobj::do_finalize_local_symbols): Move code from loop body into private version of Sized_relobj::compute_final_local_value. Call the inline method. * object.h (Symbol_value::Symbol_value): Define destructor. Free merged symbol value if there is one. (Symbol_value::has_output_value): New method defintiion. (Sized_relobj::Compute_final_local_value_status): New enum type. (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. * Makefile.am (check_SCRIPTS): Add arm_branch_out_of_range.sh and arm_cortex_a8.sh. (thumb_bl_out_of_range_local, arm_cortex_a8_b_cond, arm_cortex_a8_bl, arm_cortex_a8_blx, arm_cortex_a8_local, arm_corte_a8_local_reloc): New tests. * Makefile.in: Regenerate. * testsuite/arm_bl_out_of_range.s: Update test. * testsuite/thumb_bl_out_of_range.s: Ditto. * testsuite/thumb_blx_out_of_range.s: Ditto. * testsuite/arm_branch_out_of_range.sh: New file. * testsuite/arm_cortex_a8.sh: Ditto. * testsuite/arm_cortex_a8_b.s: Ditto. * testsuite/arm_cortex_a8_b_cond.s: Ditto. * testsuite/arm_cortex_a8_b_local.s: Ditto. * testsuite/arm_cortex_a8_bl.s: Ditto. * testsuite/arm_cortex_a8_blx.s: Ditto. * testsuite/arm_cortex_a8_local.s: Ditto. * testsuite/arm_cortex_a8_local_reloc.s: Ditto. * testsuite/thumb_bl_out_of_range_local.s: Ditto.
2010-09-09 01:54:51 +02:00
// Return true if this has output value.
bool
has_output_value() const
{ return this->has_output_value_; }
2007-05-16 19:42:48 +02:00
private:
// The index of this local symbol in the output symbol table. This
* target-reloc.h (relocate_section): Check the symbol table index for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-03-03 20:31:54 +01:00
// will be 0 if no value has been assigned yet, and the symbol may
// be omitted. This will be -1U if the symbol should not go into
// the symbol table. This will be -2U if the symbol must go into
// the symbol table, but no index has been assigned yet.
2007-05-16 19:42:48 +02:00
unsigned int output_symtab_index_;
// The index of this local symbol in the dynamic symbol table. This
* target-reloc.h (relocate_section): Check the symbol table index for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-03-03 20:31:54 +01:00
// will be -1U if the symbol should not go into the symbol table.
unsigned int output_dynsym_index_;
2007-05-16 19:42:48 +02:00
// The section index in the input file in which this symbol is
// defined.
PR 10893 * 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.
2010-08-20 00:50:16 +02:00
unsigned int input_shndx_ : 27;
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
// Whether the section index is an ordinary index, not a special
// value.
bool is_ordinary_shndx_ : 1;
// Whether this is a STT_SECTION symbol.
bool is_section_symbol_ : 1;
// Whether this is a STT_TLS symbol.
bool is_tls_symbol_ : 1;
PR 10893 * 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.
2010-08-20 00:50:16 +02:00
// Whether this is a STT_GNU_IFUNC symbol.
bool is_ifunc_symbol_ : 1;
// Whether this symbol has a value for the output file. This is
// normally set to true during Layout::finalize, by
// finalize_local_symbols. It will be false for a section symbol in
// a merge section, as for such symbols we can not determine the
// value to use in a relocation until we see the addend.
bool has_output_value_ : 1;
union
{
// This is used if has_output_value_ is true. Between
// count_local_symbols and finalize_local_symbols, this is the
// value in the input file. After finalize_local_symbols, it is
// the value in the output file.
Value value;
// This is used if has_output_value_ is false. It points to the
// information we need to get the value for a merge section.
Merged_symbol_value<size>* merged_symbol_value;
} u_;
2007-05-16 19:42:48 +02:00
};
* options.h (class General_options): Define split_stack_adjust_size parameter. * object.h (class Object): Add uses_split_stack_ and has_no_split_stack_ fields. Add uses_split_stack and has_no_split_stack accessor functions. Declare handle_split_stack_section. (class Reloc_symbol_changes): Define. (class Sized_relobj): Define Function_offsets. Declare split_stack_adjust, split_stack_adjust_reltype, and find_functions. * object.cc (Object::handle_split_stack_section): New function. (Sized_relobj::do_layout): Call handle_split_stack_section. * dynobj.cc (Sized_dynobj::do_layout): Call handle_split_stack_section. * reloc.cc (Sized_relobj::relocate_sections): Call split_stack_adjust for executable sections in split_stack objects. Pass reloc_map to relocate_section. (Sized_relobj::split_stack_adjust): New function. (Sized_relobj::split_stack_adjust_reltype): New function. (Sized_relobj::find_functions): New function. * target-reloc.h: Include "object.h". (relocate_section): Add reloc_symbol_changes parameter. Change all callers. * target.h (class Target): Add calls_non_split method. Declare do_calls_non_split virtual method. Declare match_view and set_view_to_nop. * target.cc: Include "elfcpp.h". (Target::do_calls_non_split): New function. (Target::match_view): New function. (Target::set_view_to_nop): New function. * gold.cc (queue_middle_tasks): Give an error if mixing split-stack and non-split-stack objects with -r. * i386.cc (Target_i386::relocate_section): Add reloc_symbol_changes parameter. (Target_i386::do_calls_non_split): New function. * x86_64.cc (Target_x86_64::relocate_section): Add reloc_symbol_changes parameter. (Target_x86_64::do_calls_non_split): New function. * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes parameter. * powerpc.cc (Target_powerpc::relocate_section): Add reloc_symbol_changes parameter. * sparc.cc (Target_sparc::relocate_section): Add reloc_symbol_changes parameter. * configure.ac: Call AM_CONDITIONAL for the default target. * configure: Rebuild. * testsuite/Makefile.am (TEST_AS): New variable. (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh. (check_DATA): Add split_i386 and split_x86_64 files. (SPLIT_DEFSYMS): Define. (split_i386_[1234n].o): New targets. (split_i386_[124]): New targets. (split_i386_[1234r].stdout): New targets. (split_x86_64_[1234n].o): New targets. (split_x86_64_[124]): New targets. (split_x86_64_[1234r].stdout): New targets. (MOSTLYCLEANFILES): Add new executables. * testsuite/split_i386.sh: New file. * testsuite/split_x86_64.sh: New file. * testsuite/split_i386_1.s: New file. * testsuite/split_i386_2.s: New file. * testsuite/split_i386_3.s: New file. * testsuite/split_i386_4.s: New file. * testsuite/split_i386_n.s: New file. * testsuite/split_x86_64_1.s: New file. * testsuite/split_x86_64_2.s: New file. * testsuite/split_x86_64_3.s: New file. * testsuite/split_x86_64_4.s: New file. * testsuite/split_x86_64_n.s: New file. * testsuite/testfile.cc (Target_test): Update relocation_section function. * testsuite/Makefile.in: Rebuild.
2009-10-07 00:58:27 +02:00
// This type is used to modify relocations for -fsplit-stack. It is
// indexed by relocation index, and means that the relocation at that
// index should use the symbol from the vector, rather than the one
// indicated by the relocation.
class Reloc_symbol_changes
{
public:
Reloc_symbol_changes(size_t count)
: vec_(count, NULL)
{ }
void
set(size_t i, Symbol* sym)
{ this->vec_[i] = sym; }
const Symbol*
operator[](size_t i) const
{ return this->vec_[i]; }
private:
std::vector<Symbol*> vec_;
};
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
// Abstract base class for a regular object file, either a real object file
// or an incremental (unchanged) object. This is size and endian specific.
template<int size, bool big_endian>
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
class Sized_relobj : public Relobj
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{
public:
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
typedef typename elfcpp::Elf_types<size>::Elf_Addr Address;
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
typedef Relobj::Symbols Symbols;
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
static const Address invalid_address = static_cast<Address>(0) - 1;
Sized_relobj(const std::string& name, Input_file* input_file)
: Relobj(name, input_file), local_got_offsets_(), section_offsets_()
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{ }
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
Sized_relobj(const std::string& name, Input_file* input_file,
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
off_t offset)
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
: Relobj(name, input_file, offset), local_got_offsets_(), section_offsets_()
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{ }
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
~Sized_relobj()
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
{ }
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
// If this is a regular object, return a pointer to the Sized_relobj_file
// object. Otherwise, return NULL.
virtual Sized_relobj_file<size, big_endian>*
sized_relobj()
{ return NULL; }
const virtual Sized_relobj_file<size, big_endian>*
sized_relobj() const
{ return NULL; }
// Checks if the offset of input section SHNDX within its output
// section is invalid.
bool
is_output_section_offset_invalid(unsigned int shndx) const
{ return this->get_output_section_offset(shndx) == invalid_address; }
// Get the offset of input section SHNDX within its output section.
// This is -1 if the input section requires a special mapping, such
// as a merge section. The output section can be found in the
// output_sections_ field of the parent class Relobj.
Address
get_output_section_offset(unsigned int shndx) const
{
gold_assert(shndx < this->section_offsets_.size());
return this->section_offsets_[shndx];
}
// Iterate over local symbols, calling a visitor class V for each GOT offset
// associated with a local symbol.
void
do_for_all_local_got_entries(Got_offset_list::Visitor* v) const;
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
protected:
typedef Relobj::Output_sections Output_sections;
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
// Clear the local symbol information.
void
clear_got_offsets()
{ this->local_got_offsets_.clear(); }
// Return the vector of section offsets.
std::vector<Address>&
section_offsets()
{ return this->section_offsets_; }
// Get the address of an output section.
uint64_t
do_output_section_address(unsigned int shndx);
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
// Get the offset of a section.
uint64_t
do_output_section_offset(unsigned int shndx) const
{
Address off = this->get_output_section_offset(shndx);
if (off == invalid_address)
return -1ULL;
return off;
}
// Set the offset of a section.
void
do_set_section_offset(unsigned int shndx, uint64_t off)
{
gold_assert(shndx < this->section_offsets_.size());
this->section_offsets_[shndx] =
(off == static_cast<uint64_t>(-1)
? invalid_address
: convert_types<Address, uint64_t>(off));
}
// Return whether the local symbol SYMNDX plus ADDEND has a GOT offset
// of type GOT_TYPE.
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
bool
do_local_has_got_offset(unsigned int symndx, unsigned int got_type,
uint64_t addend) const
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
{
Local_got_entry_key key(symndx, addend);
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
Local_got_offsets::const_iterator p =
this->local_got_offsets_.find(key);
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
return (p != this->local_got_offsets_.end()
&& p->second->get_offset(got_type) != -1U);
}
// Return the GOT offset of type GOT_TYPE of the local symbol
// SYMNDX plus ADDEND.
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
unsigned int
do_local_got_offset(unsigned int symndx, unsigned int got_type,
uint64_t addend) const
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
{
Local_got_entry_key key(symndx, addend);
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
Local_got_offsets::const_iterator p =
this->local_got_offsets_.find(key);
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
gold_assert(p != this->local_got_offsets_.end());
unsigned int off = p->second->get_offset(got_type);
gold_assert(off != -1U);
return off;
}
// Set the GOT offset with type GOT_TYPE of the local symbol SYMNDX
// plus ADDEND to GOT_OFFSET.
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
void
do_set_local_got_offset(unsigned int symndx, unsigned int got_type,
unsigned int got_offset, uint64_t addend)
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
{
Local_got_entry_key key(symndx, addend);
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
Local_got_offsets::const_iterator p =
this->local_got_offsets_.find(key);
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
if (p != this->local_got_offsets_.end())
p->second->set_offset(got_type, got_offset);
else
{
Got_offset_list* g = new Got_offset_list(got_type, got_offset);
std::pair<Local_got_offsets::iterator, bool> ins =
this->local_got_offsets_.insert(std::make_pair(key, g));
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
gold_assert(ins.second);
}
}
// Return the word size of the object file.
virtual int
do_elfsize() const
{ return size; }
// Return TRUE if this is a big-endian object file.
virtual bool
do_is_big_endian() const
{ return big_endian; }
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
private:
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
// The GOT offsets of local symbols. This map also stores GOT offsets
// for tp-relative offsets for TLS symbols.
typedef Unordered_map<Local_got_entry_key, Got_offset_list*,
Local_got_entry_key::hash,
Local_got_entry_key::equal_to> Local_got_offsets;
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
// GOT offsets for local non-TLS symbols, and tp-relative offsets
// for TLS symbols, indexed by local got entry key class.
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
Local_got_offsets local_got_offsets_;
// For each input section, the offset of the input section in its
// output section. This is INVALID_ADDRESS if the input section requires a
// special mapping.
std::vector<Address> section_offsets_;
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
};
// A regular object file. This is size and endian specific.
2006-08-05 01:10:59 +02:00
template<int size, bool big_endian>
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
class Sized_relobj_file : public Sized_relobj<size, big_endian>
2006-08-05 01:10:59 +02:00
{
public:
typedef typename elfcpp::Elf_types<size>::Elf_Addr Address;
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
typedef typename Sized_relobj<size, big_endian>::Symbols Symbols;
2007-05-16 19:42:48 +02:00
typedef std::vector<Symbol_value<size> > Local_values;
static const Address invalid_address = static_cast<Address>(0) - 1;
2010-09-08 Doug Kwan <dougkwan@google.com> * arm.cc (Arm_exidx_cantunwind::do_print_to_mapfile): New method. (Arm_relobj::do_relocate_sections): Add new parameter for output file to match the parent. (Target_arm::scan_reloc_section_for_stubs): Use would-be final values of local symbols instead of input values. Update code to track changes in gold::relocate_section. * object.cc (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. (Sized_relobj::do_finalize_local_symbols): Move code from loop body into private version of Sized_relobj::compute_final_local_value. Call the inline method. * object.h (Symbol_value::Symbol_value): Define destructor. Free merged symbol value if there is one. (Symbol_value::has_output_value): New method defintiion. (Sized_relobj::Compute_final_local_value_status): New enum type. (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. * Makefile.am (check_SCRIPTS): Add arm_branch_out_of_range.sh and arm_cortex_a8.sh. (thumb_bl_out_of_range_local, arm_cortex_a8_b_cond, arm_cortex_a8_bl, arm_cortex_a8_blx, arm_cortex_a8_local, arm_corte_a8_local_reloc): New tests. * Makefile.in: Regenerate. * testsuite/arm_bl_out_of_range.s: Update test. * testsuite/thumb_bl_out_of_range.s: Ditto. * testsuite/thumb_blx_out_of_range.s: Ditto. * testsuite/arm_branch_out_of_range.sh: New file. * testsuite/arm_cortex_a8.sh: Ditto. * testsuite/arm_cortex_a8_b.s: Ditto. * testsuite/arm_cortex_a8_b_cond.s: Ditto. * testsuite/arm_cortex_a8_b_local.s: Ditto. * testsuite/arm_cortex_a8_bl.s: Ditto. * testsuite/arm_cortex_a8_blx.s: Ditto. * testsuite/arm_cortex_a8_local.s: Ditto. * testsuite/arm_cortex_a8_local_reloc.s: Ditto. * testsuite/thumb_bl_out_of_range_local.s: Ditto.
2010-09-09 01:54:51 +02:00
enum Compute_final_local_value_status
{
// No error.
CFLV_OK,
// An error occurred.
CFLV_ERROR,
// The local symbol has no output section.
CFLV_DISCARDED
};
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
Sized_relobj_file(const std::string& name,
Input_file* input_file,
off_t offset,
const typename elfcpp::Ehdr<size, big_endian>&);
2006-08-05 01:10:59 +02:00
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
~Sized_relobj_file();
2009-01-20 Sriraman Tallam <tmsriram@google.com> * 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.
2009-01-28 03:25:33 +01:00
// Set up the object file based on TARGET.
2006-08-05 01:10:59 +02:00
void
2009-10-09 Doug Kwan <dougkwan@google.com> * 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.
2009-10-10 01:18:19 +02:00
setup()
{ this->do_setup(); }
2006-08-05 01:10:59 +02:00
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
// Return a pointer to the Sized_relobj_file object.
Sized_relobj_file<size, big_endian>*
sized_relobj()
{ return this; }
const Sized_relobj_file<size, big_endian>*
sized_relobj() const
{ return this; }
// Return the ELF file type.
int
e_type() const
{ return this->e_type_; }
* mapfile.cc: New file. * mapfile.h: New file. * options.h (class General_options): Add -M/--print-map and -Map. * options.cc (General_options::finalize): Make -M equivalent to -Map -. * main.cc: Include <cstdio> and "mapfile.h". (main): Open mapfile if requested. * gold.cc (class Middle_runner): Add mapfile_ field. Update constructor. Change caller. (queue_initial_tasks): Add mapfile parameter. Change caller. (queue_middle_tasks): Likewise. * gold.h (queue_initial_tasks, queue_middle_tasks): Update declarations. * archive.cc: Include "mapfile.h". (Archive::add_symbols): Add mapfile parameter. Change all callers. Pass mapfile, symbol, and reason to include_member. (Archive::include_all_members): Add mapfile parameter. Change all callers. (Archive::include_member): Add mapfile, sym, and why parameters. Change all callers. Report inclusion to map file. * archive.h: Include "fileread.h". (class Archive): Update declarations. (Archive::file): New const method. (class Add_archive_symbols): Add mapfile_ field. Update constructor. Change all callers. * readsyms.h (class Read_symbols): Likewise. (class Finish_group): Likewise. (class Read_script): Likewise. * common.cc: Include "mapfile.h". (Symbol_table::allocate_commons): Add mapfile parameter. Change all callers. (Symbol_table::do_allocate_commons): Likewise. (Symbol_table::do_allocate_commons_list): Likewise. Report common symbol allocation to mapfile. * common.h (class Allocate_commons_task): Add mapfile_ field. Update constructor. Change all callers. * symtab.h (class Symbol_table): Update declarations. * layout.cc: Include "mapfile.h". (Layout_task_runner::run): Print information to mapfile. (Layout::create_gold_note): Change Output_data_fixed_space to Output_data_zero_fill. (Layout::create_build_id): Likewise. (Layout::print_to_mapfile): New function. * layout.h (class Layout_task_runner): Add mapfile_ field. Update constructor. Change caller. (class Layout): Declare print_to_mapfile. * output.cc (Output_section::Input_section::print_to_mapfile): New function. (Output_section::add_input_section): If producing a map, always add to input_sections_ list. (Output_section::do_print_to_mapfile): New function. (Output_segment::print_sections_to_mapfile): New function. (Output_segment::print_section_list_to_mapfile): New function. * output.h: Include "mapfile.h". (Output_data::print_to_mapfile): New function. (Output_data::do_print_to_mapfile): New virtual function. (Output_segment_headers::do_print_to_mapfile): New function. (Output_file_header::do_print_to_mapfile): New function. (Output_data_const::do_print_to_mapfile): New function. (class Output_data_const_buffer): Add map_name_ field. Update constructor. Change all callers. Add do_print_to_mapfile function. (class Output_data_fixed_space): Likewise. (class Output_data_space): Likewise. (class Output_data_zero_fill): New class. (Output_data_strtab::do_print_to_mapfile): New function. (Output_data_reloc_base::do_print_to_mapfile): New function. (Output_relocatable_relocs::do_print_to_mapfile): New function. (Output_data_group::do_print_to_mapfile): New function. (Output_data_got::do_print_to_mapfile): New function. (Output_data_dynamic::do_print_to_mapfile): New function. (Output_symtab_xindex::do_print_to_mapfile): New function. (class Output_section): Declare do_print_to_mapflie. Declare print_to_mapfile in Input_section. (class Output_segment): Declare new functions. * object.h (Sized_relobj::symbol_count): New function. * script-sections.cc (Output_section_element_dot_assignment::set_section_addresses): Change Output_data_fixed_space to Output_data_zero_fill. (Output_data_expression::do_print_to_mapfile): New function. * script.cc (read_input_script): Add mapfile parameter. Change all callers. * script.h (read_input_script): Update declaration. * ehframe.h (Eh_frame_hdr::do_print_to_mapfile): New function. (Eh_frame::do_print_to_mapfile): New function. * merge.h (Output_merge_data::do_print_to_mapfile): New function. (Output_merge_string::do_print_to_mapfile): New function. * i386.cc (Output_data_plt_i386::do_print_to_mapfile): New function. * sparc.cc (Output_data_plt_sparc::do_print_to_mapfile): New function. * x86_64.cc (Output_data_plt_x86_64::do_print_to_mapfile): New function. * Makefile.am (CCFILES): Add mapfile.cc. (HFILES): Add mapfile.h. * Makefile.in: Rebuild.
2008-05-21 23:37:44 +02:00
// Return the number of symbols. This is only valid after
// Object::add_symbols has been called.
unsigned int
symbol_count() const
{ return this->local_symbol_count_ + this->symbols_.size(); }
// If SYM is the index of a global symbol in the object file's
// symbol table, return the Symbol object. Otherwise, return NULL.
Symbol*
global_symbol(unsigned int sym) const
{
if (sym >= this->local_symbol_count_)
{
gold_assert(sym - this->local_symbol_count_ < this->symbols_.size());
return this->symbols_[sym - this->local_symbol_count_];
}
return NULL;
}
// Return the section index of symbol SYM. Set *VALUE to its value
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
// in the object file. Set *IS_ORDINARY if this is an ordinary
// section index, not a special code between SHN_LORESERVE and
// SHN_HIRESERVE. Note that for a symbol which is not defined in
// this object file, this will set *VALUE to 0 and return SHN_UNDEF;
// it will not return the final value of the symbol in the link.
unsigned int
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
symbol_section_and_value(unsigned int sym, Address* value, bool* is_ordinary);
// Return a pointer to the Symbol_value structure which holds the
// value of a local symbol.
const Symbol_value<size>*
local_symbol(unsigned int sym) const
{
gold_assert(sym < this->local_values_.size());
return &this->local_values_[sym];
}
// Return the index of local symbol SYM in the ordinary symbol
// table. A value of -1U means that the symbol is not being output.
unsigned int
symtab_index(unsigned int sym) const
{
2007-05-16 19:42:48 +02:00
gold_assert(sym < this->local_values_.size());
return this->local_values_[sym].output_symtab_index();
}
// Return the index of local symbol SYM in the dynamic symbol
// table. A value of -1U means that the symbol is not being output.
unsigned int
dynsym_index(unsigned int sym) const
{
gold_assert(sym < this->local_values_.size());
return this->local_values_[sym].output_dynsym_index();
}
2008-02-06 09:13:50 +01:00
// Return the input section index of local symbol SYM.
unsigned int
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
local_symbol_input_shndx(unsigned int sym, bool* is_ordinary) const
2008-02-06 09:13:50 +01:00
{
gold_assert(sym < this->local_values_.size());
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
return this->local_values_[sym].input_shndx(is_ordinary);
2008-02-06 09:13:50 +01:00
}
* target-reloc.h (relocate_section): Check the symbol table index for -1U before setting the local symbol index. (scan_relocatable_relocs): If copying the relocation, record that the local symbol is required. * object.h (Symbol_value::is_output_symtab_index_set): New function. (Symbol_value::may_be_discarded_from_output_symtab): New function. (Symbol_value::has_output_symtab_entry): New function. (Symbol_value::needs_output_symtab_entry): Remove. (Symbol_value::output_symtab_index): Make sure the symbol index is set. (Symbol_value::set_output_symtab_index): Make sure the symbol index is not set. Make sure the new index is valid. (Symbol_value::set_must_have_output_symtab_entry): New function. (Symbol_value::has_output_dynsym_entry): New function. (Symbol_value::set_output_dynsym_index): Make sure the new index is valid. (Sized_relobj::set_must_have_output_symtab_entry): New function. * object.cc (Sized_relobj::do_count_local_symbols): Only discard a local symbol if permitted. (Sized_relobj::do_finalize_local_symbols): Call is_output_symtab_index_set rather than needs_output_symtab_entry. (Sized_relobj::write_local_symbols): Call has_output_symtab_entry rather than needs_output_symtab_entry. Call has_output_dynsym_entry rather than needs_output_dynsym_entry. * arm.cc (Arm_relobj::update_output_local_symbol_count): Call is_output_symtab_index_set rather than needs_output_symtab_entry. * testsuite/discard_locals_relocatable_test.c: New file. * testsuite/discard_locals_test.sh: Test -r. * testsuite/Makefile.am (check_DATA): Add discard_locals_relocatable_test1.syms, discard_local_relocatable_test2.syms. (MOSTLYCLEANFILES): Likewise. Also add discard_locals_relocatable_test1.lout and discard_locals_relocatable_test2.out. (discard_locals_relocatable_test1.syms): New target. (discard_locals_relocatable_test.o): New target. (discard_locals_relocatable_test1.out): New target. (discard_locals_relocatable_test2.syms): New target. (discard_locals_relocatable_test2.out): New target. (various): Add missing ../ld-new dependencies. * testsuite/Makefile.in: Rebuild.
2010-03-03 20:31:54 +01:00
// Record that local symbol SYM must be in the output symbol table.
void
set_must_have_output_symtab_entry(unsigned int sym)
{
gold_assert(sym < this->local_values_.size());
this->local_values_[sym].set_must_have_output_symtab_entry();
}
// Record that local symbol SYM needs a dynamic symbol entry.
void
set_needs_output_dynsym_entry(unsigned int sym)
{
gold_assert(sym < this->local_values_.size());
this->local_values_[sym].set_needs_output_dynsym_entry();
}
PR 10893 * 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.
2010-08-20 00:50:16 +02:00
// Return whether the local symbol SYMNDX has a PLT offset.
bool
local_has_plt_offset(unsigned int symndx) const;
// Set the PLT offset of the local symbol SYMNDX.
void
set_local_plt_offset(unsigned int symndx, unsigned int plt_offset);
// Adjust this local symbol value. Return false if the symbol
// should be discarded from the output file.
bool
adjust_local_symbol(Symbol_value<size>* lv) const
{ return this->do_adjust_local_symbol(lv); }
// Return the name of the symbol that spans the given offset in the
// specified section in this object. This is used only for error
// messages and is not particularly efficient.
bool
get_symbol_location_info(unsigned int shndx, off_t offset,
Symbol_location_info* info);
* layout.cc (Layout::include_section): Refactored check for debug info section. (Layout::add_comdat): Add new parameters. Change type of signature parameter. Add object and shndx to signatures table. (Layout::find_kept_object): New function. * layout.h: Include <cstring>. (Layout::is_debug_info_section): New function. (Layout::add_comdat): Add new parameters. (Layout::find_kept_object): New function. (Layout::Kept_section): New struct. (Layout::Signatures): Change type of map range. * object.cc (Relobj::output_section_address): New function. (Sized_relobj::include_section_group): Add new parameters. Change calls to Layout::add_comdat. Change to build table of kept comdat groups and table mapping discarded sections to kept sections. (Sized_relobj::include_linkonce_section): Likewise. Add new parameter. (Sized_relobj::do_layout): Change calls to include_section_group and include_linkonce_section. (Sized_relobj::do_finalize_local_symbols): Do not set local symbol value to zero when section is discarded. (Sized_relobj::map_to_kept_section): New function. * object.h (Relobj::output_section_address): New function. (Relobj::Comdat_group): New type. (Relobj::find_comdat_group): New function. (Relobj::Comdat_group_table): New type. (Relobj::Kept_comdat_section): New type. (Relobj::Kept_comdat_section_table): New type. (Relobj::add_comdat_group): New function. (Relobj::set_kept_comdat_section): New function. (Relobj::get_kept_comdat_section): New function. (Relobj::comdat_groups_): New field. (Relobj::kept_comdat_sections_): New field. (Symbol_value::input_value): Update comment. (Sized_relobj::map_to_kept_section) New function. (Sized_relobj::include_linkonce_section): Add new parameter. * target-reloc.h (Comdat_behavior): New type. (get_comdat_behavior): New function. (relocate_section): Add code to map a discarded section to the corresponding kept section when applying a relocation.
2008-05-01 03:23:21 +02:00
// Look for a kept section corresponding to the given discarded section,
// and return its output address. This is used only for relocations in
// debugging sections.
Address
Further improve warnings for relocations referring to discarded sections. Relocations referring to discarded sections are now treated as errors instead of warnings. Also with this patch, we will now print the section group signature and the object file with the prevailing definition of that group along with the name of the symbol that the relocation is referring to. This additional information should be much more useful to anyone trying to track down the source of such errors. To do so, we now map each discarded section to the Kept_section info in the Layout class, and defer the logic that maps a discarded section to its counterpart in the kept group. This gives us the information we need to identify the signature symbol given the discarded section, and the name of the object file that provided the prevailing (i.e., first) definition of that group. gold/ * object.cc (Sized_relobj_file::include_section_group): Store reference to Kept_section info for discarded comdat sections regardless of size. Move size checking to map_to_kept_section. (Sized_relobj_file::include_linkonce_section): Likewise. (Sized_relobj_file::map_to_kept_section): Add section name parameter. Insert size checking logic from above functions. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. * object.h (Sized_relobj_file::map_to_kept_section): Add section_name parameter. Adjust all callers. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. (Sized_relobj_file::Kept_comdat_section): Replace object and shndx fields with sh_size, kept_section, symndx, and is_comdat fields. (Sized_relobj_file::set_kept_comdat_section): Replace kept_object and kept_shndx parameters with is_comdat, symndx, sh_size, and kept_section. (Sized_relobj_file::get_kept_comdat_section): Likewise. * target-reloc.h (enum Comdat_behavior): Change CB_WARNING to CB_ERROR. Adjust all references. (issue_undefined_symbol_error): New function template. (relocate_section): Pass section name to map_to_kept_section. Move discarded section code to new function above. * aarch64.cc (Target_aarch64::scan_reloc_section_for_stubs): Move declaration for gsym out one level. Call issue_discarded_error. * arm.cc (Target_arm::scan_reloc_section_for_stubs): Likewise. * powerpc.cc (Relocate_comdat_behavior): Change CB_WARNING to CB_ERROR.
2018-04-07 01:06:16 +02:00
map_to_kept_section(unsigned int shndx, std::string& section_name,
bool* found) const;
// Look for a kept section corresponding to the given discarded section,
// and return its object file.
Relobj*
find_kept_section_object(unsigned int shndx, unsigned int* symndx_p) const;
// Return the name of symbol SYMNDX.
const char*
get_symbol_name(unsigned int symndx);
* layout.cc (Layout::include_section): Refactored check for debug info section. (Layout::add_comdat): Add new parameters. Change type of signature parameter. Add object and shndx to signatures table. (Layout::find_kept_object): New function. * layout.h: Include <cstring>. (Layout::is_debug_info_section): New function. (Layout::add_comdat): Add new parameters. (Layout::find_kept_object): New function. (Layout::Kept_section): New struct. (Layout::Signatures): Change type of map range. * object.cc (Relobj::output_section_address): New function. (Sized_relobj::include_section_group): Add new parameters. Change calls to Layout::add_comdat. Change to build table of kept comdat groups and table mapping discarded sections to kept sections. (Sized_relobj::include_linkonce_section): Likewise. Add new parameter. (Sized_relobj::do_layout): Change calls to include_section_group and include_linkonce_section. (Sized_relobj::do_finalize_local_symbols): Do not set local symbol value to zero when section is discarded. (Sized_relobj::map_to_kept_section): New function. * object.h (Relobj::output_section_address): New function. (Relobj::Comdat_group): New type. (Relobj::find_comdat_group): New function. (Relobj::Comdat_group_table): New type. (Relobj::Kept_comdat_section): New type. (Relobj::Kept_comdat_section_table): New type. (Relobj::add_comdat_group): New function. (Relobj::set_kept_comdat_section): New function. (Relobj::get_kept_comdat_section): New function. (Relobj::comdat_groups_): New field. (Relobj::kept_comdat_sections_): New field. (Symbol_value::input_value): Update comment. (Sized_relobj::map_to_kept_section) New function. (Sized_relobj::include_linkonce_section): Add new parameter. * target-reloc.h (Comdat_behavior): New type. (get_comdat_behavior): New function. (relocate_section): Add code to map a discarded section to the corresponding kept section when applying a relocation.
2008-05-01 03:23:21 +02:00
2010-09-08 Doug Kwan <dougkwan@google.com> * arm.cc (Arm_exidx_cantunwind::do_print_to_mapfile): New method. (Arm_relobj::do_relocate_sections): Add new parameter for output file to match the parent. (Target_arm::scan_reloc_section_for_stubs): Use would-be final values of local symbols instead of input values. Update code to track changes in gold::relocate_section. * object.cc (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. (Sized_relobj::do_finalize_local_symbols): Move code from loop body into private version of Sized_relobj::compute_final_local_value. Call the inline method. * object.h (Symbol_value::Symbol_value): Define destructor. Free merged symbol value if there is one. (Symbol_value::has_output_value): New method defintiion. (Sized_relobj::Compute_final_local_value_status): New enum type. (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. * Makefile.am (check_SCRIPTS): Add arm_branch_out_of_range.sh and arm_cortex_a8.sh. (thumb_bl_out_of_range_local, arm_cortex_a8_b_cond, arm_cortex_a8_bl, arm_cortex_a8_blx, arm_cortex_a8_local, arm_corte_a8_local_reloc): New tests. * Makefile.in: Regenerate. * testsuite/arm_bl_out_of_range.s: Update test. * testsuite/thumb_bl_out_of_range.s: Ditto. * testsuite/thumb_blx_out_of_range.s: Ditto. * testsuite/arm_branch_out_of_range.sh: New file. * testsuite/arm_cortex_a8.sh: Ditto. * testsuite/arm_cortex_a8_b.s: Ditto. * testsuite/arm_cortex_a8_b_cond.s: Ditto. * testsuite/arm_cortex_a8_b_local.s: Ditto. * testsuite/arm_cortex_a8_bl.s: Ditto. * testsuite/arm_cortex_a8_blx.s: Ditto. * testsuite/arm_cortex_a8_local.s: Ditto. * testsuite/arm_cortex_a8_local_reloc.s: Ditto. * testsuite/thumb_bl_out_of_range_local.s: Ditto.
2010-09-09 01:54:51 +02:00
// Compute final local symbol value. R_SYM is the local symbol index.
// LV_IN points to a local symbol value containing the input value.
// LV_OUT points to a local symbol value storing the final output value,
// which must not be a merged symbol value since before calling this
// method to avoid memory leak. SYMTAB points to a symbol table.
//
// The method returns a status code at return. If the return status is
// CFLV_OK, *LV_OUT contains the final value. If the return status is
// CFLV_ERROR, *LV_OUT is 0. If the return status is CFLV_DISCARDED,
// *LV_OUT is not modified.
Compute_final_local_value_status
compute_final_local_value(unsigned int r_sym,
const Symbol_value<size>* lv_in,
Symbol_value<size>* lv_out,
const Symbol_table* symtab);
// Return true if the layout for this object was deferred.
bool is_deferred_layout() const
{ return this->is_deferred_layout_; }
protected:
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
typedef typename Sized_relobj<size, big_endian>::Output_sections
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
Output_sections;
2009-10-09 Doug Kwan <dougkwan@google.com> * 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.
2009-10-10 01:18:19 +02:00
// Set up.
virtual void
do_setup();
// Read the symbols.
2006-08-05 01:10:59 +02:00
void
do_read_symbols(Read_symbols_data*);
// Read the symbols. This is common code for all target-specific
// overrides of do_read_symbols.
void
base_read_symbols(Read_symbols_data*);
* object.h (Relobj::local_symbol_value): New function. (Relobj::local_plt_offset): New function. (Relobj::local_has_got_offset): New function. (Relobj::local_got_offset): New function. (Relobj::set_local_got_offset): New function. (Relobj::do_local_symbol_value): New pure virtual function. (Relobj::do_local_plt_offset): Likewise. (Relobj::do_local_has_got_offset): Likewise. (Relobj::do_local_got_offset): Likewise. (Relobj::do_set_local_got_offset): Likewise. (Sized_relobj::do_local_has_got_offset): Rename from local_has_got_offset. (Sized_relobj::do_local_got_offset): Rename from local_got_offset. (Sized_relobj::do_set_local_got_offset): Rename from set_local_got_offset. (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. (Sized_relobj_file::do_local_symbol_value): New function. * object.cc (Sized_relobj_file::do_local_plt_offset): Rename from local_plt_offset. * output.cc (Output_data_got::Got_entry::write): Change object to Relobj. Use local_symbol_value. (Output_data_got::add_global_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_with_rela): Remove. Change all callers to use add_global_with_rel. (Output_data_got::add_global_pair_with_rel): Change rel_dyn to Output_data_reloc_generic*. Use add_global_generic. (Output_data_got::add_global_pair_with_rela): Remove. Change all callers to use add_global_pair_with_rel. (Output_data_got::add_local): Change object to Relobj*. (Output_data_got::add_local_plt): Likewise. (Output_data_got::add_local_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_local_generic. (Output_data_got::add_local_with_rela): Remove. Change all callers to use all_local_with_rel. (Output_data_got::add_local_pair_with_rel): Change object to Relobj*, change rel_dyn to Output_data_reloc_generic*. Use add_output_section_generic. (Output_data_got::add_local_pair_with_rela): Remove. Change all callers to use add_local_pair_with_rel. (Output_data_got::reserve_local): Change object to Relobj*. * output.h: (class Output_data_reloc_generic): Add pure virtual declarations for add_global_generic, add_local_generic, add_output_section_generic. (class Output_data_reloc) [SHT_REL, SHT_RELA]: Implement new functions for Output_data_reloc_generic. Update declarations for changes listed in output.cc. (class Output_data_got): Change template parameter to got_size. Don't define Rel_dyn or Rela_dyn. Update declarations per above. * incremental.h (Sized_relobj_incr::do_local_symbol_value): New function. (Sized_relobj_incr::do_local_plt_offset): New function. * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Call add_global_generic.
2011-12-19 22:07:16 +01:00
// Return the value of a local symbol.
uint64_t
do_local_symbol_value(unsigned int symndx, uint64_t addend) const
{
const Symbol_value<size>* symval = this->local_symbol(symndx);
return symval->value(this, addend);
}
// Return the PLT offset for a local symbol. It is an error to call
// this if it doesn't have one.
unsigned int
do_local_plt_offset(unsigned int symndx) const;
// Return whether local symbol SYMNDX is a TLS symbol.
bool
do_local_is_tls(unsigned int symndx) const
{ return this->local_symbol(symndx)->is_tls_symbol(); }
// Return the number of local symbols.
unsigned int
do_local_symbol_count() const
{ return this->local_symbol_count_; }
* incremental-dump.cc (dump_incremental_inputs): Print local symbol info for each input file. * incremental.cc (Output_section_incremental_inputs::set_final_data_size): Add local symbol info to input file entries in incremental info. (Output_section_incremental_inputs::write_info_blocks): Likewise. (Sized_incr_relobj::Sized_incr_relobj): Initialize new data members. (Sized_incr_relobj::do_add_symbols): Cosmetic change. (Sized_incr_relobj::do_count_local_symbols): Replace stub with implementation. (Sized_incr_relobj::do_finalize_local_symbols): Likewise. (Sized_incr_relobj::do_relocate): Write the local symbols. (Sized_incr_dynobj::do_add_symbols): Cosmetic change. * incremental.h (Incremental_inputs_reader::get_symbol_offset): Adjust size of input file header. (Incremental_inputs_reader::get_local_symbol_offset): New function. (Incremental_inputs_reader::get_local_symbol_count): New function. (Incremental_inputs_reader::get_input_section): Adjust size of input file header. (Incremental_inputs_reader::get_global_symbol_reader): Likewise. (Sized_incr_relobj::This): New typedef. (Sized_incr_relobj::sym_size): New const data member. (Sized_incr_relobj::Local_symbol): New struct. (Sized_incr_relobj::do_output_local_symbol_count): New function. (Sized_incr_relobj::do_local_symbol_offset): New function. (Sized_incr_relobj::local_symbol_count_): New data member. (Sized_incr_relobj::output_local_dynsym_count_): New data member. (Sized_incr_relobj::local_symbol_index_): New data member. (Sized_incr_relobj::local_symbol_offset_): New data member. (Sized_incr_relobj::local_dynsym_offset_): New data member. (Sized_incr_relobj::local_symbols_): New data member. * object.h (Relobj::output_local_symbol_count): New function. (Relobj::local_symbol_offset): New function. (Relobj::do_output_local_symbol_count): New function. (Relobj::do_local_symbol_offset): New function. (Sized_relobj::do_output_local_symbol_count): New function. (Sized_relobj::do_local_symbol_offset): New function.
2011-04-25 22:28:48 +02:00
// Return the number of local symbols in the output symbol table.
unsigned int
do_output_local_symbol_count() const
{ return this->output_local_symbol_count_; }
// Return the number of local symbols in the output symbol table.
off_t
do_local_symbol_offset() const
{ return this->local_symbol_offset_; }
// Lay out the input sections.
void
2007-09-21 09:20:01 +02:00
do_layout(Symbol_table*, Layout*, Read_symbols_data*);
// Layout sections whose layout was deferred while waiting for
// input files from a plugin.
void
do_layout_deferred_sections(Layout*);
// Add the symbols to the symbol table.
void
do_add_symbols(Symbol_table*, Read_symbols_data*, Layout*);
2010-03-22 Rafael Espindola <espindola@google.com> * archive.cc (Should_include): Move to archive.h. (should_include_member): Make it a member of Archive. (Lib_group): New. (Add_lib_group_symbols): New. * archive.h: Include options.h. (Archive_member): Moved from Archive. (Should_include): Moved from archive.cc. (Lib_group): New. (Add_lib_group_symbols): New. * dynobj.cc (do_should_include_member): New. * dynobj.h (do_should_include_member): New. * gold.cc (queue_initial_tasks): Update call to queue. * main.cc (main): Print lib group stats. * object.cc (do_should_include_member): New. * object.h: Include archive.h. (Object::should_include_member): New. (Object::do_should_include_member): New. (Sized_relobj::do_should_include_member): New. * options.cc (General_options::parse_start_lib): New. (General_options::parse_end_lib): New. (Input_arguments::add_file): Handle lib groups. (Input_arguments::start_group): Check we are not in a lib. (Input_arguments::start_lib): New. (Input_arguments::end_lib): New. * options.h (General_options): Add start_lib and end_lib. (Input_argument::lib_): New. (Input_argument::lib): New. (Input_argument::is_lib): New. (Input_file_lib): New. (Input_arguments::in_lib_): New. (Input_arguments::in_lib): New. (Input_arguments::start_lib): New. (Input_arguments::end_lib_): New. * plugin.cc (Pluginobj::get_symbol_resolution_info): Mark symbols in unused members as preempted. (Sized_pluginobj::do_should_include_member): New. * plugin.h (Sized_pluginobj::do_should_include_member): New. * readsyms.cc (Read_symbols::locks): If we are just reading a member, return the blocker. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::do_read_symbols): Handle lib groups. (Read_symbols::get_name): Handle lib groups. * readsyms.h (Read_symbols): Add an archive member pointer. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::member_): New. * script.cc (read_input_script): Update call to queue_soon.
2010-03-22 15:18:24 +01:00
Archive::Should_include
PR 11855 * script.cc (Script_options::Script_options): Initialize symbol_definitions_ and symbol_references_. (Script_options::add_symbol_assignment): Update symbol_definitions_ and symbol_references_. (Script_options::add_symbol_reference): New function. (script_symbol): New function. * script.h (class Script_options): Add symbol_definitions_ and symbol_references_ fields. (Script_options::referenced_const_iterator): New type. (Script_options::referenced_begin): New function. (Script_options::referenced_end): New function. (Script_options::is_referenced): New function. (Script_options::any_unreferenced): New function. * script-c.h (script_symbol): Declare. * yyscript.y (exp): Call script_symbol. * symtab.cc: Include "script.h". (Symbol_table::gc_mark_undef_symbols): Add layout parameter. Change all callers. Check symbols referenced by scripts. (Symbol_table::add_undefined_symbols_from_command_line): Add layout parameter. Change all callers. (Symbol_table::do_add_undefined_symbols_from_command_line): Likewise. Break out loop body. Check symbols referenced by scripts. (Symbol_table::add_undefined_symbol_from_command_line): New function broken out of do_add_undefined_symbols_from_command_line. * symtab.h (class Symbol_table): Update declarations. * archive.cc: Include "layout.h". (Archive::should_include_member): Add layout parameter. Change all callers. Check for symbol mentioned in expression. * archive.h (class Archive): Update declaration. * object.cc (Sized_relobj::do_should_include_member): Add layout parameter. * object.h (Object::should_include_member): Add layout parameter. Change all callers. (Object::do_should_include_member): Add layout parameter. (class Sized_relobj): Update declaration. * dynobj.cc (Sized_dynobj::do_should_include_member): Add layout parameter. * dynobj.h (class Sized_dynobj): Update declaration. * plugin.cc (Sized_pluginobj::do_should_include_member): Add layout parameter. * plugin.h (class Sized_pluginobj): Update declaration.
2010-08-02 15:34:33 +02:00
do_should_include_member(Symbol_table* symtab, Layout*, Read_symbols_data*,
2010-03-22 Rafael Espindola <espindola@google.com> * archive.cc (Should_include): Move to archive.h. (should_include_member): Make it a member of Archive. (Lib_group): New. (Add_lib_group_symbols): New. * archive.h: Include options.h. (Archive_member): Moved from Archive. (Should_include): Moved from archive.cc. (Lib_group): New. (Add_lib_group_symbols): New. * dynobj.cc (do_should_include_member): New. * dynobj.h (do_should_include_member): New. * gold.cc (queue_initial_tasks): Update call to queue. * main.cc (main): Print lib group stats. * object.cc (do_should_include_member): New. * object.h: Include archive.h. (Object::should_include_member): New. (Object::do_should_include_member): New. (Sized_relobj::do_should_include_member): New. * options.cc (General_options::parse_start_lib): New. (General_options::parse_end_lib): New. (Input_arguments::add_file): Handle lib groups. (Input_arguments::start_group): Check we are not in a lib. (Input_arguments::start_lib): New. (Input_arguments::end_lib): New. * options.h (General_options): Add start_lib and end_lib. (Input_argument::lib_): New. (Input_argument::lib): New. (Input_argument::is_lib): New. (Input_file_lib): New. (Input_arguments::in_lib_): New. (Input_arguments::in_lib): New. (Input_arguments::start_lib): New. (Input_arguments::end_lib_): New. * plugin.cc (Pluginobj::get_symbol_resolution_info): Mark symbols in unused members as preempted. (Sized_pluginobj::do_should_include_member): New. * plugin.h (Sized_pluginobj::do_should_include_member): New. * readsyms.cc (Read_symbols::locks): If we are just reading a member, return the blocker. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::do_read_symbols): Handle lib groups. (Read_symbols::get_name): Handle lib groups. * readsyms.h (Read_symbols): Add an archive member pointer. (Read_symbols::do_whole_lib_group): New. (Read_symbols::do_lib_group): New. (Read_symbols::member_): New. * script.cc (read_input_script): Update call to queue_soon.
2010-03-22 15:18:24 +01:00
std::string* why);
* archive.cc (Library_base::should_include_member): Move method here from class Archive. (Archive::Archive): Initialize base class. (Archive::should_include_member): Move to base class. (Archive::do_for_all_unused_symbols): New function. (Add_archive_symbols::run): Remove redundant access to incremental_inputs. (Lib_group::Lib_group): Initialize base class. (Lib_group::do_filename): New function. (Lib_group::include_member): Pass pointer to Lib_group to report_object. (Lib_group::do_for_all_unused_symbols): New function. (Add_lib_group_symbols::run): Report archive information for incremental links. * archive.h (class Library_base): New base class. (class Archive): Derive from Library_base. (Archive::filename): Move to base class. (Archive::set_incremental_info): Likewise. (Archive::incremental_info): Likewise. (Archive::Should_include): Likewise. (Archive::should_include_member): Likewise. (Archive::Armap_entry): Remove. (Archive::Unused_symbol_iterator): Remove. (Archive::unused_symbols_begin): Remove. (Archive::unused_symbols_end): Remove. (Archive::do_filename): New function. (Archive::do_get_mtime): New function. (Archive::do_for_all_unused_symbols): New function. (Archive::task_): Move to base class. (Archive::incremental_info_): Likewise. (class Lib_group): Derive from Library_base. (Lib_group::do_filename): New function. (Lib_group::do_get_mtime): New function. (Lib_group::do_for_all_unused_symbols): New function. (Lib_group::task_): Move to base class. * dynobj.cc (Sized_dynobj::do_for_all_global_symbols): New function. * dynobj.h (Sized_dynobj::do_for_all_global_symbols): New function. * incremental.cc (Incremental_inputs::report_archive_begin): Use Library_base; call library's get_mtime; add incremental inputs entry before members. (class Unused_symbol_visitor): New class. (Incremental_inputs::report_archive_end): Use Library_base; use visitor class to record unused symbols; don't add incremental inputs entry after members. (Incremental_inputs::report_object): Use Library_base. * incremental.h (Incremental_archive_entry::Incremental_archive_entry): Remove unused Archive parameter. (Incremental_inputs::report_archive_begin): Use Library_base. (Incremental_inputs::report_archive_end): Likewise. (Incremental_inputs::report_object): Likewise. * object.cc (Sized_relobj::do_for_all_global_symbols): New function. * object.h (Object::for_all_global_symbols): New function. (Object::do_for_all_global_symbols): New function. (Sized_relobj::do_for_all_global_symbols): New function. * plugin.cc (Sized_pluginobj::do_for_all_global_symbols): New function. * plugin.h (Sized_pluginobj::do_for_all_global_symbols): New function.
2011-03-30 03:31:57 +02:00
// Iterate over global symbols, calling a visitor class V for each.
void
do_for_all_global_symbols(Read_symbols_data* sd,
Library_base::Symbol_visitor_base* v);
// Read the relocs.
void
do_read_relocs(Read_relocs_data*);
2009-01-20 Sriraman Tallam <tmsriram@google.com> * 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.
2009-01-28 03:25:33 +01:00
// Process the relocs to find list of referenced sections. Used only
// during garbage collection.
void
do_gc_process_relocs(Symbol_table*, Layout*, Read_relocs_data*);
2009-01-20 Sriraman Tallam <tmsriram@google.com> * 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.
2009-01-28 03:25:33 +01:00
// Scan the relocs and adjust the symbol table.
void
do_scan_relocs(Symbol_table*, Layout*, Read_relocs_data*);
// Count the local symbols.
void
do_count_local_symbols(Stringpool_template<char>*,
Stringpool_template<char>*);
2006-09-28 00:53:42 +02:00
// Finalize the local symbols.
unsigned int
2009-08-05 22:51:56 +02:00
do_finalize_local_symbols(unsigned int, off_t, Symbol_table*);
// Set the offset where local dynamic symbol information will be stored.
unsigned int
do_set_local_dynsym_indexes(unsigned int);
// Set the offset where local dynamic symbol information will be stored.
unsigned int
do_set_local_dynsym_offset(off_t);
2006-09-28 00:53:42 +02:00
// Relocate the input sections and write out the local symbols.
void
do_relocate(const Symbol_table* symtab, const Layout*, Output_file* of);
2008-02-04 06:43:05 +01:00
// Get the size of a section.
uint64_t
do_section_size(unsigned int shndx)
{ return this->elf_file_.section_size(shndx); }
// Get the name of a section.
std::string
do_section_name(unsigned int shndx) const
{ return this->elf_file_.section_name(shndx); }
// Return the location of the contents of a section.
2012-03-21 Cary Coutant <ccoutant@google.com> * Makefile.am: Add gdb-index.cc, gdb-index.h. * Makefile.in: Regenerate. * dwarf_reader.cc (Sized_elf_reloc_mapper::do_initialize): New function. (Sized_elf_reloc_mapper::symbol_section): New function. (Sized_elf_reloc_mapper::do_get_reloc_target): New function. (make_elf_reloc_mapper): New function. (Dwarf_abbrev_table::clear_abbrev_codes): New function. (Dwarf_abbrev_table::do_read_abbrevs): New function. (Dwarf_abbrev_table::do_get_abbrev): New function. (Dwarf_ranges_table::read_ranges_table): New function. (Dwarf_ranges_table::read_range_list): New function. (Dwarf_pubnames_table::read_section): New function. (Dwarf_pubnames_table::read_header): New function. (Dwarf_pubnames_table::next_name): New function. (Dwarf_die::Dwarf_die): New function. (Dwarf_die::read_attributes): New function. (Dwarf_die::skip_attributes): New function. (Dwarf_die::set_name): New function. (Dwarf_die::set_linkage_name): New function. (Dwarf_die::attribute): New function. (Dwarf_die::string_attribute): New function. (Dwarf_die::int_attribute): New function. (Dwarf_die::uint_attribute): New function. (Dwarf_die::ref_attribute): New function. (Dwarf_die::child_offset): New function. (Dwarf_die::sibling_offset): New function. (Dwarf_info_reader::check_buffer): New function. (Dwarf_info_reader::parse): New function. (Dwarf_info_reader::do_parse): New function. (Dwarf_info_reader::do_read_string_table): New function. (Dwarf_info_reader::lookup_reloc): New function. (Dwarf_info_reader::get_string): New function. (Dwarf_info_reader::visit_compilation_unit): New function. (Dwarf_info_reader::visit_type_unit): New function. (Sized_dwarf_line_info::Sized_dwarf_line_info): Use Sized_elf_reloc_mapper. (Sized_dwarf_line_info::symbol_section): Remove function. (Sized_dwarf_line_info::read_relocs): Use Sized_elf_reloc_mapper. (Sized_dwarf_line_info::read_line_mappings): Remove object parameter, adjust callers. (Sized_dwarf_line_info::format_file_lineno): Fix type of cast. * dwarf_reader.h: Include <sys/types.h>. (class Track_relocs): Remove forward declaration. (class Elf_reloc_mapper): New class. (class Sized_elf_reloc_mapper): New class. (class Dwarf_abbrev_table): New class. (class Dwarf_range_list): New class. (class Dwarf_ranges_table): New class. (class Dwarf_pubnames_table): New class. (class Dwarf_die): New class. (class Dwarf_info_reader): New class. (Sized_dwarf_line_info::read_line_mappings): Remove object parameter. (Sized_dwarf_line_info::symbol_section): Remove member function. * dynobj.h (Sized_dynobj::do_section_contents): Refactor code from base class. * gdb-index.cc: New source file. * gdb-index.h: New source file. * incremental.cc (Sized_relobj_incr::do_layout): Track .debug_info and .debug_types sections, call Layout::add_to_gdb_index. (Sized_relobj_incr::do_section_name): Implement. (Sized_relobj_incr::do_section_contents): Adjust parameter list and return type; Implement. (Sized_incr_dynobj::do_section_contents): Adjust parameter list and return type. * incremental.h (Sized_relobj_incr::do_section_contents): Adjust parameter list and return type. (Sized_incr_dynobj::do_section_contents): Likewise. * layout.cc: Include gdb-index.h. (Layout::Layout): Initialize gdb_index_data_. (Layout::init_fixed_output_section): Check for .gdb_index section. (Layout::add_to_gdb_index): New function. Instantiate. * layout.h: Add forward declaration for class Gdb_index. (Layout::add_to_gdb_index): New member function. (Layout::gdb_index_data_): New data member. * main.cc: Include gdb-index.h. (main): Print statistics for gdb index. * object.cc (Object::section_contents): Move code into do_section_contents. (need_decompressed_section): Check for sections needed when building gdb index. (build_compressed_section_map): Likewise. (Sized_relobj_file::do_read_symbols): Need local symbols when building gdb index. (Sized_relobj_file::do_layout): Track .debug_info and .debug_types sections; call Layout::add_to_gdb_index. (Sized_relobj_file::do_decompressed_section_contents): Call do_section_contents directly. * object.h (Object::do_section_contents): Adjust parameter list and return type. (Object::do_decompressed_section_contents): Call do_section_contents directly. (Sized_relobj_file::do_section_contents): Adjust parameter list and return type. * options.h (class General_options): Add --gdb-index option. * plugin.cc (Sized_pluginobj::do_section_contents): Adjust parameter list and return type. * plugin.h (Sized_pluginobj::do_section_contents): Likewise. * reloc.h (Track_relocs::checkpoint): New function. (Track_relocs::reset): New function. * testsuite/Makefile.am (gdb_index_test_1.sh, gdb_index_test_2.sh): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/gdb_index_test.cc: New test source file. * testsuite/gdb_index_test_1.sh: New test source file. * testsuite/gdb_index_test_2.sh: New test source file.
2012-03-21 20:02:22 +01:00
const unsigned char*
do_section_contents(unsigned int shndx, section_size_type* plen,
bool cache)
{
Object::Location loc(this->elf_file_.section_contents(shndx));
*plen = convert_to_section_size_type(loc.data_size);
if (*plen == 0)
{
static const unsigned char empty[1] = { '\0' };
return empty;
}
return this->get_view(loc.file_offset, *plen, true, cache);
}
// Return section flags.
uint64_t
2009-08-05 22:51:56 +02:00
do_section_flags(unsigned int shndx);
// Return section entsize.
uint64_t
do_section_entsize(unsigned int shndx);
// Return section address.
uint64_t
do_section_address(unsigned int shndx)
{ return this->elf_file_.section_addr(shndx); }
// Return section type.
unsigned int
do_section_type(unsigned int shndx)
{ return this->elf_file_.section_type(shndx); }
// Return the section link field.
unsigned int
do_section_link(unsigned int shndx)
{ return this->elf_file_.section_link(shndx); }
// Return the section info field.
unsigned int
do_section_info(unsigned int shndx)
{ return this->elf_file_.section_info(shndx); }
2008-02-04 06:43:05 +01:00
// Return the section alignment.
uint64_t
do_section_addralign(unsigned int shndx)
{ return this->elf_file_.section_addralign(shndx); }
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
// Return the Xindex structure to use.
Xindex*
do_initialize_xindex();
* cref.cc: New file. * cref.h: New file. * options.h (class General_options): Add --print-symbol-counts. * main.cc (main): Issue defined symbol report if requested. * archive.cc (Archive::interpret_header): Make into a const member function. (Archive::add_symbols): Call Input_objects::archive_start and archive_stop. (Archive::const_iterator): Define new class. (Archive::begin, Archive::end): New functions. (Archive::include_all_members): Rewrite to use iterator. (Archive::count_members): New function. * archive.h (class Archive): Update declarations. (Archive::filename): New function. * object.cc: Include "cref.h". (Sized_relobj::Sized_relobj): Initialize defined_count_. (Sized_relobj::do_get_global_symbol_counts): New function. (Input_objects::add_object): Add object to cross-referencer. (Input_objects::archive_start): New function. (Input_objects::archive_stop): New function. (Input_objects::print_symbol_counts): New function. * object.h: Declare Cref and Archive. (Object::get_global_symbol_counts): New function. (Object::do_get_global_symbol_counts): New pure virtual function. (class Sized_relobj): Add defined_count_ field. Update declarations. (class Input_objects): Add cref_ field. Update constructor. Update declarations. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and defined_count_. (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing symbol counts. (Sized_dynobj::do_get_global_symbol_counts): New function. * dynobj.h (class Sized_dynobj): Add fields symbols_ and defined_count_. Update declarations. Define Symbols typedef. * symtab.cc (Symbol_table::add_from_relobj): Add defined parameter. Change all callers. (Symbol_table::add_from_dynobj): Add sympointers and defined parameters. Change all callers. * symtab.h (class Symbol_table): Update declarations. * Makefile.am (CCFILES): Add cref.cc. (HFILES): Add cref.h. * Makefile.in: Rebuild.
2008-07-23 00:08:43 +02:00
// Get symbol counts.
void
do_get_global_symbol_counts(const Symbol_table*, size_t*, size_t*) const;
// Get the global symbols.
const Symbols*
do_get_global_symbols() const
{ return &this->symbols_; }
2009-10-09 Doug Kwan <dougkwan@google.com> * 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.
2009-10-10 01:18:19 +02:00
// Adjust a section index if necessary.
unsigned int
adjust_shndx(unsigned int shndx)
{
if (shndx >= elfcpp::SHN_LORESERVE)
shndx += this->elf_file_.large_shndx_offset();
return shndx;
}
// Initialize input to output maps for section symbols in merged
// sections.
void
initialize_input_to_output_maps();
// Free the input to output maps for section symbols in merged
// sections.
void
free_input_to_output_maps();
// Return symbol table section index.
unsigned int
symtab_shndx() const
{ return this->symtab_shndx_; }
// Allow a child class to access the ELF file.
elfcpp::Elf_file<size, big_endian, Object>*
elf_file()
{ return &this->elf_file_; }
// Allow a child class to access the local values.
Local_values*
local_values()
{ return &this->local_values_; }
// Views and sizes when relocating.
struct View_size
{
unsigned char* view;
typename elfcpp::Elf_types<size>::Elf_Addr address;
off_t offset;
section_size_type view_size;
bool is_input_output_view;
bool is_postprocessing_view;
bool is_ctors_reverse_view;
};
typedef std::vector<View_size> Views;
// Stash away info for a number of special sections.
// Return true if any of the sections found require local symbols to be read.
virtual bool
do_find_special_sections(Read_symbols_data* sd);
// This may be overriden by a child class.
virtual void
do_relocate_sections(const Symbol_table* symtab, const Layout* layout,
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
const unsigned char* pshdrs, Output_file* of,
Views* pviews);
// Relocate section data for a range of sections.
void
relocate_section_range(const Symbol_table* symtab, const Layout* layout,
const unsigned char* pshdrs, Output_file* of,
Views* pviews, unsigned int start_shndx,
unsigned int end_shndx);
// Adjust this local symbol value. Return false if the symbol
// should be discarded from the output file.
virtual bool
do_adjust_local_symbol(Symbol_value<size>*) const
{ return true; }
// Allow a child to set output local symbol count.
void
set_output_local_symbol_count(unsigned int value)
{ this->output_local_symbol_count_ = value; }
// Return the output view for a section.
unsigned char*
do_get_output_view(unsigned int, section_size_type*) const;
2006-08-05 01:10:59 +02:00
private:
// For convenience.
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
typedef Sized_relobj_file<size, big_endian> This;
static const int ehdr_size = elfcpp::Elf_sizes<size>::ehdr_size;
static const int shdr_size = elfcpp::Elf_sizes<size>::shdr_size;
static const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
2006-09-28 00:53:42 +02:00
typedef elfcpp::Shdr<size, big_endian> Shdr;
Fix problem where mixed section types can cause internal error during a -r link. During a -r (or --emit-relocs) link, if two sections had the same name but different section types, gold would put relocations for both sections into the same relocation section even though the data sections remained separate. For .eh_frame sections, when one section is PROGBITS and another is X86_64_UNWIND, we really should be using the UNWIND section type and combining the sections anyway. For other sections, we should be creating one relocation section for each output data section. gold/ PR gold/23016 * incremental.cc (can_incremental_update): Check for unwind section type. * layout.h (Layout::layout): Add sh_type parameter. * layout.cc (Layout::layout): Likewise. (Layout::layout_reloc): Create new output reloc section if data section does not already have one. (Layout::layout_eh_frame): Check for unwind section type. (Layout::make_eh_frame_section): Use unwind section type for .eh_frame and .eh_frame_hdr. * object.h (Sized_relobj_file::Shdr_write): New typedef. (Sized_relobj_file::layout_section): Add sh_type parameter. (Sized_relobj_file::Deferred_layout::Deferred_layout): Add sh_type parameter. * object.cc (Sized_relobj_file::check_eh_frame_flags): Check for unwind section type. (Sized_relobj_file::layout_section): Add sh_type parameter; pass it to Layout::layout. (Sized_relobj_file::do_layout): Make local copy of sh_type. Force .eh_frame sections to unwind section type. Pass sh_type to layout_section. (Sized_relobj_file<size, big_endian>::do_layout_deferred_sections): Pass sh_type to layout_section. * output.cc (Output_section::Output_section): Initialize reloc_section_. * output.h (Output_section::reloc_section): New method. (Output_section::set_reloc_section): New method. (Output_section::reloc_section_): New data member. * target.h (Target::unwind_section_type): New method. (Target::Target_info::unwind_section_type): New data member. * aarch64.cc (aarch64_info): Add unwind_section_type. * arm.cc (arm_info, arm_nacl_info): Likewise. * i386.cc (i386_info, i386_nacl_info, iamcu_info): Likewise. * mips.cc (mips_info, mips_nacl_info): Likewise. * powerpc.cc (powerpc_info): Likewise. * s390.cc (s390_info): Likewise. * sparc.cc (sparc_info): Likewise. * tilegx.cc (tilegx_info): Likewise. * x86_64.cc (x86_64_info, x86_64_nacl_info): Likewise. * testsuite/Makefile.am (pr23016_1, pr23016_2): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/testfile.cc: Add unwind_section_type. * testsuite/pr23016_1.sh: New test script. * testsuite/pr23016_1a.s: New source file. * testsuite/pr23016_1b.s: New source file. * testsuite/pr23016_2.sh: New test script. * testsuite/pr23016_2a.s: New source file. * testsuite/pr23016_2b.s: New source file.
2018-04-03 01:12:10 +02:00
typedef elfcpp::Shdr_write<size, big_endian> Shdr_write;
2006-09-28 00:53:42 +02:00
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
// To keep track of discarded comdat sections, we need to map a member
// section index to the object and section index of the corresponding
// kept section.
struct Kept_comdat_section
{
Further improve warnings for relocations referring to discarded sections. Relocations referring to discarded sections are now treated as errors instead of warnings. Also with this patch, we will now print the section group signature and the object file with the prevailing definition of that group along with the name of the symbol that the relocation is referring to. This additional information should be much more useful to anyone trying to track down the source of such errors. To do so, we now map each discarded section to the Kept_section info in the Layout class, and defer the logic that maps a discarded section to its counterpart in the kept group. This gives us the information we need to identify the signature symbol given the discarded section, and the name of the object file that provided the prevailing (i.e., first) definition of that group. gold/ * object.cc (Sized_relobj_file::include_section_group): Store reference to Kept_section info for discarded comdat sections regardless of size. Move size checking to map_to_kept_section. (Sized_relobj_file::include_linkonce_section): Likewise. (Sized_relobj_file::map_to_kept_section): Add section name parameter. Insert size checking logic from above functions. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. * object.h (Sized_relobj_file::map_to_kept_section): Add section_name parameter. Adjust all callers. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. (Sized_relobj_file::Kept_comdat_section): Replace object and shndx fields with sh_size, kept_section, symndx, and is_comdat fields. (Sized_relobj_file::set_kept_comdat_section): Replace kept_object and kept_shndx parameters with is_comdat, symndx, sh_size, and kept_section. (Sized_relobj_file::get_kept_comdat_section): Likewise. * target-reloc.h (enum Comdat_behavior): Change CB_WARNING to CB_ERROR. Adjust all references. (issue_undefined_symbol_error): New function template. (relocate_section): Pass section name to map_to_kept_section. Move discarded section code to new function above. * aarch64.cc (Target_aarch64::scan_reloc_section_for_stubs): Move declaration for gsym out one level. Call issue_discarded_error. * arm.cc (Target_arm::scan_reloc_section_for_stubs): Likewise. * powerpc.cc (Relocate_comdat_behavior): Change CB_WARNING to CB_ERROR.
2018-04-07 01:06:16 +02:00
Kept_comdat_section(uint64_t a_sh_size, Kept_section* a_kept_section,
unsigned int a_symndx, bool a_is_comdat)
: sh_size(a_sh_size), kept_section(a_kept_section),
symndx (a_symndx), is_comdat(a_is_comdat)
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
{ }
Further improve warnings for relocations referring to discarded sections. Relocations referring to discarded sections are now treated as errors instead of warnings. Also with this patch, we will now print the section group signature and the object file with the prevailing definition of that group along with the name of the symbol that the relocation is referring to. This additional information should be much more useful to anyone trying to track down the source of such errors. To do so, we now map each discarded section to the Kept_section info in the Layout class, and defer the logic that maps a discarded section to its counterpart in the kept group. This gives us the information we need to identify the signature symbol given the discarded section, and the name of the object file that provided the prevailing (i.e., first) definition of that group. gold/ * object.cc (Sized_relobj_file::include_section_group): Store reference to Kept_section info for discarded comdat sections regardless of size. Move size checking to map_to_kept_section. (Sized_relobj_file::include_linkonce_section): Likewise. (Sized_relobj_file::map_to_kept_section): Add section name parameter. Insert size checking logic from above functions. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. * object.h (Sized_relobj_file::map_to_kept_section): Add section_name parameter. Adjust all callers. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. (Sized_relobj_file::Kept_comdat_section): Replace object and shndx fields with sh_size, kept_section, symndx, and is_comdat fields. (Sized_relobj_file::set_kept_comdat_section): Replace kept_object and kept_shndx parameters with is_comdat, symndx, sh_size, and kept_section. (Sized_relobj_file::get_kept_comdat_section): Likewise. * target-reloc.h (enum Comdat_behavior): Change CB_WARNING to CB_ERROR. Adjust all references. (issue_undefined_symbol_error): New function template. (relocate_section): Pass section name to map_to_kept_section. Move discarded section code to new function above. * aarch64.cc (Target_aarch64::scan_reloc_section_for_stubs): Move declaration for gsym out one level. Call issue_discarded_error. * arm.cc (Target_arm::scan_reloc_section_for_stubs): Likewise. * powerpc.cc (Relocate_comdat_behavior): Change CB_WARNING to CB_ERROR.
2018-04-07 01:06:16 +02:00
uint64_t sh_size; // Section size
Kept_section* kept_section; // Kept section info
unsigned int symndx; // Index of key symbol
bool is_comdat; // True if comdat group, false if linkonce
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
};
PR 10400 * layout.h: #include <map>. (class Kept_section): Change from struct to class. Add accessors and setters. Add section size to Comdat_group mapping. Change Comdat_group to std::map. Add is_comdat_ field. Add linkonce_size field in union. (class Layout): Update declaration of find_or_add_kept_section. Don't declare find_kept_object. * layout.cc (Layout::find_or_add_kept_section): Remove candidate parameter. Add object, shndx, is_comdat, and is_group_name parameters. Change all callers. Adjust for new Kept_section. (Layout::find_kept_object): Remove. * object.cc (Sized_relobj::include_section_group): Update use of Kept_section. Rename secnum to shndx. Only record Kept_comdat_section if sections are the same size. (Sized_relobj::include_linkonce_section): Update use of Kept_section. Only record Kept_comdat_section if sections are the same size. Set size of linkonce section. (Sized_relobj::map_to_kept_section): Update call to get_kept_comdat_section. * object.h (class Sized_relobj): Rename fields in Kept_comdat_section to drop trailing underscores; change object field to Relobj*. Change Kept_comdat_section_table to store struct rather than pointer. (Sized_relobj::set_kept_comdat_section): Remove kept parameter. Add kept_object and kept_shndx parameters. Change all callers. (Sized_relobj::get_kept_comdat_section): Change return type to bool. Add kept_object and kept_shndx parameters. Change all callers. * plugin.cc (Pluginobj::include_comdat_group): Update call to Layout::find_or_add_kept_section.
2009-07-17 03:07:33 +02:00
typedef std::map<unsigned int, Kept_comdat_section>
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
Kept_comdat_section_table;
// Find the SHT_SYMTAB section, given the section headers.
void
find_symtab(const unsigned char* pshdrs);
// Return whether SHDR has the right flags for a GNU style exception
// frame section.
bool
check_eh_frame_flags(const elfcpp::Shdr<size, big_endian>* shdr) const;
// Return whether there is a section named .eh_frame which might be
// a GNU style exception frame section.
bool
find_eh_frame(const unsigned char* pshdrs, const char* names,
section_size_type names_size) const;
// Whether to include a section group in the link.
bool
2008-02-06 09:13:50 +01:00
include_section_group(Symbol_table*, Layout*, unsigned int, const char*,
const unsigned char*, const char*, section_size_type,
std::vector<bool>*);
// Whether to include a linkonce section in the link.
bool
* layout.cc (Layout::include_section): Refactored check for debug info section. (Layout::add_comdat): Add new parameters. Change type of signature parameter. Add object and shndx to signatures table. (Layout::find_kept_object): New function. * layout.h: Include <cstring>. (Layout::is_debug_info_section): New function. (Layout::add_comdat): Add new parameters. (Layout::find_kept_object): New function. (Layout::Kept_section): New struct. (Layout::Signatures): Change type of map range. * object.cc (Relobj::output_section_address): New function. (Sized_relobj::include_section_group): Add new parameters. Change calls to Layout::add_comdat. Change to build table of kept comdat groups and table mapping discarded sections to kept sections. (Sized_relobj::include_linkonce_section): Likewise. Add new parameter. (Sized_relobj::do_layout): Change calls to include_section_group and include_linkonce_section. (Sized_relobj::do_finalize_local_symbols): Do not set local symbol value to zero when section is discarded. (Sized_relobj::map_to_kept_section): New function. * object.h (Relobj::output_section_address): New function. (Relobj::Comdat_group): New type. (Relobj::find_comdat_group): New function. (Relobj::Comdat_group_table): New type. (Relobj::Kept_comdat_section): New type. (Relobj::Kept_comdat_section_table): New type. (Relobj::add_comdat_group): New function. (Relobj::set_kept_comdat_section): New function. (Relobj::get_kept_comdat_section): New function. (Relobj::comdat_groups_): New field. (Relobj::kept_comdat_sections_): New field. (Symbol_value::input_value): Update comment. (Sized_relobj::map_to_kept_section) New function. (Sized_relobj::include_linkonce_section): Add new parameter. * target-reloc.h (Comdat_behavior): New type. (get_comdat_behavior): New function. (relocate_section): Add code to map a discarded section to the corresponding kept section when applying a relocation.
2008-05-01 03:23:21 +02:00
include_linkonce_section(Layout*, unsigned int, const char*,
const elfcpp::Shdr<size, big_endian>&);
// Layout an input section.
void
layout_section(Layout* layout, unsigned int shndx, const char* name,
Fix problem where mixed section types can cause internal error during a -r link. During a -r (or --emit-relocs) link, if two sections had the same name but different section types, gold would put relocations for both sections into the same relocation section even though the data sections remained separate. For .eh_frame sections, when one section is PROGBITS and another is X86_64_UNWIND, we really should be using the UNWIND section type and combining the sections anyway. For other sections, we should be creating one relocation section for each output data section. gold/ PR gold/23016 * incremental.cc (can_incremental_update): Check for unwind section type. * layout.h (Layout::layout): Add sh_type parameter. * layout.cc (Layout::layout): Likewise. (Layout::layout_reloc): Create new output reloc section if data section does not already have one. (Layout::layout_eh_frame): Check for unwind section type. (Layout::make_eh_frame_section): Use unwind section type for .eh_frame and .eh_frame_hdr. * object.h (Sized_relobj_file::Shdr_write): New typedef. (Sized_relobj_file::layout_section): Add sh_type parameter. (Sized_relobj_file::Deferred_layout::Deferred_layout): Add sh_type parameter. * object.cc (Sized_relobj_file::check_eh_frame_flags): Check for unwind section type. (Sized_relobj_file::layout_section): Add sh_type parameter; pass it to Layout::layout. (Sized_relobj_file::do_layout): Make local copy of sh_type. Force .eh_frame sections to unwind section type. Pass sh_type to layout_section. (Sized_relobj_file<size, big_endian>::do_layout_deferred_sections): Pass sh_type to layout_section. * output.cc (Output_section::Output_section): Initialize reloc_section_. * output.h (Output_section::reloc_section): New method. (Output_section::set_reloc_section): New method. (Output_section::reloc_section_): New data member. * target.h (Target::unwind_section_type): New method. (Target::Target_info::unwind_section_type): New data member. * aarch64.cc (aarch64_info): Add unwind_section_type. * arm.cc (arm_info, arm_nacl_info): Likewise. * i386.cc (i386_info, i386_nacl_info, iamcu_info): Likewise. * mips.cc (mips_info, mips_nacl_info): Likewise. * powerpc.cc (powerpc_info): Likewise. * s390.cc (s390_info): Likewise. * sparc.cc (sparc_info): Likewise. * tilegx.cc (tilegx_info): Likewise. * x86_64.cc (x86_64_info, x86_64_nacl_info): Likewise. * testsuite/Makefile.am (pr23016_1, pr23016_2): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/testfile.cc: Add unwind_section_type. * testsuite/pr23016_1.sh: New test script. * testsuite/pr23016_1a.s: New source file. * testsuite/pr23016_1b.s: New source file. * testsuite/pr23016_2.sh: New test script. * testsuite/pr23016_2a.s: New source file. * testsuite/pr23016_2b.s: New source file.
2018-04-03 01:12:10 +02:00
const typename This::Shdr& shdr, unsigned int sh_type,
unsigned int reloc_shndx, unsigned int reloc_type);
// Layout an input .eh_frame section.
void
layout_eh_frame_section(Layout* layout, const unsigned char* symbols_data,
section_size_type symbols_size,
const unsigned char* symbol_names_data,
section_size_type symbol_names_size,
unsigned int shndx, const typename This::Shdr&,
unsigned int reloc_shndx, unsigned int reloc_type);
2018-06-22 18:27:39 +02:00
// Layout an input .note.gnu.property section.
void
layout_gnu_property_section(Layout* layout, unsigned int shndx);
// Write section data to the output file. Record the views and
// sizes in VIEWS for use when relocating.
void
write_sections(const Layout*, const unsigned char* pshdrs, Output_file*,
Views*);
// Relocate the sections in the output file.
void
relocate_sections(const Symbol_table* symtab, const Layout* layout,
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
const unsigned char* pshdrs, Output_file* of,
Views* pviews)
{ this->do_relocate_sections(symtab, layout, pshdrs, of, pviews); }
// Reverse the words in a section. Used for .ctors sections mapped
// to .init_array sections.
void
reverse_words(unsigned char*, section_size_type);
2008-02-27 23:38:18 +01:00
// Scan the input relocations for --emit-relocs.
void
emit_relocs_scan(Symbol_table*, Layout*, const unsigned char* plocal_syms,
2008-02-27 23:38:18 +01:00
const Read_relocs_data::Relocs_list::iterator&);
// Scan the input relocations for --emit-relocs, templatized on the
// type of the relocation section.
template<int sh_type>
void
emit_relocs_scan_reltype(Symbol_table*, Layout*,
2008-02-27 23:38:18 +01:00
const unsigned char* plocal_syms,
const Read_relocs_data::Relocs_list::iterator&,
Relocatable_relocs*);
elfcpp/ChangeLog: * elfcpp.h (enum SHT): Add SHT_GNU_INCREMENTAL_SYMTAB, SHT_GNU_INCREMENTAL_RELOCS. gold/ChangeLog: * archive.cc: Include incremental.h. (Archive::Archive): Initialize incremental_info_. (Archive::include_member): Record archive members in incremental info. (Add_archive_symbols::run): Record begin and end of an archive in incremental info. (Lib_group::include_member): Record objects in incremental info. * archive.h (Incremental_archive_entry): Forward declaration. (Archive::set_incremental_info): New member function. (Archive::incremental_info): New member function. (Archive::Unused_symbol_iterator): New class. (Archive::unused_symbols_begin): New member function. (Archive::unused_symbols_end): New member function. (Archive::incremental_info_): New data member. * incremental-dump.cc (find_input_containing_global): New function. (dump_incremental_inputs): Dump new incremental info sections. * incremental.cc: Include symtab.h. (Output_section_incremental_inputs): New class. (Sized_incremental_binary::do_find_incremental_inputs_sections): Support new incremental info sections. (Sized_incremental_binary::do_check_inputs): Likewise. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): New function. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Rewrite. (Incremental_inputs::finalize): Do nothing but finalize string table. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::relocs_entsize): New function. (Output_section_incremental_inputs::set_final_data_size): New function. (Output_section_incremental_inputs::do_write): New function. (Output_section_incremental_inputs::write_header): New function. (Output_section_incremental_inputs::write_input_files): New function. (Output_section_incremental_inputs::write_info_blocks): New function. (Output_section_incremental_inputs::write_symtab): New function. * incremental.h (Incremental_script_entry): Forward declaration. (Incremental_object_entry): Forward declaration. (Incremental_archive_entry): Forward declaration. (Incremental_inputs): Forward declaration. (Incremental_inputs_header_data): Remove. (Incremental_inputs_header): Remove. (Incremental_inputs_header_write): Remove. (Incremental_inputs_entry_data): Remove. (Incremental_inputs_entry): Remove. (Incremental_inputs_entry_write): Remove. (enum Incremental_input_type): Add INCREMENTAL_INPUT_ARCHIVE_MEMBER. (Incremental_binary::find_incremental_inputs_sections): Add parameters. (Incremental_binary::do_find_incremental_inputs_sections): Likewise. (Sized_ncremental_binary::do_find_incremental_inputs_sections): Likewise. (Incremental_input_entry): New class. (Incremental_script_entry): New class. (Incremental_object_entry): New class. (Incremental_archive_entry): New class. (Incremental_inputs::Incremental_inputs): Initialize new data members. (Incremental_inputs::report_inputs): Remove. (Incremental_inputs::report_archive): Remove. (Incremental_inputs::report_archive_begin): New function. (Incremental_inputs::report_archive_end): New function. (Incremental_inputs::report_object): Change prototype. (Incremental_inputs::report_input_section): New function. (Incremental_inputs::report_script): Change prototype. (Incremental_inputs::get_reloc_count): New function. (Incremental_inputs::set_reloc_count): New function. (Incremental_inputs::create_data_sections): New function. (Incremental_inputs::create_incremental_inputs_section_data): Remove. (Incremental_inputs::inputs_section): New function. (Incremental_inputs::symtab_section): New function. (Incremental_inputs::relocs_section): New function. (Incremental_inputs::get_stringpool): Add const. (Incremental_inputs::command_line): Add const. (Incremental_inputs::inputs): Remove. (Incremental_inputs::command_line_key): New function. (Incremental_inputs::input_file_count): New function. (Incremental_inputs::input_files): New function. (Incremental_inputs::relocs_entsize): New function. (Incremental_inputs::sized_create_inputs_section_data): Remove. (Incremental_inputs::finalize_inputs): Remove. (Incremental_inputs::Input_info): Remove. (Incremental_inputs::lock_): Remove. (Incremental_inputs::inputs_): Change type. (Incremental_inputs::inputs_map_): Remove. (Incremental_inputs::current_object_entry_): New data member. (Incremental_inputs::inputs_section_): New data member. (Incremental_inputs::symtab_section_): New data member. (Incremental_inputs::relocs_section_): New data member. (Incremental_inputs::reloc_count_): New data member. (Incremental_inputs_reader): New class. (Incremental_symtab_reader): New class. (Incremental_relocs_reader): New class. * layout.cc (Layout::finalize): Move finalization of incremental info and creation of incremental info sections to follow finalization of symbol table. Set offsets for postprocessing sections. (Layout::create_incremental_info_sections): Call Incremental_inputs::create_data_sections. Add incremental symtab and relocs sections. Set sh_entsize and sh_link fields. Arrange for sections to layout after input sections. * layout.h (struct Timespec): Forward declaration. (Layout::incremental_inputs): Add const. (Layout::create_incremental_info_sections): Add parameter. * main.cc (main): Remove call to Incremental_inputs::report_inputs. * object.cc: Include incremental.h. (Relobj::finalize_incremental_relocs): New function. (Sized_relobj::do_layout): Record input sections in incremental info. * object.h (Object::output_section): New function. (Object::output_section_offset): Moved from Relobj. (Object::get_incremental_reloc_base): New function. (Object::get_incremental_reloc_count): New function. (Object::do_output_section): New function. (Object::do_output_section_offset): Moved from Relobj. (Object::do_get_incremental_reloc_base): New function. (Object::do_get_incremental_reloc_count): New function. (Object::Object): Initialize new data members. (Relobj::output_section): Renamed do_output_section and moved to protected. (Relobj::output_section_offset): Moved to Object. (Relobj::do_get_incremental_reloc_base): New function. (Relobj::do_get_incremental_reloc_count): New function. (Relobj::allocate_incremental_reloc_counts): New function. (Relobj::count_incremental_reloc): New function. (Relobj::finalize_incremental_relocs): New function. (Relobj::next_incremental_reloc_index): New function. (Relobj::reloc_counts_): New data member. (Relobj::reloc_bases_): New data member. (Sized_relobj::do_relocate_sections): Add parameter. Change caller. (Sized_relobj::relocate_sections): Add parameter. Change all callers. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * plugin.cc (Plugin_manager::add_input_file): Rewrite test for incremental link. * readsyms.cc (Read_symbols::do_read_symbols): Move reporting of archives and object files elsewhere. (Add_symbols::run): Report object files here. (Finish_group::run): Report end of archive at end of group. * reloc.cc: Include layout.h, incremental.h. (Sized_relobj::do_read_relocs): Need relocations for incremental link. (Sized_relobj::do_scan_relocs): Record relocations for incremental link. (Sized_relobj::incremental_relocs_scan): New function. (Sized_relobj::incremental_relocs_scan_reltype): New function. (Sized_relobj::do_relocate_sections): Write incremental relocations. (Sized_relobj::incremental_relocs_write): New function. (Sized_relobj::incremental_relocs_write_reltype): New function. * script.cc (read_input_script): Rewrite test for incremental link. Change call to Incremental_inputs::report_script. * symtab.h (Symbol_table::first_global_index): New function. (Symbol_table::output_count): New function.
2010-08-13 00:01:11 +02:00
// Scan the input relocations for --incremental.
void
incremental_relocs_scan(const Read_relocs_data::Relocs_list::iterator&);
// Scan the input relocations for --incremental, templatized on the
// type of the relocation section.
template<int sh_type>
void
incremental_relocs_scan_reltype(
const Read_relocs_data::Relocs_list::iterator&);
void
incremental_relocs_write(const Relocate_info<size, big_endian>*,
unsigned int sh_type,
const unsigned char* prelocs,
size_t reloc_count,
Output_section*,
Address output_offset,
Output_file*);
template<int sh_type>
void
incremental_relocs_write_reltype(const Relocate_info<size, big_endian>*,
const unsigned char* prelocs,
size_t reloc_count,
Output_section*,
Address output_offset,
Output_file*);
* options.h (class General_options): Define split_stack_adjust_size parameter. * object.h (class Object): Add uses_split_stack_ and has_no_split_stack_ fields. Add uses_split_stack and has_no_split_stack accessor functions. Declare handle_split_stack_section. (class Reloc_symbol_changes): Define. (class Sized_relobj): Define Function_offsets. Declare split_stack_adjust, split_stack_adjust_reltype, and find_functions. * object.cc (Object::handle_split_stack_section): New function. (Sized_relobj::do_layout): Call handle_split_stack_section. * dynobj.cc (Sized_dynobj::do_layout): Call handle_split_stack_section. * reloc.cc (Sized_relobj::relocate_sections): Call split_stack_adjust for executable sections in split_stack objects. Pass reloc_map to relocate_section. (Sized_relobj::split_stack_adjust): New function. (Sized_relobj::split_stack_adjust_reltype): New function. (Sized_relobj::find_functions): New function. * target-reloc.h: Include "object.h". (relocate_section): Add reloc_symbol_changes parameter. Change all callers. * target.h (class Target): Add calls_non_split method. Declare do_calls_non_split virtual method. Declare match_view and set_view_to_nop. * target.cc: Include "elfcpp.h". (Target::do_calls_non_split): New function. (Target::match_view): New function. (Target::set_view_to_nop): New function. * gold.cc (queue_middle_tasks): Give an error if mixing split-stack and non-split-stack objects with -r. * i386.cc (Target_i386::relocate_section): Add reloc_symbol_changes parameter. (Target_i386::do_calls_non_split): New function. * x86_64.cc (Target_x86_64::relocate_section): Add reloc_symbol_changes parameter. (Target_x86_64::do_calls_non_split): New function. * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes parameter. * powerpc.cc (Target_powerpc::relocate_section): Add reloc_symbol_changes parameter. * sparc.cc (Target_sparc::relocate_section): Add reloc_symbol_changes parameter. * configure.ac: Call AM_CONDITIONAL for the default target. * configure: Rebuild. * testsuite/Makefile.am (TEST_AS): New variable. (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh. (check_DATA): Add split_i386 and split_x86_64 files. (SPLIT_DEFSYMS): Define. (split_i386_[1234n].o): New targets. (split_i386_[124]): New targets. (split_i386_[1234r].stdout): New targets. (split_x86_64_[1234n].o): New targets. (split_x86_64_[124]): New targets. (split_x86_64_[1234r].stdout): New targets. (MOSTLYCLEANFILES): Add new executables. * testsuite/split_i386.sh: New file. * testsuite/split_x86_64.sh: New file. * testsuite/split_i386_1.s: New file. * testsuite/split_i386_2.s: New file. * testsuite/split_i386_3.s: New file. * testsuite/split_i386_4.s: New file. * testsuite/split_i386_n.s: New file. * testsuite/split_x86_64_1.s: New file. * testsuite/split_x86_64_2.s: New file. * testsuite/split_x86_64_3.s: New file. * testsuite/split_x86_64_4.s: New file. * testsuite/split_x86_64_n.s: New file. * testsuite/testfile.cc (Target_test): Update relocation_section function. * testsuite/Makefile.in: Rebuild.
2009-10-07 00:58:27 +02:00
// A type shared by split_stack_adjust_reltype and find_functions.
typedef std::map<section_offset_type, section_size_type> Function_offsets;
// Check for -fsplit-stack routines calling non-split-stack routines.
void
split_stack_adjust(const Symbol_table*, const unsigned char* pshdrs,
unsigned int sh_type, unsigned int shndx,
const unsigned char* prelocs, size_t reloc_count,
unsigned char* view, section_size_type view_size,
Refactor gold to enable support for MIPS-64 relocation format. For MIPS-64, the r_info field in the relocation format is replaced by several individual fields, including r_sym and r_type. To enable support for this format, I've refactored target-independent code to remove almost all uses of the r_info field. (I've left alone a couple of routines used only for incremental linking, which I can update if/when the MIPS target adds support for incremental linking.) For routines that are already templated on a Classify_reloc class (namely, gc_process_relocs, relocate_section, and relocate_relocs), I've extended the Classify_reloc interface to include sh_type (which no longer needs to be a separate template parameter) as well as get_r_sym() and get_r_type() methods for extracting the r_sym and r_type fields. For scan_relocatable_relocs, I've extended the Default_scan_relocatable_relocs class by converting it to a class template with Classify_reloc as a template parameter. For the remaining routines that need to access r_sym, I've added a virtual Target::get_r_sym() method with an override for the MIPS target. In elfcpp, I've added Mips64_rel, etc., accessor classes and corresponding internal data structures. The MIPS target uses these new classes within its own Mips_classify_reloc class. The Mips64_ accessor classes also expose the r_ssym, r_type2, and r_type3 fields from the relocation. These changes should be functionally the same for all but the MIPS target. elfcpp/ * elfcpp.h (Mips64_rel, Mips64_rel_write): New classes. (Mips64_rela, Mips64_rela_write): New classes. * elfcpp_internal.h (Mips64_rel_data, Mips64_rela_data): New structs. gold/ * gc.h (get_embedded_addend_size): Remove sh_type parameter. (gc_process_relocs): Remove sh_type template parameter. Use Classify_reloc to access r_sym, r_type, and r_addend fields. * object.h (Sized_relobj_file::split_stack_adjust): Add target parameter. (Sized_relobj_file::split_stack_adjust_reltype): Likewise. * reloc-types.h (Reloc_types::copy_reloc_addend): (SHT_REL and SHT_RELA specializations) Remove. * reloc.cc (Emit_relocs_strategy): Rename and move to target-reloc.h. (Sized_relobj_file::emit_relocs_scan): Call Target::emit_relocs_scan(). (Sized_relobj_file::emit_relocs_scan_reltype): Remove. (Sized_relobj_file::split_stack_adjust): Add target parameter. Adjust all callers. (Sized_relobj_file::split_stack_adjust_reltype): Likewise. Call Target::get_r_sym() to get r_sym field from relocations. (Track_relocs::next_symndx): Call Target::get_r_sym(). * target-reloc.h (scan_relocs): Remove sh_type template parameter; add Classify_reloc template parameter. Use for accessing r_sym and r_type. (relocate_section): Likewise. (Default_classify_reloc): New class (renamed and moved from reloc.cc). (Default_scan_relocatable_relocs): Remove sh_type template parameter. (Default_scan_relocatable_relocs::Reltype): New typedef. (Default_scan_relocatable_relocs::reloc_size): New const. (Default_scan_relocatable_relocs::sh_type): New const. (Default_scan_relocatable_relocs::get_r_sym): New method. (Default_scan_relocatable_relocs::get_r_type): New method. (Default_emit_relocs_strategy): New class. (scan_relocatable_relocs): Replace sh_type template parameter with Scan_relocatable_relocs class. Use it to access r_sym and r_type fields. (relocate_relocs): Replace sh_type template parameter with Classify_reloc class. Use it to access r_sym and r_type fields. * target.h (Target::is_call_to_non_split): Replace r_type parameter with pointer to relocation. Adjust all callers. (Target::do_is_call_to_non_split): Likewise. (Target::emit_relocs_scan): New virtual method. (Sized_target::get_r_sym): New virtual method. * target.cc (Target::do_is_call_to_non_split): Replace r_type parameter with pointer to relocation. * aarch64.cc (Target_aarch64::emit_relocs_scan): New method. (Target_aarch64::Relocatable_size_for_reloc): Remove. (Target_aarch64::gc_process_relocs): Use Default_classify_reloc. (Target_aarch64::scan_relocs): Likewise. (Target_aarch64::relocate_section): Likewise. (Target_aarch64::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_aarch64::scan_relocatable_relocs): Use Default_classify_reloc. (Target_aarch64::relocate_relocs): Use Default_classify_reloc. * arm.cc (Target_arm::Arm_scan_relocatable_relocs): Remove sh_type template parameter. (Target_arm::emit_relocs_scan): New method. (Target_arm::Relocatable_size_for_reloc): Replace with... (Target_arm::Classify_reloc): ...this. (Target_arm::gc_process_relocs): Use Classify_reloc. (Target_arm::scan_relocs): Likewise. (Target_arm::relocate_section): Likewise. (Target_arm::scan_relocatable_relocs): Likewise. (Target_arm::relocate_relocs): Likewise. * i386.cc (Target_i386::emit_relocs_scan): New method. (Target_i386::Relocatable_size_for_reloc): Replace with... (Target_i386::Classify_reloc): ...this. (Target_i386::gc_process_relocs): Use Classify_reloc. (Target_i386::scan_relocs): Likewise. (Target_i386::relocate_section): Likewise. (Target_i386::scan_relocatable_relocs): Likewise. (Target_i386::relocate_relocs): Likewise. * mips.cc (Mips_scan_relocatable_relocs): Remove sh_type template parameter. (Mips_reloc_types): New class template. (Mips_classify_reloc): New class template. (Target_mips::Reltype): New typedef. (Target_mips::Relatype): New typedef. (Target_mips::emit_relocs_scan): New method. (Target_mips::get_r_sym): New method. (Target_mips::Relocatable_size_for_reloc): Replace with Mips_classify_reloc. (Target_mips::copy_reloc): Use Mips_classify_reloc. (Target_mips::gc_process_relocs): Likewise. (Target_mips::scan_relocs): Likewise. (Target_mips::relocate_section): Likewise. (Target_mips::scan_relocatable_relocs): Likewise. (Target_mips::relocate_relocs): Likewise. (mips_get_size_for_reloc): New function, factored out from Relocatable_size_for_reloc::get_size_for_reloc. (Target_mips::Scan::local): Use Mips_classify_reloc. (Target_mips::Scan::global): Likewise. (Target_mips::Relocate::relocate): Likewise. * powerpc.cc (Target_powerpc::emit_relocs_scan): New method. (Target_powerpc::Relocatable_size_for_reloc): Remove. (Target_powerpc::gc_process_relocs): Use Default_classify_reloc. (Target_powerpc::scan_relocs): Likewise. (Target_powerpc::relocate_section): Likewise. (Powerpc_scan_relocatable_reloc): Convert to class template. (Powerpc_scan_relocatable_reloc::Reltype): New typedef. (Powerpc_scan_relocatable_reloc::reloc_size): New const. (Powerpc_scan_relocatable_reloc::sh_type): New const. (Powerpc_scan_relocatable_reloc::get_r_sym): New method. (Powerpc_scan_relocatable_reloc::get_r_type): New method. (Target_powerpc::scan_relocatable_relocs): Use Powerpc_scan_relocatable_reloc. (Target_powerpc::relocate_relocs): Use Default_classify_reloc. * s390.cc (Target_s390::emit_relocs_scan): New method. (Target_s390::Relocatable_size_for_reloc): Remove. (Target_s390::gc_process_relocs): Use Default_classify_reloc. (Target_s390::scan_relocs): Likewise. (Target_s390::relocate_section): Likewise. (Target_s390::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_s390::scan_relocatable_relocs): Use Default_classify_reloc. (Target_s390::relocate_relocs): Use Default_classify_reloc. * sparc.cc (Target_sparc::emit_relocs_scan): New method. (Target_sparc::Relocatable_size_for_reloc): Remove. (Target_sparc::gc_process_relocs): Use Default_classify_reloc. (Target_sparc::scan_relocs): Likewise. (Target_sparc::relocate_section): Likewise. (Target_sparc::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_sparc::scan_relocatable_relocs): Use Default_classify_reloc. (Target_sparc::relocate_relocs): Use Default_classify_reloc. * tilegx.cc (Target_tilegx::emit_relocs_scan): New method. (Target_tilegx::Relocatable_size_for_reloc): Remove. (Target_tilegx::gc_process_relocs): Use Default_classify_reloc. (Target_tilegx::scan_relocs): Likewise. (Target_tilegx::relocate_section): Likewise. (Target_tilegx::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_tilegx::scan_relocatable_relocs): Use Default_classify_reloc. (Target_tilegx::relocate_relocs): Use Default_classify_reloc. * x86_64.cc (Target_x86_64::emit_relocs_scan): New method. (Target_x86_64::Relocatable_size_for_reloc): Remove. (Target_x86_64::gc_process_relocs): Use Default_classify_reloc. (Target_x86_64::scan_relocs): Likewise. (Target_x86_64::relocate_section): Likewise. (Target_x86_64::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_x86_64::scan_relocatable_relocs): Use Default_classify_reloc. (Target_x86_64::relocate_relocs): Use Default_classify_reloc. * testsuite/testfile.cc (Target_test::emit_relocs_scan): New method.
2015-12-11 16:43:59 +01:00
Reloc_symbol_changes** reloc_map,
const Sized_target<size, big_endian>* target);
* options.h (class General_options): Define split_stack_adjust_size parameter. * object.h (class Object): Add uses_split_stack_ and has_no_split_stack_ fields. Add uses_split_stack and has_no_split_stack accessor functions. Declare handle_split_stack_section. (class Reloc_symbol_changes): Define. (class Sized_relobj): Define Function_offsets. Declare split_stack_adjust, split_stack_adjust_reltype, and find_functions. * object.cc (Object::handle_split_stack_section): New function. (Sized_relobj::do_layout): Call handle_split_stack_section. * dynobj.cc (Sized_dynobj::do_layout): Call handle_split_stack_section. * reloc.cc (Sized_relobj::relocate_sections): Call split_stack_adjust for executable sections in split_stack objects. Pass reloc_map to relocate_section. (Sized_relobj::split_stack_adjust): New function. (Sized_relobj::split_stack_adjust_reltype): New function. (Sized_relobj::find_functions): New function. * target-reloc.h: Include "object.h". (relocate_section): Add reloc_symbol_changes parameter. Change all callers. * target.h (class Target): Add calls_non_split method. Declare do_calls_non_split virtual method. Declare match_view and set_view_to_nop. * target.cc: Include "elfcpp.h". (Target::do_calls_non_split): New function. (Target::match_view): New function. (Target::set_view_to_nop): New function. * gold.cc (queue_middle_tasks): Give an error if mixing split-stack and non-split-stack objects with -r. * i386.cc (Target_i386::relocate_section): Add reloc_symbol_changes parameter. (Target_i386::do_calls_non_split): New function. * x86_64.cc (Target_x86_64::relocate_section): Add reloc_symbol_changes parameter. (Target_x86_64::do_calls_non_split): New function. * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes parameter. * powerpc.cc (Target_powerpc::relocate_section): Add reloc_symbol_changes parameter. * sparc.cc (Target_sparc::relocate_section): Add reloc_symbol_changes parameter. * configure.ac: Call AM_CONDITIONAL for the default target. * configure: Rebuild. * testsuite/Makefile.am (TEST_AS): New variable. (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh. (check_DATA): Add split_i386 and split_x86_64 files. (SPLIT_DEFSYMS): Define. (split_i386_[1234n].o): New targets. (split_i386_[124]): New targets. (split_i386_[1234r].stdout): New targets. (split_x86_64_[1234n].o): New targets. (split_x86_64_[124]): New targets. (split_x86_64_[1234r].stdout): New targets. (MOSTLYCLEANFILES): Add new executables. * testsuite/split_i386.sh: New file. * testsuite/split_x86_64.sh: New file. * testsuite/split_i386_1.s: New file. * testsuite/split_i386_2.s: New file. * testsuite/split_i386_3.s: New file. * testsuite/split_i386_4.s: New file. * testsuite/split_i386_n.s: New file. * testsuite/split_x86_64_1.s: New file. * testsuite/split_x86_64_2.s: New file. * testsuite/split_x86_64_3.s: New file. * testsuite/split_x86_64_4.s: New file. * testsuite/split_x86_64_n.s: New file. * testsuite/testfile.cc (Target_test): Update relocation_section function. * testsuite/Makefile.in: Rebuild.
2009-10-07 00:58:27 +02:00
template<int sh_type>
void
split_stack_adjust_reltype(const Symbol_table*, const unsigned char* pshdrs,
unsigned int shndx, const unsigned char* prelocs,
size_t reloc_count, unsigned char* view,
section_size_type view_size,
Refactor gold to enable support for MIPS-64 relocation format. For MIPS-64, the r_info field in the relocation format is replaced by several individual fields, including r_sym and r_type. To enable support for this format, I've refactored target-independent code to remove almost all uses of the r_info field. (I've left alone a couple of routines used only for incremental linking, which I can update if/when the MIPS target adds support for incremental linking.) For routines that are already templated on a Classify_reloc class (namely, gc_process_relocs, relocate_section, and relocate_relocs), I've extended the Classify_reloc interface to include sh_type (which no longer needs to be a separate template parameter) as well as get_r_sym() and get_r_type() methods for extracting the r_sym and r_type fields. For scan_relocatable_relocs, I've extended the Default_scan_relocatable_relocs class by converting it to a class template with Classify_reloc as a template parameter. For the remaining routines that need to access r_sym, I've added a virtual Target::get_r_sym() method with an override for the MIPS target. In elfcpp, I've added Mips64_rel, etc., accessor classes and corresponding internal data structures. The MIPS target uses these new classes within its own Mips_classify_reloc class. The Mips64_ accessor classes also expose the r_ssym, r_type2, and r_type3 fields from the relocation. These changes should be functionally the same for all but the MIPS target. elfcpp/ * elfcpp.h (Mips64_rel, Mips64_rel_write): New classes. (Mips64_rela, Mips64_rela_write): New classes. * elfcpp_internal.h (Mips64_rel_data, Mips64_rela_data): New structs. gold/ * gc.h (get_embedded_addend_size): Remove sh_type parameter. (gc_process_relocs): Remove sh_type template parameter. Use Classify_reloc to access r_sym, r_type, and r_addend fields. * object.h (Sized_relobj_file::split_stack_adjust): Add target parameter. (Sized_relobj_file::split_stack_adjust_reltype): Likewise. * reloc-types.h (Reloc_types::copy_reloc_addend): (SHT_REL and SHT_RELA specializations) Remove. * reloc.cc (Emit_relocs_strategy): Rename and move to target-reloc.h. (Sized_relobj_file::emit_relocs_scan): Call Target::emit_relocs_scan(). (Sized_relobj_file::emit_relocs_scan_reltype): Remove. (Sized_relobj_file::split_stack_adjust): Add target parameter. Adjust all callers. (Sized_relobj_file::split_stack_adjust_reltype): Likewise. Call Target::get_r_sym() to get r_sym field from relocations. (Track_relocs::next_symndx): Call Target::get_r_sym(). * target-reloc.h (scan_relocs): Remove sh_type template parameter; add Classify_reloc template parameter. Use for accessing r_sym and r_type. (relocate_section): Likewise. (Default_classify_reloc): New class (renamed and moved from reloc.cc). (Default_scan_relocatable_relocs): Remove sh_type template parameter. (Default_scan_relocatable_relocs::Reltype): New typedef. (Default_scan_relocatable_relocs::reloc_size): New const. (Default_scan_relocatable_relocs::sh_type): New const. (Default_scan_relocatable_relocs::get_r_sym): New method. (Default_scan_relocatable_relocs::get_r_type): New method. (Default_emit_relocs_strategy): New class. (scan_relocatable_relocs): Replace sh_type template parameter with Scan_relocatable_relocs class. Use it to access r_sym and r_type fields. (relocate_relocs): Replace sh_type template parameter with Classify_reloc class. Use it to access r_sym and r_type fields. * target.h (Target::is_call_to_non_split): Replace r_type parameter with pointer to relocation. Adjust all callers. (Target::do_is_call_to_non_split): Likewise. (Target::emit_relocs_scan): New virtual method. (Sized_target::get_r_sym): New virtual method. * target.cc (Target::do_is_call_to_non_split): Replace r_type parameter with pointer to relocation. * aarch64.cc (Target_aarch64::emit_relocs_scan): New method. (Target_aarch64::Relocatable_size_for_reloc): Remove. (Target_aarch64::gc_process_relocs): Use Default_classify_reloc. (Target_aarch64::scan_relocs): Likewise. (Target_aarch64::relocate_section): Likewise. (Target_aarch64::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_aarch64::scan_relocatable_relocs): Use Default_classify_reloc. (Target_aarch64::relocate_relocs): Use Default_classify_reloc. * arm.cc (Target_arm::Arm_scan_relocatable_relocs): Remove sh_type template parameter. (Target_arm::emit_relocs_scan): New method. (Target_arm::Relocatable_size_for_reloc): Replace with... (Target_arm::Classify_reloc): ...this. (Target_arm::gc_process_relocs): Use Classify_reloc. (Target_arm::scan_relocs): Likewise. (Target_arm::relocate_section): Likewise. (Target_arm::scan_relocatable_relocs): Likewise. (Target_arm::relocate_relocs): Likewise. * i386.cc (Target_i386::emit_relocs_scan): New method. (Target_i386::Relocatable_size_for_reloc): Replace with... (Target_i386::Classify_reloc): ...this. (Target_i386::gc_process_relocs): Use Classify_reloc. (Target_i386::scan_relocs): Likewise. (Target_i386::relocate_section): Likewise. (Target_i386::scan_relocatable_relocs): Likewise. (Target_i386::relocate_relocs): Likewise. * mips.cc (Mips_scan_relocatable_relocs): Remove sh_type template parameter. (Mips_reloc_types): New class template. (Mips_classify_reloc): New class template. (Target_mips::Reltype): New typedef. (Target_mips::Relatype): New typedef. (Target_mips::emit_relocs_scan): New method. (Target_mips::get_r_sym): New method. (Target_mips::Relocatable_size_for_reloc): Replace with Mips_classify_reloc. (Target_mips::copy_reloc): Use Mips_classify_reloc. (Target_mips::gc_process_relocs): Likewise. (Target_mips::scan_relocs): Likewise. (Target_mips::relocate_section): Likewise. (Target_mips::scan_relocatable_relocs): Likewise. (Target_mips::relocate_relocs): Likewise. (mips_get_size_for_reloc): New function, factored out from Relocatable_size_for_reloc::get_size_for_reloc. (Target_mips::Scan::local): Use Mips_classify_reloc. (Target_mips::Scan::global): Likewise. (Target_mips::Relocate::relocate): Likewise. * powerpc.cc (Target_powerpc::emit_relocs_scan): New method. (Target_powerpc::Relocatable_size_for_reloc): Remove. (Target_powerpc::gc_process_relocs): Use Default_classify_reloc. (Target_powerpc::scan_relocs): Likewise. (Target_powerpc::relocate_section): Likewise. (Powerpc_scan_relocatable_reloc): Convert to class template. (Powerpc_scan_relocatable_reloc::Reltype): New typedef. (Powerpc_scan_relocatable_reloc::reloc_size): New const. (Powerpc_scan_relocatable_reloc::sh_type): New const. (Powerpc_scan_relocatable_reloc::get_r_sym): New method. (Powerpc_scan_relocatable_reloc::get_r_type): New method. (Target_powerpc::scan_relocatable_relocs): Use Powerpc_scan_relocatable_reloc. (Target_powerpc::relocate_relocs): Use Default_classify_reloc. * s390.cc (Target_s390::emit_relocs_scan): New method. (Target_s390::Relocatable_size_for_reloc): Remove. (Target_s390::gc_process_relocs): Use Default_classify_reloc. (Target_s390::scan_relocs): Likewise. (Target_s390::relocate_section): Likewise. (Target_s390::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_s390::scan_relocatable_relocs): Use Default_classify_reloc. (Target_s390::relocate_relocs): Use Default_classify_reloc. * sparc.cc (Target_sparc::emit_relocs_scan): New method. (Target_sparc::Relocatable_size_for_reloc): Remove. (Target_sparc::gc_process_relocs): Use Default_classify_reloc. (Target_sparc::scan_relocs): Likewise. (Target_sparc::relocate_section): Likewise. (Target_sparc::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_sparc::scan_relocatable_relocs): Use Default_classify_reloc. (Target_sparc::relocate_relocs): Use Default_classify_reloc. * tilegx.cc (Target_tilegx::emit_relocs_scan): New method. (Target_tilegx::Relocatable_size_for_reloc): Remove. (Target_tilegx::gc_process_relocs): Use Default_classify_reloc. (Target_tilegx::scan_relocs): Likewise. (Target_tilegx::relocate_section): Likewise. (Target_tilegx::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_tilegx::scan_relocatable_relocs): Use Default_classify_reloc. (Target_tilegx::relocate_relocs): Use Default_classify_reloc. * x86_64.cc (Target_x86_64::emit_relocs_scan): New method. (Target_x86_64::Relocatable_size_for_reloc): Remove. (Target_x86_64::gc_process_relocs): Use Default_classify_reloc. (Target_x86_64::scan_relocs): Likewise. (Target_x86_64::relocate_section): Likewise. (Target_x86_64::Relocatable_size_for_reloc::get_size_for_reloc): Remove. (Target_x86_64::scan_relocatable_relocs): Use Default_classify_reloc. (Target_x86_64::relocate_relocs): Use Default_classify_reloc. * testsuite/testfile.cc (Target_test::emit_relocs_scan): New method.
2015-12-11 16:43:59 +01:00
Reloc_symbol_changes** reloc_map,
const Sized_target<size, big_endian>* target);
* options.h (class General_options): Define split_stack_adjust_size parameter. * object.h (class Object): Add uses_split_stack_ and has_no_split_stack_ fields. Add uses_split_stack and has_no_split_stack accessor functions. Declare handle_split_stack_section. (class Reloc_symbol_changes): Define. (class Sized_relobj): Define Function_offsets. Declare split_stack_adjust, split_stack_adjust_reltype, and find_functions. * object.cc (Object::handle_split_stack_section): New function. (Sized_relobj::do_layout): Call handle_split_stack_section. * dynobj.cc (Sized_dynobj::do_layout): Call handle_split_stack_section. * reloc.cc (Sized_relobj::relocate_sections): Call split_stack_adjust for executable sections in split_stack objects. Pass reloc_map to relocate_section. (Sized_relobj::split_stack_adjust): New function. (Sized_relobj::split_stack_adjust_reltype): New function. (Sized_relobj::find_functions): New function. * target-reloc.h: Include "object.h". (relocate_section): Add reloc_symbol_changes parameter. Change all callers. * target.h (class Target): Add calls_non_split method. Declare do_calls_non_split virtual method. Declare match_view and set_view_to_nop. * target.cc: Include "elfcpp.h". (Target::do_calls_non_split): New function. (Target::match_view): New function. (Target::set_view_to_nop): New function. * gold.cc (queue_middle_tasks): Give an error if mixing split-stack and non-split-stack objects with -r. * i386.cc (Target_i386::relocate_section): Add reloc_symbol_changes parameter. (Target_i386::do_calls_non_split): New function. * x86_64.cc (Target_x86_64::relocate_section): Add reloc_symbol_changes parameter. (Target_x86_64::do_calls_non_split): New function. * arm.cc (Target_arm::relocate_section): Add reloc_symbol_changes parameter. * powerpc.cc (Target_powerpc::relocate_section): Add reloc_symbol_changes parameter. * sparc.cc (Target_sparc::relocate_section): Add reloc_symbol_changes parameter. * configure.ac: Call AM_CONDITIONAL for the default target. * configure: Rebuild. * testsuite/Makefile.am (TEST_AS): New variable. (check_SCRIPTS): Add split_i386.sh and split_x86_64.sh. (check_DATA): Add split_i386 and split_x86_64 files. (SPLIT_DEFSYMS): Define. (split_i386_[1234n].o): New targets. (split_i386_[124]): New targets. (split_i386_[1234r].stdout): New targets. (split_x86_64_[1234n].o): New targets. (split_x86_64_[124]): New targets. (split_x86_64_[1234r].stdout): New targets. (MOSTLYCLEANFILES): Add new executables. * testsuite/split_i386.sh: New file. * testsuite/split_x86_64.sh: New file. * testsuite/split_i386_1.s: New file. * testsuite/split_i386_2.s: New file. * testsuite/split_i386_3.s: New file. * testsuite/split_i386_4.s: New file. * testsuite/split_i386_n.s: New file. * testsuite/split_x86_64_1.s: New file. * testsuite/split_x86_64_2.s: New file. * testsuite/split_x86_64_3.s: New file. * testsuite/split_x86_64_4.s: New file. * testsuite/split_x86_64_n.s: New file. * testsuite/testfile.cc (Target_test): Update relocation_section function. * testsuite/Makefile.in: Rebuild.
2009-10-07 00:58:27 +02:00
// Find all functions in a section.
void
find_functions(const unsigned char* pshdrs, unsigned int shndx,
Function_offsets*);
// Write out the local symbols.
void
2007-05-16 19:42:48 +02:00
write_local_symbols(Output_file*,
const Stringpool_template<char>*,
* object.cc (Xindex::initialize_symtab_xindex): New function. (Xindex::read_symtab_xindex): New function. (Xindex::sym_xindex_to_shndx): New function. (Sized_relobj::find_symtab): Pick up SHT_SYMTAB_SHNDX section if available. (Sized_relobj::do_initialize_xindex): New function. (Sized_relobj::do_read_symbols): Adjust section links. (Sized_relobj::symbol_section_and_value): Add is_ordinary parameter. Change all callers. (Sized_relobj::include_section_group): Adjust section links and symbol section indexes. (Sized_relobj::do_layout): Adjust section links. (Sized_relobj::do_count_local_symbols): Adjust section links and symbol section indexes. (Sized_relobj::do_finalize_local_symbols): Distinguish between ordinary and special symbols. (Sized_relobj::write_local_symbols): Add symtab_xindex and dynsym_xindex parameters. Change all callers. Adjust section links. Use SHN_XINDEX when needed. (Sized_relobj::get_symbol_location_info): Adjust section links. Don't get fooled by special symbols. * object.h (class Xindex): Define. (class Object): Add xindex_ parameter. Declare virtual functoin do_initialize_xindex. (Object::adjust_sym_shndx): New function. (Object::set_xindex): New protected function. (class Symbol_value): Add is_ordinary_shndx_ field. (Symbol_value::Symbol_value): Initialize is_ordinary_shndx_. (Symbol_value::value): Assert ordinary section. (Symbol_value::initialize_input_to_output_map): Likewise. (Symbol_value::set_input_shndx): Add is_ordinary parameter. Change all callers. (Symbol_value::input_shndx): Add is_ordinary parameter. Change all callers. (class Sized_relobj): Update declarations. (Sized_relobj::local_symbol_input_shndx): Add is_ordinary parameter. Change all callers. (Sized_relobj::adjust_shndx): New function. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize dynsym_shndx_ field. (Sized_dynobj::find_dynsym_sections): Remove pdynsym_shndx parameter. Change all callers. Pick up SHT_DYNSYM_SHNDX section for SHT_DYNSYM section if available. Set dynsym_shndx_ field. (Sized_dynobj::read_dynsym_section): Adjust section links. (Sized_dynobj::read_dynamic): Likewise. (Sized_dynobj::do_read_symbols): Use dynsym_shndx_ field. Adjust section links. (Sized_dynobj::do_initialize_xindex): New function. * dynobj.h (class Sized_dynobj): Add dynsym_shndx_ field. Declare do_initialize_xindex. (Sized_dynobj::adjust_shndx): New function. * layout.cc (Layout::Layout): Initialize symtab_xindex_ and dynsym_xindex_ fields. (Layout::finalize): Add a call to set_section_indexes before creating the symtab sections. (Layout::set_section_indexes): Don't do anything if the section already has a section index. (Layout::create_symtab_sections): Add shnum parameter. Change caller. Create .symtab_shndx section if needed. (Layout::create_shdrs): Add shstrtab_section parameter. Change caller. (Layout::allocated_output_section_count): New function. (Layout::create_dynamic_symtab): Create .dynsym_shndx section if needed. * layout.h (class Layout): Add symtab_xindex_ and dynsym_xindex_ fields. Update declarations. (Layout::symtab_xindex): New function. (Layout::dynsym_xindex): New function. (class Write_symbols_task): Add layout_ field. (Write_symbols_task::Write_symbols_task): Add layout parameter. Change caller. * output.cc (Output_section_headers::Output_section_headers): Add shstrtab_section parameter. Change all callers. (Output_section_headers::do_sized_write): Store overflow values for section count and section string table section index in section header zero. (Output_file_header::do_sized_write): Check for overflow of section count and section string table section index. (Output_symtab_xindex::do_write): New function. (Output_symtab_xindex::endian_do_write): New function. * output.h (class Output_section_headers): Add shstrtab_section_. Update declarations. (class Output_symtab_xindex): Define. (Output_section::has_out_shndx): New function. * symtab.cc (Symbol::init_fields): Initialize is_ordinary_shndx_ field. (Symbol::init_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::init): Likewise. (Symbol::output_section): Check for ordinary symbol. (Symbol_table::add_from_object): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. (Symbol_table::add_from_relobj): Add symndx_offset parameter. Change all callers. Simplify handling of symbols from sections not included in the link. (Symbol_table::add_from_dynobj): Handle ordinary symbol distinction. (Weak_alias_sorter::operator()): Assert that symbols are ordinary. (Symbol_table::sized_finalize_symbol): Handle ordinary symbol distinction. (Symbol_table::write_globals): Add symtab_xindex and dynsym_xindex parameters. Change all callers. (Symbol_table::sized_write_globals): Likewise. Handle ordinary symbol distinction. Use SHN_XINDEX when needed. (Symbol_table::write_section_symbol): Add symtab_xindex parameter. Change all callers. (Symbol_table::sized_write_section_symbol): Likewise. Use SHN_XINDEX when needed. * symtab.h (class Symbol): Add is_ordinary_shndx_ field. Update declarations. (Symbol::shndx): Add is_ordinary parameter. Change all callers. (Symbol::is_defined): Check is_ordinary. (Symbol::is_undefined, Symbol::is_weak_undefined): Likewise. (Symbol::is_absolute, Symbol::is_common): Likewise. (class Sized_symbol): Update declarations. (class Symbol_table): Update declarations. * resolve.cc (Symbol::override_base): Add st_shndx and is_ordinary parameters. Change all callers. (Sized_symbol::override): Likewise. (Symbol_table::override): Likewise. (symbol_to_bits): Add is_ordinary parameter. Change all callers. (Symbol_table::resolve): Remove orig_sym parameter. Add st_shndx, is_ordinary, and orig_st_shndx parameters. Change all callers. * copy-relocs.cc (Copy_relocs::emit_copy_reloc): Require symbol to be in an ordinary section. * dwarf_reader.cc (Sized_dwarf_line_info::symbol_section): Add object and is_ordinary parameters. Change all callers. (Sized_dwarf_line_info::read_relocs): Add object parameter. Change all callers. Don't add undefined or non-ordinary symbols to reloc_map_. (Sized_dwarf_line_info::read_line_mappings): Add object parameter. Change all callers. * dwarf_reader.h (class Sized_dwarf_line_info): Update declarations. * ehframe.cc (Eh_frame::read_fde): Check for ordinary symbol. * reloc.cc (Sized_relobj::do_read_relocs): Adjust section links. (Sized_relobj::relocate_sections): Likewise. * target-reloc.h (scan_relocs): Adjust section symbol index. (scan_relocatable_relocs): Likewise. * i386.cc (Scan::local): Check for ordinary symbols. * sparc.cc (Scan::local): Likewise. * x86_64.cc (Scan::local): Likewise. * testsuite/binary_unittest.cc (Sized_binary_test): Update calls to symbol_section_and_value. * testsuite/many_sections_test.cc: New file. * testsuite/Makefile.am (BUILT_SOURCES): Define. (check_PROGRAMS): Add many_sections_test. (many_sections_test_SOURCES): Define. (many_sections_test_DEPENDENCIES): Define. (many_sections_test_LDFLAGS): Define. (BUILT_SOURCES): Add many_sections_define.h. (many_sections_define.h): New target. (BUILT_SOURCES): Add many_sections_check.h. (many_sections_check.h): New target. (check_PROGRAMS): Add many_sections_r_test. (many_sections_r_test_SOURCES): Define. (many_sections_r_test_DEPENDENCIES): Define. (many_sections_r_test_LDFLAGS): Define. (many_sections_r_test_LDADD): Define. (many_sections_r_test.o): New target. * testsuite/Makefile.in: Rebuild.
2008-04-19 20:30:58 +02:00
const Stringpool_template<char>*,
Output_symtab_xindex*,
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
Output_symtab_xindex*,
off_t);
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
// Record a mapping from discarded section SHNDX to the corresponding
// kept section.
void
Further improve warnings for relocations referring to discarded sections. Relocations referring to discarded sections are now treated as errors instead of warnings. Also with this patch, we will now print the section group signature and the object file with the prevailing definition of that group along with the name of the symbol that the relocation is referring to. This additional information should be much more useful to anyone trying to track down the source of such errors. To do so, we now map each discarded section to the Kept_section info in the Layout class, and defer the logic that maps a discarded section to its counterpart in the kept group. This gives us the information we need to identify the signature symbol given the discarded section, and the name of the object file that provided the prevailing (i.e., first) definition of that group. gold/ * object.cc (Sized_relobj_file::include_section_group): Store reference to Kept_section info for discarded comdat sections regardless of size. Move size checking to map_to_kept_section. (Sized_relobj_file::include_linkonce_section): Likewise. (Sized_relobj_file::map_to_kept_section): Add section name parameter. Insert size checking logic from above functions. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. * object.h (Sized_relobj_file::map_to_kept_section): Add section_name parameter. Adjust all callers. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. (Sized_relobj_file::Kept_comdat_section): Replace object and shndx fields with sh_size, kept_section, symndx, and is_comdat fields. (Sized_relobj_file::set_kept_comdat_section): Replace kept_object and kept_shndx parameters with is_comdat, symndx, sh_size, and kept_section. (Sized_relobj_file::get_kept_comdat_section): Likewise. * target-reloc.h (enum Comdat_behavior): Change CB_WARNING to CB_ERROR. Adjust all references. (issue_undefined_symbol_error): New function template. (relocate_section): Pass section name to map_to_kept_section. Move discarded section code to new function above. * aarch64.cc (Target_aarch64::scan_reloc_section_for_stubs): Move declaration for gsym out one level. Call issue_discarded_error. * arm.cc (Target_arm::scan_reloc_section_for_stubs): Likewise. * powerpc.cc (Relocate_comdat_behavior): Change CB_WARNING to CB_ERROR.
2018-04-07 01:06:16 +02:00
set_kept_comdat_section(unsigned int shndx, bool is_comdat,
unsigned int symndx, uint64_t sh_size,
Kept_section* kept_section)
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
{
Further improve warnings for relocations referring to discarded sections. Relocations referring to discarded sections are now treated as errors instead of warnings. Also with this patch, we will now print the section group signature and the object file with the prevailing definition of that group along with the name of the symbol that the relocation is referring to. This additional information should be much more useful to anyone trying to track down the source of such errors. To do so, we now map each discarded section to the Kept_section info in the Layout class, and defer the logic that maps a discarded section to its counterpart in the kept group. This gives us the information we need to identify the signature symbol given the discarded section, and the name of the object file that provided the prevailing (i.e., first) definition of that group. gold/ * object.cc (Sized_relobj_file::include_section_group): Store reference to Kept_section info for discarded comdat sections regardless of size. Move size checking to map_to_kept_section. (Sized_relobj_file::include_linkonce_section): Likewise. (Sized_relobj_file::map_to_kept_section): Add section name parameter. Insert size checking logic from above functions. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. * object.h (Sized_relobj_file::map_to_kept_section): Add section_name parameter. Adjust all callers. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. (Sized_relobj_file::Kept_comdat_section): Replace object and shndx fields with sh_size, kept_section, symndx, and is_comdat fields. (Sized_relobj_file::set_kept_comdat_section): Replace kept_object and kept_shndx parameters with is_comdat, symndx, sh_size, and kept_section. (Sized_relobj_file::get_kept_comdat_section): Likewise. * target-reloc.h (enum Comdat_behavior): Change CB_WARNING to CB_ERROR. Adjust all references. (issue_undefined_symbol_error): New function template. (relocate_section): Pass section name to map_to_kept_section. Move discarded section code to new function above. * aarch64.cc (Target_aarch64::scan_reloc_section_for_stubs): Move declaration for gsym out one level. Call issue_discarded_error. * arm.cc (Target_arm::scan_reloc_section_for_stubs): Likewise. * powerpc.cc (Relocate_comdat_behavior): Change CB_WARNING to CB_ERROR.
2018-04-07 01:06:16 +02:00
Kept_comdat_section kept(sh_size, kept_section, symndx, is_comdat);
PR 10400 * layout.h: #include <map>. (class Kept_section): Change from struct to class. Add accessors and setters. Add section size to Comdat_group mapping. Change Comdat_group to std::map. Add is_comdat_ field. Add linkonce_size field in union. (class Layout): Update declaration of find_or_add_kept_section. Don't declare find_kept_object. * layout.cc (Layout::find_or_add_kept_section): Remove candidate parameter. Add object, shndx, is_comdat, and is_group_name parameters. Change all callers. Adjust for new Kept_section. (Layout::find_kept_object): Remove. * object.cc (Sized_relobj::include_section_group): Update use of Kept_section. Rename secnum to shndx. Only record Kept_comdat_section if sections are the same size. (Sized_relobj::include_linkonce_section): Update use of Kept_section. Only record Kept_comdat_section if sections are the same size. Set size of linkonce section. (Sized_relobj::map_to_kept_section): Update call to get_kept_comdat_section. * object.h (class Sized_relobj): Rename fields in Kept_comdat_section to drop trailing underscores; change object field to Relobj*. Change Kept_comdat_section_table to store struct rather than pointer. (Sized_relobj::set_kept_comdat_section): Remove kept parameter. Add kept_object and kept_shndx parameters. Change all callers. (Sized_relobj::get_kept_comdat_section): Change return type to bool. Add kept_object and kept_shndx parameters. Change all callers. * plugin.cc (Pluginobj::include_comdat_group): Update call to Layout::find_or_add_kept_section.
2009-07-17 03:07:33 +02:00
this->kept_comdat_sections_.insert(std::make_pair(shndx, kept));
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
}
PR 10400 * layout.h: #include <map>. (class Kept_section): Change from struct to class. Add accessors and setters. Add section size to Comdat_group mapping. Change Comdat_group to std::map. Add is_comdat_ field. Add linkonce_size field in union. (class Layout): Update declaration of find_or_add_kept_section. Don't declare find_kept_object. * layout.cc (Layout::find_or_add_kept_section): Remove candidate parameter. Add object, shndx, is_comdat, and is_group_name parameters. Change all callers. Adjust for new Kept_section. (Layout::find_kept_object): Remove. * object.cc (Sized_relobj::include_section_group): Update use of Kept_section. Rename secnum to shndx. Only record Kept_comdat_section if sections are the same size. (Sized_relobj::include_linkonce_section): Update use of Kept_section. Only record Kept_comdat_section if sections are the same size. Set size of linkonce section. (Sized_relobj::map_to_kept_section): Update call to get_kept_comdat_section. * object.h (class Sized_relobj): Rename fields in Kept_comdat_section to drop trailing underscores; change object field to Relobj*. Change Kept_comdat_section_table to store struct rather than pointer. (Sized_relobj::set_kept_comdat_section): Remove kept parameter. Add kept_object and kept_shndx parameters. Change all callers. (Sized_relobj::get_kept_comdat_section): Change return type to bool. Add kept_object and kept_shndx parameters. Change all callers. * plugin.cc (Pluginobj::include_comdat_group): Update call to Layout::find_or_add_kept_section.
2009-07-17 03:07:33 +02:00
// Find the kept section corresponding to the discarded section
// SHNDX. Return true if found.
bool
Further improve warnings for relocations referring to discarded sections. Relocations referring to discarded sections are now treated as errors instead of warnings. Also with this patch, we will now print the section group signature and the object file with the prevailing definition of that group along with the name of the symbol that the relocation is referring to. This additional information should be much more useful to anyone trying to track down the source of such errors. To do so, we now map each discarded section to the Kept_section info in the Layout class, and defer the logic that maps a discarded section to its counterpart in the kept group. This gives us the information we need to identify the signature symbol given the discarded section, and the name of the object file that provided the prevailing (i.e., first) definition of that group. gold/ * object.cc (Sized_relobj_file::include_section_group): Store reference to Kept_section info for discarded comdat sections regardless of size. Move size checking to map_to_kept_section. (Sized_relobj_file::include_linkonce_section): Likewise. (Sized_relobj_file::map_to_kept_section): Add section name parameter. Insert size checking logic from above functions. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. * object.h (Sized_relobj_file::map_to_kept_section): Add section_name parameter. Adjust all callers. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. (Sized_relobj_file::Kept_comdat_section): Replace object and shndx fields with sh_size, kept_section, symndx, and is_comdat fields. (Sized_relobj_file::set_kept_comdat_section): Replace kept_object and kept_shndx parameters with is_comdat, symndx, sh_size, and kept_section. (Sized_relobj_file::get_kept_comdat_section): Likewise. * target-reloc.h (enum Comdat_behavior): Change CB_WARNING to CB_ERROR. Adjust all references. (issue_undefined_symbol_error): New function template. (relocate_section): Pass section name to map_to_kept_section. Move discarded section code to new function above. * aarch64.cc (Target_aarch64::scan_reloc_section_for_stubs): Move declaration for gsym out one level. Call issue_discarded_error. * arm.cc (Target_arm::scan_reloc_section_for_stubs): Likewise. * powerpc.cc (Relocate_comdat_behavior): Change CB_WARNING to CB_ERROR.
2018-04-07 01:06:16 +02:00
get_kept_comdat_section(unsigned int shndx, bool* is_comdat,
unsigned int *symndx, uint64_t* sh_size,
Kept_section** kept_section) const
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
{
typename Kept_comdat_section_table::const_iterator p =
this->kept_comdat_sections_.find(shndx);
if (p == this->kept_comdat_sections_.end())
PR 10400 * layout.h: #include <map>. (class Kept_section): Change from struct to class. Add accessors and setters. Add section size to Comdat_group mapping. Change Comdat_group to std::map. Add is_comdat_ field. Add linkonce_size field in union. (class Layout): Update declaration of find_or_add_kept_section. Don't declare find_kept_object. * layout.cc (Layout::find_or_add_kept_section): Remove candidate parameter. Add object, shndx, is_comdat, and is_group_name parameters. Change all callers. Adjust for new Kept_section. (Layout::find_kept_object): Remove. * object.cc (Sized_relobj::include_section_group): Update use of Kept_section. Rename secnum to shndx. Only record Kept_comdat_section if sections are the same size. (Sized_relobj::include_linkonce_section): Update use of Kept_section. Only record Kept_comdat_section if sections are the same size. Set size of linkonce section. (Sized_relobj::map_to_kept_section): Update call to get_kept_comdat_section. * object.h (class Sized_relobj): Rename fields in Kept_comdat_section to drop trailing underscores; change object field to Relobj*. Change Kept_comdat_section_table to store struct rather than pointer. (Sized_relobj::set_kept_comdat_section): Remove kept parameter. Add kept_object and kept_shndx parameters. Change all callers. (Sized_relobj::get_kept_comdat_section): Change return type to bool. Add kept_object and kept_shndx parameters. Change all callers. * plugin.cc (Pluginobj::include_comdat_group): Update call to Layout::find_or_add_kept_section.
2009-07-17 03:07:33 +02:00
return false;
Further improve warnings for relocations referring to discarded sections. Relocations referring to discarded sections are now treated as errors instead of warnings. Also with this patch, we will now print the section group signature and the object file with the prevailing definition of that group along with the name of the symbol that the relocation is referring to. This additional information should be much more useful to anyone trying to track down the source of such errors. To do so, we now map each discarded section to the Kept_section info in the Layout class, and defer the logic that maps a discarded section to its counterpart in the kept group. This gives us the information we need to identify the signature symbol given the discarded section, and the name of the object file that provided the prevailing (i.e., first) definition of that group. gold/ * object.cc (Sized_relobj_file::include_section_group): Store reference to Kept_section info for discarded comdat sections regardless of size. Move size checking to map_to_kept_section. (Sized_relobj_file::include_linkonce_section): Likewise. (Sized_relobj_file::map_to_kept_section): Add section name parameter. Insert size checking logic from above functions. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. * object.h (Sized_relobj_file::map_to_kept_section): Add section_name parameter. Adjust all callers. (Sized_relobj_file::find_kept_section_object): New method. (Sized_relobj_file::get_symbol_name): New method. (Sized_relobj_file::Kept_comdat_section): Replace object and shndx fields with sh_size, kept_section, symndx, and is_comdat fields. (Sized_relobj_file::set_kept_comdat_section): Replace kept_object and kept_shndx parameters with is_comdat, symndx, sh_size, and kept_section. (Sized_relobj_file::get_kept_comdat_section): Likewise. * target-reloc.h (enum Comdat_behavior): Change CB_WARNING to CB_ERROR. Adjust all references. (issue_undefined_symbol_error): New function template. (relocate_section): Pass section name to map_to_kept_section. Move discarded section code to new function above. * aarch64.cc (Target_aarch64::scan_reloc_section_for_stubs): Move declaration for gsym out one level. Call issue_discarded_error. * arm.cc (Target_arm::scan_reloc_section_for_stubs): Likewise. * powerpc.cc (Relocate_comdat_behavior): Change CB_WARNING to CB_ERROR.
2018-04-07 01:06:16 +02:00
*is_comdat = p->second.is_comdat;
*symndx = p->second.symndx;
*sh_size = p->second.sh_size;
*kept_section = p->second.kept_section;
PR 10400 * layout.h: #include <map>. (class Kept_section): Change from struct to class. Add accessors and setters. Add section size to Comdat_group mapping. Change Comdat_group to std::map. Add is_comdat_ field. Add linkonce_size field in union. (class Layout): Update declaration of find_or_add_kept_section. Don't declare find_kept_object. * layout.cc (Layout::find_or_add_kept_section): Remove candidate parameter. Add object, shndx, is_comdat, and is_group_name parameters. Change all callers. Adjust for new Kept_section. (Layout::find_kept_object): Remove. * object.cc (Sized_relobj::include_section_group): Update use of Kept_section. Rename secnum to shndx. Only record Kept_comdat_section if sections are the same size. (Sized_relobj::include_linkonce_section): Update use of Kept_section. Only record Kept_comdat_section if sections are the same size. Set size of linkonce section. (Sized_relobj::map_to_kept_section): Update call to get_kept_comdat_section. * object.h (class Sized_relobj): Rename fields in Kept_comdat_section to drop trailing underscores; change object field to Relobj*. Change Kept_comdat_section_table to store struct rather than pointer. (Sized_relobj::set_kept_comdat_section): Remove kept parameter. Add kept_object and kept_shndx parameters. Change all callers. (Sized_relobj::get_kept_comdat_section): Change return type to bool. Add kept_object and kept_shndx parameters. Change all callers. * plugin.cc (Pluginobj::include_comdat_group): Update call to Layout::find_or_add_kept_section.
2009-07-17 03:07:33 +02:00
return true;
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
}
2010-09-08 Doug Kwan <dougkwan@google.com> * arm.cc (Arm_exidx_cantunwind::do_print_to_mapfile): New method. (Arm_relobj::do_relocate_sections): Add new parameter for output file to match the parent. (Target_arm::scan_reloc_section_for_stubs): Use would-be final values of local symbols instead of input values. Update code to track changes in gold::relocate_section. * object.cc (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. (Sized_relobj::do_finalize_local_symbols): Move code from loop body into private version of Sized_relobj::compute_final_local_value. Call the inline method. * object.h (Symbol_value::Symbol_value): Define destructor. Free merged symbol value if there is one. (Symbol_value::has_output_value): New method defintiion. (Sized_relobj::Compute_final_local_value_status): New enum type. (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. * Makefile.am (check_SCRIPTS): Add arm_branch_out_of_range.sh and arm_cortex_a8.sh. (thumb_bl_out_of_range_local, arm_cortex_a8_b_cond, arm_cortex_a8_bl, arm_cortex_a8_blx, arm_cortex_a8_local, arm_corte_a8_local_reloc): New tests. * Makefile.in: Regenerate. * testsuite/arm_bl_out_of_range.s: Update test. * testsuite/thumb_bl_out_of_range.s: Ditto. * testsuite/thumb_blx_out_of_range.s: Ditto. * testsuite/arm_branch_out_of_range.sh: New file. * testsuite/arm_cortex_a8.sh: Ditto. * testsuite/arm_cortex_a8_b.s: Ditto. * testsuite/arm_cortex_a8_b_cond.s: Ditto. * testsuite/arm_cortex_a8_b_local.s: Ditto. * testsuite/arm_cortex_a8_bl.s: Ditto. * testsuite/arm_cortex_a8_blx.s: Ditto. * testsuite/arm_cortex_a8_local.s: Ditto. * testsuite/arm_cortex_a8_local_reloc.s: Ditto. * testsuite/thumb_bl_out_of_range_local.s: Ditto.
2010-09-09 01:54:51 +02:00
// Compute final local symbol value. R_SYM is the local symbol index.
// LV_IN points to a local symbol value containing the input value.
// LV_OUT points to a local symbol value storing the final output value,
// which must not be a merged symbol value since before calling this
Fix symbol values and relocation addends for relocatable links. The fix for PR 19291 broke some other cases where -r is used with scripts, as reported in PR 22266. The original fix for PR 22266 ended up breaking many cases for REL targets, where the addends are stored in the section data, and are not being adjusted properly. The problem was basically that in a relocatable output file (ET_REL), symbol values are supposed to be relative to the start address of their section. Usually in a relocatable file, all sections start at 0, so the failure to get this right is often irrelevant, but with a linker script, we occasionally see an output section whose starting address is not 0, and gold would occasionally write a symbol with its relocated value instead of its section-relative value. This patch reverts the recent fix for PR 22266 as well as my original fix for PR 19291. The original fix moved the symbol value adjustment to write_local_symbols, but neglected to undo a few places where the adjustment was also being applied, resulting in an occasional double adjustment. The more recent fix removed those other adjustments, but then failed to re-account for the adjustment when rewriting the relocations on REL targets. With the old attempts reverted, we now apply the symbol value adjustment to the one case that had been missed (non-section symbols in merge sections). But now we also need to account for the adjustment when rewriting the addends for RELA relocations. gold/ PR gold/19291 PR gold/22266 * object.cc (Sized_relobj_file::compute_final_local_value_internal): Revert changes from 2017-11-08 patch. Adjust symbol value in relocatable links for non-section symbols. (Sized_relobj_file::compute_final_local_value): Revert changes from 2017-11-08 patch. (Sized_relobj_file::do_finalize_local_symbols): Likewise. (Sized_relobj_file::write_local_symbols): Revert changes from 2015-11-25 patch. * object.h (Sized_relobj_file::compute_final_local_value_internal): Revert changes from 2017-11-08 patch. * powerpc.cc (Target_powerpc::relocate_relocs): Adjust addend for relocatable links. * target-reloc.h (relocate_relocs): Adjust addend for relocatable links. * testsuite/pr22266_a.c (hello): New function. * testsuite/pr22266_main.c (main): Add test for merge sections. * testsuite/pr22266_script.t: Add rule for .rodata.
2017-11-28 02:32:55 +01:00
// method to avoid memory leak. RELOCATABLE indicates whether we are
// linking a relocatable output. OUT_SECTIONS is an array of output
2010-09-08 Doug Kwan <dougkwan@google.com> * arm.cc (Arm_exidx_cantunwind::do_print_to_mapfile): New method. (Arm_relobj::do_relocate_sections): Add new parameter for output file to match the parent. (Target_arm::scan_reloc_section_for_stubs): Use would-be final values of local symbols instead of input values. Update code to track changes in gold::relocate_section. * object.cc (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. (Sized_relobj::do_finalize_local_symbols): Move code from loop body into private version of Sized_relobj::compute_final_local_value. Call the inline method. * object.h (Symbol_value::Symbol_value): Define destructor. Free merged symbol value if there is one. (Symbol_value::has_output_value): New method defintiion. (Sized_relobj::Compute_final_local_value_status): New enum type. (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. * Makefile.am (check_SCRIPTS): Add arm_branch_out_of_range.sh and arm_cortex_a8.sh. (thumb_bl_out_of_range_local, arm_cortex_a8_b_cond, arm_cortex_a8_bl, arm_cortex_a8_blx, arm_cortex_a8_local, arm_corte_a8_local_reloc): New tests. * Makefile.in: Regenerate. * testsuite/arm_bl_out_of_range.s: Update test. * testsuite/thumb_bl_out_of_range.s: Ditto. * testsuite/thumb_blx_out_of_range.s: Ditto. * testsuite/arm_branch_out_of_range.sh: New file. * testsuite/arm_cortex_a8.sh: Ditto. * testsuite/arm_cortex_a8_b.s: Ditto. * testsuite/arm_cortex_a8_b_cond.s: Ditto. * testsuite/arm_cortex_a8_b_local.s: Ditto. * testsuite/arm_cortex_a8_bl.s: Ditto. * testsuite/arm_cortex_a8_blx.s: Ditto. * testsuite/arm_cortex_a8_local.s: Ditto. * testsuite/arm_cortex_a8_local_reloc.s: Ditto. * testsuite/thumb_bl_out_of_range_local.s: Ditto.
2010-09-09 01:54:51 +02:00
// sections. OUT_OFFSETS is an array of offsets of the sections. SYMTAB
// points to a symbol table.
//
// The method returns a status code at return. If the return status is
// CFLV_OK, *LV_OUT contains the final value. If the return status is
// CFLV_ERROR, *LV_OUT is 0. If the return status is CFLV_DISCARDED,
// *LV_OUT is not modified.
inline Compute_final_local_value_status
compute_final_local_value_internal(unsigned int r_sym,
const Symbol_value<size>* lv_in,
Symbol_value<size>* lv_out,
Fix symbol values and relocation addends for relocatable links. The fix for PR 19291 broke some other cases where -r is used with scripts, as reported in PR 22266. The original fix for PR 22266 ended up breaking many cases for REL targets, where the addends are stored in the section data, and are not being adjusted properly. The problem was basically that in a relocatable output file (ET_REL), symbol values are supposed to be relative to the start address of their section. Usually in a relocatable file, all sections start at 0, so the failure to get this right is often irrelevant, but with a linker script, we occasionally see an output section whose starting address is not 0, and gold would occasionally write a symbol with its relocated value instead of its section-relative value. This patch reverts the recent fix for PR 22266 as well as my original fix for PR 19291. The original fix moved the symbol value adjustment to write_local_symbols, but neglected to undo a few places where the adjustment was also being applied, resulting in an occasional double adjustment. The more recent fix removed those other adjustments, but then failed to re-account for the adjustment when rewriting the relocations on REL targets. With the old attempts reverted, we now apply the symbol value adjustment to the one case that had been missed (non-section symbols in merge sections). But now we also need to account for the adjustment when rewriting the addends for RELA relocations. gold/ PR gold/19291 PR gold/22266 * object.cc (Sized_relobj_file::compute_final_local_value_internal): Revert changes from 2017-11-08 patch. Adjust symbol value in relocatable links for non-section symbols. (Sized_relobj_file::compute_final_local_value): Revert changes from 2017-11-08 patch. (Sized_relobj_file::do_finalize_local_symbols): Likewise. (Sized_relobj_file::write_local_symbols): Revert changes from 2015-11-25 patch. * object.h (Sized_relobj_file::compute_final_local_value_internal): Revert changes from 2017-11-08 patch. * powerpc.cc (Target_powerpc::relocate_relocs): Adjust addend for relocatable links. * target-reloc.h (relocate_relocs): Adjust addend for relocatable links. * testsuite/pr22266_a.c (hello): New function. * testsuite/pr22266_main.c (main): Add test for merge sections. * testsuite/pr22266_script.t: Add rule for .rodata.
2017-11-28 02:32:55 +01:00
bool relocatable,
2010-09-08 Doug Kwan <dougkwan@google.com> * arm.cc (Arm_exidx_cantunwind::do_print_to_mapfile): New method. (Arm_relobj::do_relocate_sections): Add new parameter for output file to match the parent. (Target_arm::scan_reloc_section_for_stubs): Use would-be final values of local symbols instead of input values. Update code to track changes in gold::relocate_section. * object.cc (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. (Sized_relobj::do_finalize_local_symbols): Move code from loop body into private version of Sized_relobj::compute_final_local_value. Call the inline method. * object.h (Symbol_value::Symbol_value): Define destructor. Free merged symbol value if there is one. (Symbol_value::has_output_value): New method defintiion. (Sized_relobj::Compute_final_local_value_status): New enum type. (Sized_relobj::compute_final_local_value): New methods. (Sized_relobj::compute_final_local_value_internal): New methods. * Makefile.am (check_SCRIPTS): Add arm_branch_out_of_range.sh and arm_cortex_a8.sh. (thumb_bl_out_of_range_local, arm_cortex_a8_b_cond, arm_cortex_a8_bl, arm_cortex_a8_blx, arm_cortex_a8_local, arm_corte_a8_local_reloc): New tests. * Makefile.in: Regenerate. * testsuite/arm_bl_out_of_range.s: Update test. * testsuite/thumb_bl_out_of_range.s: Ditto. * testsuite/thumb_blx_out_of_range.s: Ditto. * testsuite/arm_branch_out_of_range.sh: New file. * testsuite/arm_cortex_a8.sh: Ditto. * testsuite/arm_cortex_a8_b.s: Ditto. * testsuite/arm_cortex_a8_b_cond.s: Ditto. * testsuite/arm_cortex_a8_b_local.s: Ditto. * testsuite/arm_cortex_a8_bl.s: Ditto. * testsuite/arm_cortex_a8_blx.s: Ditto. * testsuite/arm_cortex_a8_local.s: Ditto. * testsuite/arm_cortex_a8_local_reloc.s: Ditto. * testsuite/thumb_bl_out_of_range_local.s: Ditto.
2010-09-09 01:54:51 +02:00
const Output_sections& out_sections,
const std::vector<Address>& out_offsets,
const Symbol_table* symtab);
PR 10893 * 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.
2010-08-20 00:50:16 +02:00
// The PLT offsets of local symbols.
typedef Unordered_map<unsigned int, unsigned int> Local_plt_offsets;
// Saved information for sections whose layout was deferred.
struct Deferred_layout
{
static const int shdr_size = elfcpp::Elf_sizes<size>::shdr_size;
Deferred_layout(unsigned int shndx, const char* name,
Fix problem where mixed section types can cause internal error during a -r link. During a -r (or --emit-relocs) link, if two sections had the same name but different section types, gold would put relocations for both sections into the same relocation section even though the data sections remained separate. For .eh_frame sections, when one section is PROGBITS and another is X86_64_UNWIND, we really should be using the UNWIND section type and combining the sections anyway. For other sections, we should be creating one relocation section for each output data section. gold/ PR gold/23016 * incremental.cc (can_incremental_update): Check for unwind section type. * layout.h (Layout::layout): Add sh_type parameter. * layout.cc (Layout::layout): Likewise. (Layout::layout_reloc): Create new output reloc section if data section does not already have one. (Layout::layout_eh_frame): Check for unwind section type. (Layout::make_eh_frame_section): Use unwind section type for .eh_frame and .eh_frame_hdr. * object.h (Sized_relobj_file::Shdr_write): New typedef. (Sized_relobj_file::layout_section): Add sh_type parameter. (Sized_relobj_file::Deferred_layout::Deferred_layout): Add sh_type parameter. * object.cc (Sized_relobj_file::check_eh_frame_flags): Check for unwind section type. (Sized_relobj_file::layout_section): Add sh_type parameter; pass it to Layout::layout. (Sized_relobj_file::do_layout): Make local copy of sh_type. Force .eh_frame sections to unwind section type. Pass sh_type to layout_section. (Sized_relobj_file<size, big_endian>::do_layout_deferred_sections): Pass sh_type to layout_section. * output.cc (Output_section::Output_section): Initialize reloc_section_. * output.h (Output_section::reloc_section): New method. (Output_section::set_reloc_section): New method. (Output_section::reloc_section_): New data member. * target.h (Target::unwind_section_type): New method. (Target::Target_info::unwind_section_type): New data member. * aarch64.cc (aarch64_info): Add unwind_section_type. * arm.cc (arm_info, arm_nacl_info): Likewise. * i386.cc (i386_info, i386_nacl_info, iamcu_info): Likewise. * mips.cc (mips_info, mips_nacl_info): Likewise. * powerpc.cc (powerpc_info): Likewise. * s390.cc (s390_info): Likewise. * sparc.cc (sparc_info): Likewise. * tilegx.cc (tilegx_info): Likewise. * x86_64.cc (x86_64_info, x86_64_nacl_info): Likewise. * testsuite/Makefile.am (pr23016_1, pr23016_2): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/testfile.cc: Add unwind_section_type. * testsuite/pr23016_1.sh: New test script. * testsuite/pr23016_1a.s: New source file. * testsuite/pr23016_1b.s: New source file. * testsuite/pr23016_2.sh: New test script. * testsuite/pr23016_2a.s: New source file. * testsuite/pr23016_2b.s: New source file.
2018-04-03 01:12:10 +02:00
unsigned int sh_type,
const unsigned char* pshdr,
unsigned int reloc_shndx, unsigned int reloc_type)
Fix problem where mixed section types can cause internal error during a -r link. During a -r (or --emit-relocs) link, if two sections had the same name but different section types, gold would put relocations for both sections into the same relocation section even though the data sections remained separate. For .eh_frame sections, when one section is PROGBITS and another is X86_64_UNWIND, we really should be using the UNWIND section type and combining the sections anyway. For other sections, we should be creating one relocation section for each output data section. gold/ PR gold/23016 * incremental.cc (can_incremental_update): Check for unwind section type. * layout.h (Layout::layout): Add sh_type parameter. * layout.cc (Layout::layout): Likewise. (Layout::layout_reloc): Create new output reloc section if data section does not already have one. (Layout::layout_eh_frame): Check for unwind section type. (Layout::make_eh_frame_section): Use unwind section type for .eh_frame and .eh_frame_hdr. * object.h (Sized_relobj_file::Shdr_write): New typedef. (Sized_relobj_file::layout_section): Add sh_type parameter. (Sized_relobj_file::Deferred_layout::Deferred_layout): Add sh_type parameter. * object.cc (Sized_relobj_file::check_eh_frame_flags): Check for unwind section type. (Sized_relobj_file::layout_section): Add sh_type parameter; pass it to Layout::layout. (Sized_relobj_file::do_layout): Make local copy of sh_type. Force .eh_frame sections to unwind section type. Pass sh_type to layout_section. (Sized_relobj_file<size, big_endian>::do_layout_deferred_sections): Pass sh_type to layout_section. * output.cc (Output_section::Output_section): Initialize reloc_section_. * output.h (Output_section::reloc_section): New method. (Output_section::set_reloc_section): New method. (Output_section::reloc_section_): New data member. * target.h (Target::unwind_section_type): New method. (Target::Target_info::unwind_section_type): New data member. * aarch64.cc (aarch64_info): Add unwind_section_type. * arm.cc (arm_info, arm_nacl_info): Likewise. * i386.cc (i386_info, i386_nacl_info, iamcu_info): Likewise. * mips.cc (mips_info, mips_nacl_info): Likewise. * powerpc.cc (powerpc_info): Likewise. * s390.cc (s390_info): Likewise. * sparc.cc (sparc_info): Likewise. * tilegx.cc (tilegx_info): Likewise. * x86_64.cc (x86_64_info, x86_64_nacl_info): Likewise. * testsuite/Makefile.am (pr23016_1, pr23016_2): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/testfile.cc: Add unwind_section_type. * testsuite/pr23016_1.sh: New test script. * testsuite/pr23016_1a.s: New source file. * testsuite/pr23016_1b.s: New source file. * testsuite/pr23016_2.sh: New test script. * testsuite/pr23016_2a.s: New source file. * testsuite/pr23016_2b.s: New source file.
2018-04-03 01:12:10 +02:00
: name_(name), shndx_(shndx), reloc_shndx_(reloc_shndx),
reloc_type_(reloc_type)
{
Fix problem where mixed section types can cause internal error during a -r link. During a -r (or --emit-relocs) link, if two sections had the same name but different section types, gold would put relocations for both sections into the same relocation section even though the data sections remained separate. For .eh_frame sections, when one section is PROGBITS and another is X86_64_UNWIND, we really should be using the UNWIND section type and combining the sections anyway. For other sections, we should be creating one relocation section for each output data section. gold/ PR gold/23016 * incremental.cc (can_incremental_update): Check for unwind section type. * layout.h (Layout::layout): Add sh_type parameter. * layout.cc (Layout::layout): Likewise. (Layout::layout_reloc): Create new output reloc section if data section does not already have one. (Layout::layout_eh_frame): Check for unwind section type. (Layout::make_eh_frame_section): Use unwind section type for .eh_frame and .eh_frame_hdr. * object.h (Sized_relobj_file::Shdr_write): New typedef. (Sized_relobj_file::layout_section): Add sh_type parameter. (Sized_relobj_file::Deferred_layout::Deferred_layout): Add sh_type parameter. * object.cc (Sized_relobj_file::check_eh_frame_flags): Check for unwind section type. (Sized_relobj_file::layout_section): Add sh_type parameter; pass it to Layout::layout. (Sized_relobj_file::do_layout): Make local copy of sh_type. Force .eh_frame sections to unwind section type. Pass sh_type to layout_section. (Sized_relobj_file<size, big_endian>::do_layout_deferred_sections): Pass sh_type to layout_section. * output.cc (Output_section::Output_section): Initialize reloc_section_. * output.h (Output_section::reloc_section): New method. (Output_section::set_reloc_section): New method. (Output_section::reloc_section_): New data member. * target.h (Target::unwind_section_type): New method. (Target::Target_info::unwind_section_type): New data member. * aarch64.cc (aarch64_info): Add unwind_section_type. * arm.cc (arm_info, arm_nacl_info): Likewise. * i386.cc (i386_info, i386_nacl_info, iamcu_info): Likewise. * mips.cc (mips_info, mips_nacl_info): Likewise. * powerpc.cc (powerpc_info): Likewise. * s390.cc (s390_info): Likewise. * sparc.cc (sparc_info): Likewise. * tilegx.cc (tilegx_info): Likewise. * x86_64.cc (x86_64_info, x86_64_nacl_info): Likewise. * testsuite/Makefile.am (pr23016_1, pr23016_2): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/testfile.cc: Add unwind_section_type. * testsuite/pr23016_1.sh: New test script. * testsuite/pr23016_1a.s: New source file. * testsuite/pr23016_1b.s: New source file. * testsuite/pr23016_2.sh: New test script. * testsuite/pr23016_2a.s: New source file. * testsuite/pr23016_2b.s: New source file.
2018-04-03 01:12:10 +02:00
typename This::Shdr_write shdr(this->shdr_data_);
memcpy(this->shdr_data_, pshdr, shdr_size);
Fix problem where mixed section types can cause internal error during a -r link. During a -r (or --emit-relocs) link, if two sections had the same name but different section types, gold would put relocations for both sections into the same relocation section even though the data sections remained separate. For .eh_frame sections, when one section is PROGBITS and another is X86_64_UNWIND, we really should be using the UNWIND section type and combining the sections anyway. For other sections, we should be creating one relocation section for each output data section. gold/ PR gold/23016 * incremental.cc (can_incremental_update): Check for unwind section type. * layout.h (Layout::layout): Add sh_type parameter. * layout.cc (Layout::layout): Likewise. (Layout::layout_reloc): Create new output reloc section if data section does not already have one. (Layout::layout_eh_frame): Check for unwind section type. (Layout::make_eh_frame_section): Use unwind section type for .eh_frame and .eh_frame_hdr. * object.h (Sized_relobj_file::Shdr_write): New typedef. (Sized_relobj_file::layout_section): Add sh_type parameter. (Sized_relobj_file::Deferred_layout::Deferred_layout): Add sh_type parameter. * object.cc (Sized_relobj_file::check_eh_frame_flags): Check for unwind section type. (Sized_relobj_file::layout_section): Add sh_type parameter; pass it to Layout::layout. (Sized_relobj_file::do_layout): Make local copy of sh_type. Force .eh_frame sections to unwind section type. Pass sh_type to layout_section. (Sized_relobj_file<size, big_endian>::do_layout_deferred_sections): Pass sh_type to layout_section. * output.cc (Output_section::Output_section): Initialize reloc_section_. * output.h (Output_section::reloc_section): New method. (Output_section::set_reloc_section): New method. (Output_section::reloc_section_): New data member. * target.h (Target::unwind_section_type): New method. (Target::Target_info::unwind_section_type): New data member. * aarch64.cc (aarch64_info): Add unwind_section_type. * arm.cc (arm_info, arm_nacl_info): Likewise. * i386.cc (i386_info, i386_nacl_info, iamcu_info): Likewise. * mips.cc (mips_info, mips_nacl_info): Likewise. * powerpc.cc (powerpc_info): Likewise. * s390.cc (s390_info): Likewise. * sparc.cc (sparc_info): Likewise. * tilegx.cc (tilegx_info): Likewise. * x86_64.cc (x86_64_info, x86_64_nacl_info): Likewise. * testsuite/Makefile.am (pr23016_1, pr23016_2): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/testfile.cc: Add unwind_section_type. * testsuite/pr23016_1.sh: New test script. * testsuite/pr23016_1a.s: New source file. * testsuite/pr23016_1b.s: New source file. * testsuite/pr23016_2.sh: New test script. * testsuite/pr23016_2a.s: New source file. * testsuite/pr23016_2b.s: New source file.
2018-04-03 01:12:10 +02:00
shdr.put_sh_type(sh_type);
}
std::string name_;
Fix problem where mixed section types can cause internal error during a -r link. During a -r (or --emit-relocs) link, if two sections had the same name but different section types, gold would put relocations for both sections into the same relocation section even though the data sections remained separate. For .eh_frame sections, when one section is PROGBITS and another is X86_64_UNWIND, we really should be using the UNWIND section type and combining the sections anyway. For other sections, we should be creating one relocation section for each output data section. gold/ PR gold/23016 * incremental.cc (can_incremental_update): Check for unwind section type. * layout.h (Layout::layout): Add sh_type parameter. * layout.cc (Layout::layout): Likewise. (Layout::layout_reloc): Create new output reloc section if data section does not already have one. (Layout::layout_eh_frame): Check for unwind section type. (Layout::make_eh_frame_section): Use unwind section type for .eh_frame and .eh_frame_hdr. * object.h (Sized_relobj_file::Shdr_write): New typedef. (Sized_relobj_file::layout_section): Add sh_type parameter. (Sized_relobj_file::Deferred_layout::Deferred_layout): Add sh_type parameter. * object.cc (Sized_relobj_file::check_eh_frame_flags): Check for unwind section type. (Sized_relobj_file::layout_section): Add sh_type parameter; pass it to Layout::layout. (Sized_relobj_file::do_layout): Make local copy of sh_type. Force .eh_frame sections to unwind section type. Pass sh_type to layout_section. (Sized_relobj_file<size, big_endian>::do_layout_deferred_sections): Pass sh_type to layout_section. * output.cc (Output_section::Output_section): Initialize reloc_section_. * output.h (Output_section::reloc_section): New method. (Output_section::set_reloc_section): New method. (Output_section::reloc_section_): New data member. * target.h (Target::unwind_section_type): New method. (Target::Target_info::unwind_section_type): New data member. * aarch64.cc (aarch64_info): Add unwind_section_type. * arm.cc (arm_info, arm_nacl_info): Likewise. * i386.cc (i386_info, i386_nacl_info, iamcu_info): Likewise. * mips.cc (mips_info, mips_nacl_info): Likewise. * powerpc.cc (powerpc_info): Likewise. * s390.cc (s390_info): Likewise. * sparc.cc (sparc_info): Likewise. * tilegx.cc (tilegx_info): Likewise. * x86_64.cc (x86_64_info, x86_64_nacl_info): Likewise. * testsuite/Makefile.am (pr23016_1, pr23016_2): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/testfile.cc: Add unwind_section_type. * testsuite/pr23016_1.sh: New test script. * testsuite/pr23016_1a.s: New source file. * testsuite/pr23016_1b.s: New source file. * testsuite/pr23016_2.sh: New test script. * testsuite/pr23016_2a.s: New source file. * testsuite/pr23016_2b.s: New source file.
2018-04-03 01:12:10 +02:00
unsigned int shndx_;
unsigned int reloc_shndx_;
unsigned int reloc_type_;
unsigned char shdr_data_[shdr_size];
};
// General access to the ELF file.
elfcpp::Elf_file<size, big_endian, Object> elf_file_;
// Type of ELF file (ET_REL or ET_EXEC). ET_EXEC files are allowed
// as input files only for the --just-symbols option.
int e_type_;
2006-08-05 01:10:59 +02:00
// Index of SHT_SYMTAB section.
unsigned int symtab_shndx_;
// The number of local symbols.
unsigned int local_symbol_count_;
// The number of local symbols which go into the output file.
unsigned int output_local_symbol_count_;
// The number of local symbols which go into the output file's dynamic
// symbol table.
unsigned int output_local_dynsym_count_;
// The entries in the symbol table for the external symbols.
Symbols symbols_;
* cref.cc: New file. * cref.h: New file. * options.h (class General_options): Add --print-symbol-counts. * main.cc (main): Issue defined symbol report if requested. * archive.cc (Archive::interpret_header): Make into a const member function. (Archive::add_symbols): Call Input_objects::archive_start and archive_stop. (Archive::const_iterator): Define new class. (Archive::begin, Archive::end): New functions. (Archive::include_all_members): Rewrite to use iterator. (Archive::count_members): New function. * archive.h (class Archive): Update declarations. (Archive::filename): New function. * object.cc: Include "cref.h". (Sized_relobj::Sized_relobj): Initialize defined_count_. (Sized_relobj::do_get_global_symbol_counts): New function. (Input_objects::add_object): Add object to cross-referencer. (Input_objects::archive_start): New function. (Input_objects::archive_stop): New function. (Input_objects::print_symbol_counts): New function. * object.h: Declare Cref and Archive. (Object::get_global_symbol_counts): New function. (Object::do_get_global_symbol_counts): New pure virtual function. (class Sized_relobj): Add defined_count_ field. Update declarations. (class Input_objects): Add cref_ field. Update constructor. Update declarations. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and defined_count_. (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing symbol counts. (Sized_dynobj::do_get_global_symbol_counts): New function. * dynobj.h (class Sized_dynobj): Add fields symbols_ and defined_count_. Update declarations. Define Symbols typedef. * symtab.cc (Symbol_table::add_from_relobj): Add defined parameter. Change all callers. (Symbol_table::add_from_dynobj): Add sympointers and defined parameters. Change all callers. * symtab.h (class Symbol_table): Update declarations. * Makefile.am (CCFILES): Add cref.cc. (HFILES): Add cref.h. * Makefile.in: Rebuild.
2008-07-23 00:08:43 +02:00
// Number of symbols defined in object file itself.
size_t defined_count_;
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
// File offset for local symbols (relative to start of symbol table).
2006-09-28 00:53:42 +02:00
off_t local_symbol_offset_;
* archive.cc (Archive::include_member): Adjust call to 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.
2011-04-12 02:44:48 +02:00
// File offset for local dynamic symbols (absolute).
off_t local_dynsym_offset_;
// Values of local symbols.
Local_values local_values_;
PR 10893 * 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.
2010-08-20 00:50:16 +02:00
// PLT offsets for local symbols.
Local_plt_offsets local_plt_offsets_;
Handle output sections with more than 0x7fffffff bytes. * 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.
2008-07-11 01:01:20 +02:00
// Table mapping discarded comdat sections to corresponding kept sections.
Kept_comdat_section_table kept_comdat_sections_;
// Whether this object has a GNU style .eh_frame section.
bool has_eh_frame_;
// True if the layout of this object was deferred, waiting for plugin
// replacement files.
bool is_deferred_layout_;
// The list of sections whose layout was deferred.
std::vector<Deferred_layout> deferred_layout_;
// The list of relocation sections whose layout was deferred.
std::vector<Deferred_layout> deferred_layout_relocs_;
// Pointer to the list of output views; valid only during do_relocate().
const Views* output_views_;
2006-08-05 01:10:59 +02:00
};
2006-09-26 23:00:34 +02:00
// A class to manage the list of all objects.
2006-09-26 23:00:34 +02:00
class Input_objects
{
public:
Input_objects()
: relobj_list_(), dynobj_list_(), sonames_(), cref_(NULL)
2006-09-26 23:00:34 +02:00
{ }
// The type of the list of input relocateable objects.
typedef std::vector<Relobj*> Relobj_list;
typedef Relobj_list::const_iterator Relobj_iterator;
// The type of the list of input dynamic objects.
typedef std::vector<Dynobj*> Dynobj_list;
typedef Dynobj_list::const_iterator Dynobj_iterator;
2006-09-26 23:00:34 +02:00
// Add an object to the list. Return true if all is well, or false
// if this object should be ignored.
bool
2006-09-26 23:00:34 +02:00
add_object(Object*);
* cref.cc: New file. * cref.h: New file. * options.h (class General_options): Add --print-symbol-counts. * main.cc (main): Issue defined symbol report if requested. * archive.cc (Archive::interpret_header): Make into a const member function. (Archive::add_symbols): Call Input_objects::archive_start and archive_stop. (Archive::const_iterator): Define new class. (Archive::begin, Archive::end): New functions. (Archive::include_all_members): Rewrite to use iterator. (Archive::count_members): New function. * archive.h (class Archive): Update declarations. (Archive::filename): New function. * object.cc: Include "cref.h". (Sized_relobj::Sized_relobj): Initialize defined_count_. (Sized_relobj::do_get_global_symbol_counts): New function. (Input_objects::add_object): Add object to cross-referencer. (Input_objects::archive_start): New function. (Input_objects::archive_stop): New function. (Input_objects::print_symbol_counts): New function. * object.h: Declare Cref and Archive. (Object::get_global_symbol_counts): New function. (Object::do_get_global_symbol_counts): New pure virtual function. (class Sized_relobj): Add defined_count_ field. Update declarations. (class Input_objects): Add cref_ field. Update constructor. Update declarations. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and defined_count_. (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing symbol counts. (Sized_dynobj::do_get_global_symbol_counts): New function. * dynobj.h (class Sized_dynobj): Add fields symbols_ and defined_count_. Update declarations. Define Symbols typedef. * symtab.cc (Symbol_table::add_from_relobj): Add defined parameter. Change all callers. (Symbol_table::add_from_dynobj): Add sympointers and defined parameters. Change all callers. * symtab.h (class Symbol_table): Update declarations. * Makefile.am (CCFILES): Add cref.cc. (HFILES): Add cref.h. * Makefile.in: Rebuild.
2008-07-23 00:08:43 +02:00
// Start processing an archive.
void
archive_start(Archive*);
// Stop processing an archive.
void
archive_stop(Archive*);
// For each dynamic object, check whether we've seen all of its
// explicit dependencies.
void
check_dynamic_dependencies() const;
// Return whether an object was found in the system library
// directory.
bool
found_in_system_library_directory(const Object*) const;
* cref.cc: New file. * cref.h: New file. * options.h (class General_options): Add --print-symbol-counts. * main.cc (main): Issue defined symbol report if requested. * archive.cc (Archive::interpret_header): Make into a const member function. (Archive::add_symbols): Call Input_objects::archive_start and archive_stop. (Archive::const_iterator): Define new class. (Archive::begin, Archive::end): New functions. (Archive::include_all_members): Rewrite to use iterator. (Archive::count_members): New function. * archive.h (class Archive): Update declarations. (Archive::filename): New function. * object.cc: Include "cref.h". (Sized_relobj::Sized_relobj): Initialize defined_count_. (Sized_relobj::do_get_global_symbol_counts): New function. (Input_objects::add_object): Add object to cross-referencer. (Input_objects::archive_start): New function. (Input_objects::archive_stop): New function. (Input_objects::print_symbol_counts): New function. * object.h: Declare Cref and Archive. (Object::get_global_symbol_counts): New function. (Object::do_get_global_symbol_counts): New pure virtual function. (class Sized_relobj): Add defined_count_ field. Update declarations. (class Input_objects): Add cref_ field. Update constructor. Update declarations. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and defined_count_. (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing symbol counts. (Sized_dynobj::do_get_global_symbol_counts): New function. * dynobj.h (class Sized_dynobj): Add fields symbols_ and defined_count_. Update declarations. Define Symbols typedef. * symtab.cc (Symbol_table::add_from_relobj): Add defined parameter. Change all callers. (Symbol_table::add_from_dynobj): Add sympointers and defined parameters. Change all callers. * symtab.h (class Symbol_table): Update declarations. * Makefile.am (CCFILES): Add cref.cc. (HFILES): Add cref.h. * Makefile.in: Rebuild.
2008-07-23 00:08:43 +02:00
// Print symbol counts.
void
print_symbol_counts(const Symbol_table*) const;
// Print a cross reference table.
void
print_cref(const Symbol_table*, FILE*) const;
// Iterate over all regular objects.
Relobj_iterator
relobj_begin() const
{ return this->relobj_list_.begin(); }
Relobj_iterator
relobj_end() const
{ return this->relobj_list_.end(); }
// Iterate over all dynamic objects.
Dynobj_iterator
dynobj_begin() const
{ return this->dynobj_list_.begin(); }
2006-09-26 23:00:34 +02:00
Dynobj_iterator
dynobj_end() const
{ return this->dynobj_list_.end(); }
2006-09-26 23:00:34 +02:00
// Return whether we have seen any dynamic objects.
bool
any_dynamic() const
{ return !this->dynobj_list_.empty(); }
2006-09-26 23:00:34 +02:00
// Return the number of non dynamic objects.
int
number_of_relobjs() const
{ return this->relobj_list_.size(); }
// Return the number of input objects.
int
number_of_input_objects() const
{ return this->relobj_list_.size() + this->dynobj_list_.size(); }
2006-09-26 23:00:34 +02:00
private:
Input_objects(const Input_objects&);
Input_objects& operator=(const Input_objects&);
// The list of ordinary objects included in the link.
Relobj_list relobj_list_;
// The list of dynamic objects included in the link.
Dynobj_list dynobj_list_;
// SONAMEs that we have seen.
Unordered_map<std::string, Object*> sonames_;
* cref.cc: New file. * cref.h: New file. * options.h (class General_options): Add --print-symbol-counts. * main.cc (main): Issue defined symbol report if requested. * archive.cc (Archive::interpret_header): Make into a const member function. (Archive::add_symbols): Call Input_objects::archive_start and archive_stop. (Archive::const_iterator): Define new class. (Archive::begin, Archive::end): New functions. (Archive::include_all_members): Rewrite to use iterator. (Archive::count_members): New function. * archive.h (class Archive): Update declarations. (Archive::filename): New function. * object.cc: Include "cref.h". (Sized_relobj::Sized_relobj): Initialize defined_count_. (Sized_relobj::do_get_global_symbol_counts): New function. (Input_objects::add_object): Add object to cross-referencer. (Input_objects::archive_start): New function. (Input_objects::archive_stop): New function. (Input_objects::print_symbol_counts): New function. * object.h: Declare Cref and Archive. (Object::get_global_symbol_counts): New function. (Object::do_get_global_symbol_counts): New pure virtual function. (class Sized_relobj): Add defined_count_ field. Update declarations. (class Input_objects): Add cref_ field. Update constructor. Update declarations. * dynobj.cc (Sized_dynobj::Sized_dynobj): Initialize symbols_ and defined_count_. (Sized_dynobj::do_add_symbols): Allocate symbols_ if printing symbol counts. (Sized_dynobj::do_get_global_symbol_counts): New function. * dynobj.h (class Sized_dynobj): Add fields symbols_ and defined_count_. Update declarations. Define Symbols typedef. * symtab.cc (Symbol_table::add_from_relobj): Add defined parameter. Change all callers. (Symbol_table::add_from_dynobj): Add sympointers and defined parameters. Change all callers. * symtab.h (class Symbol_table): Update declarations. * Makefile.am (CCFILES): Add cref.cc. (HFILES): Add cref.h. * Makefile.in: Rebuild.
2008-07-23 00:08:43 +02:00
// Manage cross-references if requested.
Cref* cref_;
2006-09-26 23:00:34 +02:00
};
// Some of the information we pass to the relocation routines. We
// group this together to avoid passing a dozen different arguments.
template<int size, bool big_endian>
struct Relocate_info
{
// Symbol table.
const Symbol_table* symtab;
// Layout.
const Layout* layout;
// Object being relocated.
* incremental-dump.cc (dump_incremental_inputs): Print dynamic reloc 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.
2011-05-24 23:41:10 +02:00
Sized_relobj_file<size, big_endian>* object;
// Section index of relocation section.
unsigned int reloc_shndx;
// Section header of relocation section.
const unsigned char* reloc_shdr;
[GOLD] Relocate::relocate() params Some linker code editing needs to change multiple insns. In some cases multiple relocations are involved and it is not sufficient to make the changes independently as relocations are processed, because doing so might lead to a partial edit. So in order to safely edit we need all the relocations available in relocate(). Also, to emit edited relocs corresponding to the edited code sequence we need some way to pass information from relocate() to relocate_relocs(), particularly if the edit depends on insns. We can't modify input relocs in relocate() as they are mmapped PROT_READ, nor it is particularly clean to write relocs to the output at that stage. So add a Relocatable_relocs* field to relinfo to mark edited relocs. Given that relocate is passed the raw reloc pointer, it makes sense to remove the rel/rela parameter and r_type too. However, that means the mips relocate() needs to know whether SHT_REL or SHT_RELA relocs are being processed. So add a rel_type for mips, which also has the benefit of removing relocate() overloading there. This patch adds the infrastructure without making use of it. Note that relinfo->rr will be NULL if not outputting relocations. * object.h (struct Relocate_info): Add "rr". * reloc.h (Relocatable_relocs::set_strategy): New accessor. * reloc.cc (Sized_relobj_file::do_relocate_sections): Init relinfo.rr for relocate_section and relocate_relocs. * powerpc.cc (relocate): Add rel_type and preloc parameters. Delete rela and r_type params, instead recalculate these from preloc. (relocate_relocs): Delete Relocatable_relocs* param, instead use relinfo->rr. * aarch64.cc: Likewise. * arm.cc: Likewise. * i386.cc: Likewise. * mips.cc: Likewise. * s390.cc: Likewise. * sparc.cc: Likewise. * target.h: Likewise. * tilegx.cc: Likewise. * x86_64.cc: Likewise. * testsuite/testfile.cc: Likewise. * target-reloc.h (relocate_section): Adjust to suit. (apply_relocation, relocate_relocs): Likewise.
2015-12-09 00:48:30 +01:00
// Info about how relocs should be handled
Relocatable_relocs* rr;
// Section index of section being relocated.
unsigned int data_shndx;
// Section header of data section.
const unsigned char* data_shdr;
// Return a string showing the location of a relocation. This is
// only used for error messages.
std::string
location(size_t relnum, off_t reloffset) const;
};
2010-01-20 Doug Kwan <dougkwan@google.com> * 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.
2010-01-20 18:29:52 +01:00
// This is used to represent a section in an object and is used as the
// key type for various section maps.
Change Section_id type to use Relobj* instead of Object*. 2015-04-29 Cary Coutant <cary@google.com> Rafael Ávila de Espíndola <rafael.espindola@gmail.com> gold/ * gc.h (Garbage_collection::is_section_garbage): Change Object* to Relobj*. (Garbage_collection::add_reference): Likewise. (Garbage_collection::gc_process_relocs): Likewise. Don't push object/shndx pair onto *secvec for dynamic objects. Don't follow relocations pointing to dynamic objects for GC. * icf.cc (Icf::find_identical_sections): Change Object* to Relobj*. (Icf::unfold_section): Likewise. (Icf::is_section_folded): Likewise. (Icf::get_folded_section): Likewise. * icf.h: (Icf::get_folded_section): Likewise. (Icf::unfold_section): Likewise. (Icf::is_section_folded): Likewise. (Icf::section_has_function_pointers): Likewise. (Icf::set_section_has_function_pointers): Likewise. * object.h (Section_id): Likewise. (Const_section_id): Likewise. * output.cc (Output_section::update_section_layout): Likewise. * output.h: (Output_section_lookup_maps::find_relaxed_input_section): Likewise. * plugin.cc (update_section_order): Likewise. (unique_segment_for_sections): Likewise. * powerpc.cc (Powerpc_relobj::add_reference): Likewise. (Target_powerpc::do_gc_add_reference): Likewise. (Target_powerpc::gc_process_relocs): Likewise. (Target_powerpc::do_gc_add_reference): Likewise. * symtab.cc (Symbol_table::is_section_folded): Likewise. (Symbol_table::gc_mark_symbol): Likewise. * symtab.h: (Symbol_table::is_section_folded): Likewise. * target.h: (Sized_target::gc_add_reference): Likewise. (Sized_target::do_gc_add_reference): Likewise.
2015-05-02 17:40:09 +02:00
typedef std::pair<Relobj*, unsigned int> Section_id;
2010-01-20 Doug Kwan <dougkwan@google.com> * 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.
2010-01-20 18:29:52 +01:00
// This is similar to Section_id but is used when the section
// pointers are const.
Change Section_id type to use Relobj* instead of Object*. 2015-04-29 Cary Coutant <cary@google.com> Rafael Ávila de Espíndola <rafael.espindola@gmail.com> gold/ * gc.h (Garbage_collection::is_section_garbage): Change Object* to Relobj*. (Garbage_collection::add_reference): Likewise. (Garbage_collection::gc_process_relocs): Likewise. Don't push object/shndx pair onto *secvec for dynamic objects. Don't follow relocations pointing to dynamic objects for GC. * icf.cc (Icf::find_identical_sections): Change Object* to Relobj*. (Icf::unfold_section): Likewise. (Icf::is_section_folded): Likewise. (Icf::get_folded_section): Likewise. * icf.h: (Icf::get_folded_section): Likewise. (Icf::unfold_section): Likewise. (Icf::is_section_folded): Likewise. (Icf::section_has_function_pointers): Likewise. (Icf::set_section_has_function_pointers): Likewise. * object.h (Section_id): Likewise. (Const_section_id): Likewise. * output.cc (Output_section::update_section_layout): Likewise. * output.h: (Output_section_lookup_maps::find_relaxed_input_section): Likewise. * plugin.cc (update_section_order): Likewise. (unique_segment_for_sections): Likewise. * powerpc.cc (Powerpc_relobj::add_reference): Likewise. (Target_powerpc::do_gc_add_reference): Likewise. (Target_powerpc::gc_process_relocs): Likewise. (Target_powerpc::do_gc_add_reference): Likewise. * symtab.cc (Symbol_table::is_section_folded): Likewise. (Symbol_table::gc_mark_symbol): Likewise. * symtab.h: (Symbol_table::is_section_folded): Likewise. * target.h: (Sized_target::gc_add_reference): Likewise. (Sized_target::do_gc_add_reference): Likewise.
2015-05-02 17:40:09 +02:00
typedef std::pair<const Relobj*, unsigned int> Const_section_id;
2010-01-20 Doug Kwan <dougkwan@google.com> * 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.
2010-01-20 18:29:52 +01:00
// The hash value is based on the address of an object in memory during
// linking. It is okay to use this for looking up sections but never use
// this in an unordered container that we want to traverse in a repeatable
// manner.
struct Section_id_hash
{
size_t operator()(const Section_id& loc) const
{ return reinterpret_cast<uintptr_t>(loc.first) ^ loc.second; }
};
struct Const_section_id_hash
{
size_t operator()(const Const_section_id& loc) const
{ return reinterpret_cast<uintptr_t>(loc.first) ^ loc.second; }
};
// Return whether INPUT_FILE contains an ELF object start at file
// offset OFFSET. This sets *START to point to a view of the start of
// the file. It sets *READ_SIZE to the number of bytes in the view.
extern bool
is_elf_object(Input_file* input_file, off_t offset,
const unsigned char** start, int* read_size);
2006-08-05 01:10:59 +02:00
// Return an Object appropriate for the input file. P is BYTES long,
* readsyms.cc (Read_symbols::incompatible_warning): New function. (Read_symbols::requeue): New function. (Read_symbols::do_read_symbols): If make_elf_object fails because the target type is not configured, and the file was searched for, issue a warning and retry with the next directory. (Add_symbols::run): If the file has an incompatible format, and it was searched for, requeue the Read_symbols task. On error, release the object. * readsyms.h (class Read_symbols): Add dirindex_ field. Add dirindex parameter to constructor. Change all callers. Declare incompatible_warning and requeue. (class Add_symbols): Add dirpath_, dirindex_, mapfile_, input_argument_ and input_group_ fields. Add them to constructor. Change all callers. (class Read_script): Add dirindex_ field. Add it to constructor. Change all callers. * archive.cc (Archive::setup): Remove input_objects parameter. Change all callers. (Archive::get_file_and_offset): Likewise. (Archive::read_all_symbols): Likewise. (Archive::read_symbols): Likewise. (Archive::get_elf_object_for_member): Remove input_objects parameter. Add punconfigured parameter. Change all callers. (Archive::add_symbols): Change return type to bool. Check return value of include_member. (Archive::include_all_members): Likewise. (Archive::include_member): Change return type to bool. Return false if first included object has incompatible target. Set included_member_ field. (Add_archive_symbols::run): If add_symbols returns false, requeue Read_symbols task. * archive.h (class Archive): Add included_member_ field. Initialize it in constructor. Add input_file and searched_for methods. Update declarations. (class Add_archive_symbols): Add dirpath_, dirindex_, and input_argument_ fields. Add them to constructor. Change all callers. * script.cc: Include "target-select.h". (class Parser_closure): Add skip_on_incompatible_target_ and found_incompatible_target_ fields. Add skip_on_incompatible_target parameter to constructor. Change all callers. Add methods skip_on_incompatible_target, clear_skip_on_incompatible_target, found_incompatible_target, and set_found_incompatible_target. (read_input_script): Add dirindex parameter. Change all callers. If parser finds an incompatible target, requeue Read_symbols task. (script_set_symbol): Clear skip_on_incompatible_target in closure. (script_add_assertion, script_parse_option): Likewise. (script_start_sections, script_add_phdr): Likewise. (script_check_output_format): New function. * script.h (read_input_script): Update declaration. * script-c.h (script_check_output_format): Declare. * yyscript.y (file_cmd): Handle OUTPUT_FORMAT. (ignore_cmd): Remove OUTPUT_FORMAT. * fileread.cc (Input_file::Input_file): Add explicit this. (Input_file::will_search_for): New function. (Input_file::open): Add pindex parameter. Change all callers. * fileread.h (class Input_file): Add input_file_argument method. Declare will_search_for. Update declarations. * object.cc (make_elf_object): Add punconfigured parameter. Change all callers. * object.h (class Object): Make input_file public. Add searched_for method. (make_elf_object): Update declaration. * dirsearch.cc (Dirsearch::find): Add pindex parameter. Use it to restart search. * dirsearch.h (class Dirsearch): Update declaration. * options.h (class General_options): Add --warn-search-mismatch. * parameters.cc (Parameters::is_compatible_target): New function. * parameters.h (class Parameters): Declare is_compatible_target. * workqueue.cc (Workqueue::add_blocker): New function. * workqueue.h (class Workqueue): Declare add_blocker.
2009-03-14 06:56:46 +01:00
// and holds the ELF header. If PUNCONFIGURED is not NULL, then if
// this sees an object the linker is not configured to support, it
// sets *PUNCONFIGURED to true and returns NULL without giving an
// error message.
2006-08-05 01:10:59 +02:00
extern Object*
make_elf_object(const std::string& name, Input_file*,
off_t offset, const unsigned char* p,
* readsyms.cc (Read_symbols::incompatible_warning): New function. (Read_symbols::requeue): New function. (Read_symbols::do_read_symbols): If make_elf_object fails because the target type is not configured, and the file was searched for, issue a warning and retry with the next directory. (Add_symbols::run): If the file has an incompatible format, and it was searched for, requeue the Read_symbols task. On error, release the object. * readsyms.h (class Read_symbols): Add dirindex_ field. Add dirindex parameter to constructor. Change all callers. Declare incompatible_warning and requeue. (class Add_symbols): Add dirpath_, dirindex_, mapfile_, input_argument_ and input_group_ fields. Add them to constructor. Change all callers. (class Read_script): Add dirindex_ field. Add it to constructor. Change all callers. * archive.cc (Archive::setup): Remove input_objects parameter. Change all callers. (Archive::get_file_and_offset): Likewise. (Archive::read_all_symbols): Likewise. (Archive::read_symbols): Likewise. (Archive::get_elf_object_for_member): Remove input_objects parameter. Add punconfigured parameter. Change all callers. (Archive::add_symbols): Change return type to bool. Check return value of include_member. (Archive::include_all_members): Likewise. (Archive::include_member): Change return type to bool. Return false if first included object has incompatible target. Set included_member_ field. (Add_archive_symbols::run): If add_symbols returns false, requeue Read_symbols task. * archive.h (class Archive): Add included_member_ field. Initialize it in constructor. Add input_file and searched_for methods. Update declarations. (class Add_archive_symbols): Add dirpath_, dirindex_, and input_argument_ fields. Add them to constructor. Change all callers. * script.cc: Include "target-select.h". (class Parser_closure): Add skip_on_incompatible_target_ and found_incompatible_target_ fields. Add skip_on_incompatible_target parameter to constructor. Change all callers. Add methods skip_on_incompatible_target, clear_skip_on_incompatible_target, found_incompatible_target, and set_found_incompatible_target. (read_input_script): Add dirindex parameter. Change all callers. If parser finds an incompatible target, requeue Read_symbols task. (script_set_symbol): Clear skip_on_incompatible_target in closure. (script_add_assertion, script_parse_option): Likewise. (script_start_sections, script_add_phdr): Likewise. (script_check_output_format): New function. * script.h (read_input_script): Update declaration. * script-c.h (script_check_output_format): Declare. * yyscript.y (file_cmd): Handle OUTPUT_FORMAT. (ignore_cmd): Remove OUTPUT_FORMAT. * fileread.cc (Input_file::Input_file): Add explicit this. (Input_file::will_search_for): New function. (Input_file::open): Add pindex parameter. Change all callers. * fileread.h (class Input_file): Add input_file_argument method. Declare will_search_for. Update declarations. * object.cc (make_elf_object): Add punconfigured parameter. Change all callers. * object.h (class Object): Make input_file public. Add searched_for method. (make_elf_object): Update declaration. * dirsearch.cc (Dirsearch::find): Add pindex parameter. Use it to restart search. * dirsearch.h (class Dirsearch): Update declaration. * options.h (class General_options): Add --warn-search-mismatch. * parameters.cc (Parameters::is_compatible_target): New function. * parameters.h (class Parameters): Declare is_compatible_target. * workqueue.cc (Workqueue::add_blocker): New function. * workqueue.h (class Workqueue): Declare add_blocker.
2009-03-14 06:56:46 +01:00
section_offset_type bytes, bool* punconfigured);
2006-08-05 01:10:59 +02:00
} // end namespace gold
#endif // !defined(GOLD_OBJECT_H)