2006-08-19 06:29:20 +08:00
|
|
|
// target.h -- target support for gold -*- C++ -*-
|
2006-08-05 07:10:59 +08:00
|
|
|
|
2010-08-13 06:15:00 +08:00
|
|
|
// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
2007-09-23 05:02:10 +08:00
|
|
|
// 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 07:10:59 +08:00
|
|
|
// The abstract class Target is the interface for target specific
|
|
|
|
// support. It defines abstract methods which each target must
|
|
|
|
// implement. Typically there will be one target per processor, but
|
|
|
|
// in some cases it may be necessary to have subclasses.
|
|
|
|
|
|
|
|
// For speed and consistency we want to use inline functions to handle
|
|
|
|
// relocation processing. So besides implementations of the abstract
|
|
|
|
// methods, each target is expected to define a template
|
|
|
|
// specialization of the relocation functions.
|
|
|
|
|
|
|
|
#ifndef GOLD_TARGET_H
|
|
|
|
#define GOLD_TARGET_H
|
|
|
|
|
2006-08-19 06:29:20 +08:00
|
|
|
#include "elfcpp.h"
|
2008-02-28 08:18:24 +08:00
|
|
|
#include "options.h"
|
2008-02-27 06:10:32 +08:00
|
|
|
#include "parameters.h"
|
2009-09-17 Doug Kwan <dougkwan@google.com>
* debug.h (DEBUG_RELAXATION): New constant.
(DEBUG_ALL): Add DEBUG_RELAXATION.
(debug_string_to_enum): Add relaxation debug option.
* layout.cc
(Layout::Relaxation_debug_check::check_output_data_for_reset_values,
Layout::Relaxation_debug_check::read_sections,
Layout::Relaxation_debug_check::read_sections): New method definitions.
(Layout::Layout): Initialize data members
record_output_section_data_from_scrips_,
script_output_section_data_list_ and relaxation_debug_check_.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method definitions.
(Layout::finalize): Support relaxation. Move section layout code to
Layout::relaxation_loop_body.
(Layout::set_asection_address_from_script): Move code for orphan
section placement out.
(Layout::place_orphan_sections_in_script): New method definition.
* layout.h (Output_segment_headers, Output_file_header):
New forward class declarations.
(Layout::~Layout): Define.
(Layout::new_output_section_data_from_script): New method definition.
(Layout::place_orphan_sections_in_script): New method declaration.
(Layout::Segment_states): New type declaration.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method declarations.
(Layout::Output_section_data_list): New type declaration.
(Layout::Relaxation_debug_check): New class definition.
(Layout::record_output_section_data_from_script_,
Layout::script_output_section_data_list_, Layout::segment_states_,
Layout::relaxation_debug_check_): New data members.
* output.cc: (Output_section_headers::do_size): New method definition.
(Output_section_headers::Output_section_headers): Move size
computation to Output_section_headers::do_size.
(Output_segment_headers::do_size): New method definition.
(Output_file_header::Output_file_header): Move size computation to
Output_file_header::do_size and call it.
(Output_file_header::do_size): New method definition.
(Output_data_group::Output_data_group): Adjust call to
Output_section_data.
(Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
(Output_symtab_xindex::do_write): Add array bound check.
(Output_section::Input_section::print_to_mapfile): Handle
RELAXED_INPUT_SECTION_CODE.
(Output_section::Output_section): Initialize data member checkpoint_.
(Output_section::~Output_section): Delete checkpoint object pointed
by checkpoint_.
(Output_section::add_input_section): Always add an Input_section if
relaxing.
(Output_section::add_merge_input_section): Add assert.
(Output_section::relax_input_section): New method definition.
(Output_section::set_final_data_size): Set load address to zero for
an unallocated section.
(Output_section::do_address_and_file_offset_have_reset_values):
New method definition.
(Output_section::Input_section_sort_enty::Input_section_sort_enty):
Handle relaxed input section.
(Output_section::sort_attached_input_sections): Checkpoint input
section list lazily.
(Output_section::get_input_sections): Change type of input_sections to
list of Simple_input_section pointers. Checkpoint input section list
lazily. Also handle relaxed input sections.
(Output_section::add_input_section_for_script): Take a reference to
a Simple_input_section object instead of Relobj pointer and section
index as parameter. Handle relaxed input sections.
(Output_section::save_states, Output_section::restore_states): New
method definitions.
* output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
(Output_data::is_data_size_fixed): New method definition.
(Output_data::reset_addresss_and_file_offset): Do not reset data size
if it is fixed.
(Output_data::address_and_file_offset_have_reset_values): New method
definition.
(Output_data::do_address_and_file_offset_have_reset_values): New method
definition.
(Output_data::set_data_size): Check that data size is not fixed.
(Output_data::fix_data_size): New method definition.
(Output_data::is_data_size_fixed_): New data member.
(Output_section_headers::set_final_data_size): New method definition.
(Output_section_headers::do_size): New method declaration.
(Output_segment_headers::set_final_data_size): New method definition.
(Output_segment_headers::do_size): New method declaration.
(Output_file_header::set_final_data_size)::New method definition.
(Output_file_header::do_size)::New method declaration.
(Output_section_data::Output_section_data): Add new parameter
is_data_size_fixed and use it to fix data size.
(Output_data_const::Output_data_const): Adjust call to base class
constructor and fix data size.
(Output_data_const_buffer::Output_data_const_buffer): Adjust call to
base class constructor and fix data size.
(Output_data_fixed_space::Output_data_fixed_space): Adjust call to
base class constructor and fix data size.
(Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
class constructor and fix data size.
(Output_data_group::set_final_data_size): New method definition.
(Output_data_dynamic::Dynamic_entry::tag): New method definition.
(Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
class constructor and fix data size.
(Output_relaxed_input_section): New class definition.
(Output_section::Simple_input_section): New class definition.
(Output_section::get_input_sections): Adjust parameter list.
(Output_section::add_input_section_for_script): Same.
(Output_section::save_states, Output_section::restore_states,
Output_section::do_address_and_file_offset_have_reset_values,
(Output_section::Input_section::Input_section): Handle
RELAXED_INPUT_SECTION_CODE. Add new overload for
Output_relaxed_input_section.
(Output_section::Input_section::is_input_section,
Output_section::Input_section::set_output_section): Handle relaxed
input section.
(Output_section::Input_section::is_relaxed_input_section,
Output_section::Input_section::output_section_data,
Output_section::Input_section::relaxed_input_section): New method
definitions.
(Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
value.
(Output_section::Input_section::u1_): Update comments.
(Output_section::Input_section::u2_): Add new union member poris.
(Output_section::Checkpoint_output_section): New classs definition.
(Output_section::relax_input_section): New method declaration.
(Output_section::checkpoint_): New data member.
(Output_segment): Update comments.
(Output_segment::Output_segment): Un-privatize copy constructor.
(Output_segment::operator=): Un-privatize.
* script-sections.cc (Output_section_element::Input_section_list):
Change element type to Output_section::Simple_input_section.
(Output_section_element_dot_assignment::set_section_addresses):
Register output section data for relaxation clean up.
(Output_data_exression::Output_data_expression): Adjust call to base
constructor to fix data size.
(Output_section_element_data::set_section_addresses): Register
Output_data_expression object for relaxation clean up.
(struct Input_section_info): Replace Relobj pointer and section index
pair with Output_section::Simple_input_section and Convert struct to a
class.
(Input_section_sorter::operator()): Adjust access to
Input_section_info data member to use accessors.
(Output_section_element_input::set_section_addresses): Use layout
parameter. Adjust code to use Output_section::Simple_input_section
and Input_secction_info classes. Register filler for relaxation
clean up.
(Orphan_output_section::set_section_addresses): Replace Relobj pointer
and section index pair with Output_section::Simple_input_section
class. Adjust code accordingly.
(Phdrs_element::release_segment): New method definition.
(Script_sections::attach_sections_using_phdrs_clause): Do not modify
segment list.
(Script_sections::release_segments): New method definition.
* gold/script-sections.h (Script_sections::release_segments): New
method declaration.
* gold/target.h (Target::may_relax, Target::relax,
Target::do_may_relax, Target::do_relax): New method definitions.
2009-09-18 09:10:38 +08:00
|
|
|
#include "debug.h"
|
2006-08-19 06:29:20 +08:00
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
namespace gold
|
|
|
|
{
|
|
|
|
|
2006-08-19 06:29:20 +08:00
|
|
|
class Object;
|
2009-10-07 06:58:27 +08:00
|
|
|
class Relobj;
|
2006-09-30 03:58:17 +08:00
|
|
|
template<int size, bool big_endian>
|
2006-11-07 06:46:08 +08:00
|
|
|
class Sized_relobj;
|
2008-02-06 16:13:50 +08:00
|
|
|
class Relocatable_relocs;
|
2006-10-21 04:40:49 +08:00
|
|
|
template<int size, bool big_endian>
|
2007-11-09 15:00:15 +08:00
|
|
|
class Relocate_info;
|
2009-10-07 06:58:27 +08:00
|
|
|
class Reloc_symbol_changes;
|
2006-11-07 06:46:08 +08:00
|
|
|
class Symbol;
|
|
|
|
template<int size>
|
|
|
|
class Sized_symbol;
|
|
|
|
class Symbol_table;
|
2010-08-20 06:50:16 +08:00
|
|
|
class Output_data;
|
2007-11-09 15:00:15 +08:00
|
|
|
class Output_section;
|
2009-10-30 Doug Kwan <dougkwan@google.com>
elfcpp/ChangeLog:
* arm.h (EF_ARM_BE8, EF_ARM_EABIMASK, EF_ARM_EABI_UNKNOWN,
EF_ARM_EABI_VER1, EF_ARM_EABI_VER2, EF_ARM_EABI_VER3,
EF_ARM_EABI_VER4, EF_ARM_EABI_VER5): New enums for processor-specific
flags.
(arm_eabi_version): New inline function.
* elfcpp.h: Add a comment about DT_ENCODING.
gold/ChangeLog:
* arm.cc (Arm_relobj::processor_specific_flags): New method
definition.
(Arm_relobj::do_read_symbols): New method declaration.
(Arm_relobj::processor_specific_flags_): New data member declaration.
(Arm_dynobj): New class definition.
(Target_arm::do_finalize_sections): Add input_objects parameter.
(Target_arm::do_adjust_elf_header): New method declaration.
(Target_arm::are_eabi_versions_compatible,
(Target_arm::merge_processor_specific_flags): New method declaration.
(Target_arm::do_make_elf_object): New overloaded method definitions
and declaration.
(Arm_relobj::do_read_symbols): New method definition.
(Arm_dynobj::do_read_symbols): Ditto.
(Target_arm::do_finalize_sections): Add input_objects parameters.
Merge processor-specific flags from all input objects.
(Target_arm::are_eabi_versions_compatible,
Target_arm::merge_processor_specific_flags,
Target_arm::do_adjust_elf_header, Target_arm::do_make_elf_object):
New method definitions.
* i386.cc (Target_i386::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
* layout.cc (Layout::finalize): Pass input objects to target's.
finalize_sections function.
* output.cc (Output_file_header::do_sized_write): Set ELF file
header's processor-specific flags.
* powerpc.cc (Target_powerpc::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
* sparc.cc (Target_sparc::do_finalize_sections): Same.
* target.h (Input_objects): New forward class declaration.
(Target::processor_specific_flags,
Target::are_processor_specific_flags_sect): New method definitions.
(Target::finalize_sections): Add input_objects parameter.
(Target::Target): Initialize processor_specific_flags_ and
are_processor_specific_flags_set_.
(Target::do_finalize_sections): Add unnamed Input_objects pointer type
parameter.
(Target::set_processor_specific_flags): New method definition.
(Target::processor_specific_flags_,
Target::are_processor_specific_flags_set_): New data member
declarations.
* x86_64.cc (Target_x86_64::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
2009-10-31 02:49:59 +08:00
|
|
|
class Input_objects;
|
2010-11-09 15:56:10 +08:00
|
|
|
class Task;
|
2006-08-19 06:29:20 +08:00
|
|
|
|
|
|
|
// The abstract class for target specific handling.
|
|
|
|
|
2006-08-05 07:10:59 +08:00
|
|
|
class Target
|
|
|
|
{
|
|
|
|
public:
|
2006-08-19 06:29:20 +08:00
|
|
|
virtual ~Target()
|
|
|
|
{ }
|
|
|
|
|
2010-02-13 10:04:21 +08:00
|
|
|
// Virtual function which is set to return true by a target if
|
|
|
|
// it can use relocation types to determine if a function's
|
|
|
|
// pointer is taken.
|
|
|
|
virtual bool
|
|
|
|
can_check_for_function_pointers() const
|
|
|
|
{ return false; }
|
|
|
|
|
2010-09-29 01:14:15 +08:00
|
|
|
// This function is used in ICF (icf.cc). This is set to true by
|
|
|
|
// the target if a relocation to a merged section can be processed
|
|
|
|
// to retrieve the contents of the merged section.
|
|
|
|
virtual bool
|
|
|
|
can_icf_inline_merge_sections () const
|
|
|
|
{ return false; }
|
|
|
|
|
2010-06-25 08:37:40 +08:00
|
|
|
// Whether a section called SECTION_NAME may have function pointers to
|
|
|
|
// sections not eligible for safe ICF folding.
|
|
|
|
virtual bool
|
|
|
|
section_may_have_icf_unsafe_pointers(const char* section_name) const
|
|
|
|
{
|
|
|
|
// We recognize sections for normal vtables, construction vtables and
|
|
|
|
// EH frames.
|
|
|
|
return (!is_prefix_of(".rodata._ZTV", section_name)
|
|
|
|
&& !is_prefix_of(".data.rel.ro._ZTV", section_name)
|
|
|
|
&& !is_prefix_of(".rodata._ZTC", section_name)
|
|
|
|
&& !is_prefix_of(".data.rel.ro._ZTC", section_name)
|
|
|
|
&& !is_prefix_of(".eh_frame", section_name));
|
|
|
|
}
|
|
|
|
|
2006-08-19 06:29:20 +08:00
|
|
|
// Return the bit size that this target implements. This should
|
|
|
|
// return 32 or 64.
|
|
|
|
int
|
|
|
|
get_size() const
|
2006-09-28 06:53:42 +08:00
|
|
|
{ return this->pti_->size; }
|
2006-08-19 06:29:20 +08:00
|
|
|
|
|
|
|
// Return whether this target is big-endian.
|
|
|
|
bool
|
|
|
|
is_big_endian() const
|
2006-09-28 06:53:42 +08:00
|
|
|
{ return this->pti_->is_big_endian; }
|
2006-08-19 06:29:20 +08:00
|
|
|
|
2006-09-30 03:58:17 +08:00
|
|
|
// Machine code to store in e_machine field of ELF header.
|
|
|
|
elfcpp::EM
|
|
|
|
machine_code() const
|
|
|
|
{ return this->pti_->machine_code; }
|
|
|
|
|
2009-10-30 Doug Kwan <dougkwan@google.com>
elfcpp/ChangeLog:
* arm.h (EF_ARM_BE8, EF_ARM_EABIMASK, EF_ARM_EABI_UNKNOWN,
EF_ARM_EABI_VER1, EF_ARM_EABI_VER2, EF_ARM_EABI_VER3,
EF_ARM_EABI_VER4, EF_ARM_EABI_VER5): New enums for processor-specific
flags.
(arm_eabi_version): New inline function.
* elfcpp.h: Add a comment about DT_ENCODING.
gold/ChangeLog:
* arm.cc (Arm_relobj::processor_specific_flags): New method
definition.
(Arm_relobj::do_read_symbols): New method declaration.
(Arm_relobj::processor_specific_flags_): New data member declaration.
(Arm_dynobj): New class definition.
(Target_arm::do_finalize_sections): Add input_objects parameter.
(Target_arm::do_adjust_elf_header): New method declaration.
(Target_arm::are_eabi_versions_compatible,
(Target_arm::merge_processor_specific_flags): New method declaration.
(Target_arm::do_make_elf_object): New overloaded method definitions
and declaration.
(Arm_relobj::do_read_symbols): New method definition.
(Arm_dynobj::do_read_symbols): Ditto.
(Target_arm::do_finalize_sections): Add input_objects parameters.
Merge processor-specific flags from all input objects.
(Target_arm::are_eabi_versions_compatible,
Target_arm::merge_processor_specific_flags,
Target_arm::do_adjust_elf_header, Target_arm::do_make_elf_object):
New method definitions.
* i386.cc (Target_i386::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
* layout.cc (Layout::finalize): Pass input objects to target's.
finalize_sections function.
* output.cc (Output_file_header::do_sized_write): Set ELF file
header's processor-specific flags.
* powerpc.cc (Target_powerpc::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
* sparc.cc (Target_sparc::do_finalize_sections): Same.
* target.h (Input_objects): New forward class declaration.
(Target::processor_specific_flags,
Target::are_processor_specific_flags_sect): New method definitions.
(Target::finalize_sections): Add input_objects parameter.
(Target::Target): Initialize processor_specific_flags_ and
are_processor_specific_flags_set_.
(Target::do_finalize_sections): Add unnamed Input_objects pointer type
parameter.
(Target::set_processor_specific_flags): New method definition.
(Target::processor_specific_flags_,
Target::are_processor_specific_flags_set_): New data member
declarations.
* x86_64.cc (Target_x86_64::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
2009-10-31 02:49:59 +08:00
|
|
|
// Processor specific flags to store in e_flags field of ELF header.
|
|
|
|
elfcpp::Elf_Word
|
|
|
|
processor_specific_flags() const
|
|
|
|
{ return this->processor_specific_flags_; }
|
|
|
|
|
|
|
|
// Whether processor specific flags are set at least once.
|
|
|
|
bool
|
|
|
|
are_processor_specific_flags_set() const
|
|
|
|
{ return this->are_processor_specific_flags_set_; }
|
|
|
|
|
2006-08-19 06:29:20 +08:00
|
|
|
// Whether this target has a specific make_symbol function.
|
|
|
|
bool
|
|
|
|
has_make_symbol() const
|
2006-09-28 06:53:42 +08:00
|
|
|
{ return this->pti_->has_make_symbol; }
|
2006-08-19 06:29:20 +08:00
|
|
|
|
|
|
|
// Whether this target has a specific resolve function.
|
|
|
|
bool
|
|
|
|
has_resolve() const
|
2006-09-28 06:53:42 +08:00
|
|
|
{ return this->pti_->has_resolve; }
|
|
|
|
|
2007-09-21 13:31:19 +08:00
|
|
|
// Whether this target has a specific code fill function.
|
|
|
|
bool
|
|
|
|
has_code_fill() const
|
|
|
|
{ return this->pti_->has_code_fill; }
|
|
|
|
|
2006-11-15 03:21:05 +08:00
|
|
|
// Return the default name of the dynamic linker.
|
|
|
|
const char*
|
|
|
|
dynamic_linker() const
|
|
|
|
{ return this->pti_->dynamic_linker; }
|
|
|
|
|
2006-09-28 06:53:42 +08:00
|
|
|
// Return the default address to use for the text segment.
|
|
|
|
uint64_t
|
2007-10-17 06:38:36 +08:00
|
|
|
default_text_segment_address() const
|
|
|
|
{ return this->pti_->default_text_segment_address; }
|
2006-09-28 06:53:42 +08:00
|
|
|
|
|
|
|
// Return the ABI specified page size.
|
|
|
|
uint64_t
|
|
|
|
abi_pagesize() const
|
2008-02-27 06:10:32 +08:00
|
|
|
{
|
2008-02-28 08:18:24 +08:00
|
|
|
if (parameters->options().max_page_size() > 0)
|
|
|
|
return parameters->options().max_page_size();
|
2008-02-27 06:10:32 +08:00
|
|
|
else
|
|
|
|
return this->pti_->abi_pagesize;
|
|
|
|
}
|
2006-09-28 06:53:42 +08:00
|
|
|
|
|
|
|
// Return the common page size used on actual systems.
|
|
|
|
uint64_t
|
|
|
|
common_pagesize() const
|
2008-02-27 06:10:32 +08:00
|
|
|
{
|
2008-02-28 08:18:24 +08:00
|
|
|
if (parameters->options().common_page_size() > 0)
|
|
|
|
return std::min(parameters->options().common_page_size(),
|
2008-02-27 06:10:32 +08:00
|
|
|
this->abi_pagesize());
|
|
|
|
else
|
|
|
|
return std::min(this->pti_->common_pagesize,
|
|
|
|
this->abi_pagesize());
|
|
|
|
}
|
2006-08-19 06:29:20 +08:00
|
|
|
|
2007-10-23 13:05:48 +08:00
|
|
|
// If we see some object files with .note.GNU-stack sections, and
|
|
|
|
// some objects files without them, this returns whether we should
|
|
|
|
// consider the object files without them to imply that the stack
|
|
|
|
// should be executable.
|
|
|
|
bool
|
|
|
|
is_default_stack_executable() const
|
|
|
|
{ return this->pti_->is_default_stack_executable; }
|
|
|
|
|
2008-04-09 08:48:13 +08:00
|
|
|
// Return a character which may appear as a prefix for a wrap
|
|
|
|
// symbol. If this character appears, we strip it when checking for
|
|
|
|
// wrapping and add it back when forming the final symbol name.
|
|
|
|
// This should be '\0' if not special prefix is required, which is
|
|
|
|
// the normal case.
|
|
|
|
char
|
|
|
|
wrap_char() const
|
|
|
|
{ return this->pti_->wrap_char; }
|
|
|
|
|
2009-06-22 14:51:53 +08:00
|
|
|
// Return the special section index which indicates a small common
|
|
|
|
// symbol. This will return SHN_UNDEF if there are no small common
|
|
|
|
// symbols.
|
|
|
|
elfcpp::Elf_Half
|
|
|
|
small_common_shndx() const
|
|
|
|
{ return this->pti_->small_common_shndx; }
|
|
|
|
|
|
|
|
// Return values to add to the section flags for the section holding
|
|
|
|
// small common symbols.
|
|
|
|
elfcpp::Elf_Xword
|
|
|
|
small_common_section_flags() const
|
|
|
|
{
|
|
|
|
gold_assert(this->pti_->small_common_shndx != elfcpp::SHN_UNDEF);
|
|
|
|
return this->pti_->small_common_section_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the special section index which indicates a large common
|
|
|
|
// symbol. This will return SHN_UNDEF if there are no large common
|
|
|
|
// symbols.
|
|
|
|
elfcpp::Elf_Half
|
|
|
|
large_common_shndx() const
|
|
|
|
{ return this->pti_->large_common_shndx; }
|
|
|
|
|
|
|
|
// Return values to add to the section flags for the section holding
|
|
|
|
// large common symbols.
|
|
|
|
elfcpp::Elf_Xword
|
|
|
|
large_common_section_flags() const
|
|
|
|
{
|
|
|
|
gold_assert(this->pti_->large_common_shndx != elfcpp::SHN_UNDEF);
|
|
|
|
return this->pti_->large_common_section_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This hook is called when an output section is created.
|
|
|
|
void
|
|
|
|
new_output_section(Output_section* os) const
|
|
|
|
{ this->do_new_output_section(os); }
|
|
|
|
|
2006-12-01 07:52:50 +08:00
|
|
|
// This is called to tell the target to complete any sections it is
|
|
|
|
// handling. After this all sections must have their final size.
|
|
|
|
void
|
2009-12-04 07:13:55 +08:00
|
|
|
finalize_sections(Layout* layout, const Input_objects* input_objects,
|
|
|
|
Symbol_table* symtab)
|
|
|
|
{ return this->do_finalize_sections(layout, input_objects, symtab); }
|
2006-12-01 07:52:50 +08:00
|
|
|
|
2007-09-23 13:31:48 +08:00
|
|
|
// Return the value to use for a global symbol which needs a special
|
|
|
|
// value in the dynamic symbol table. This will only be called if
|
|
|
|
// the backend first calls symbol->set_needs_dynsym_value().
|
|
|
|
uint64_t
|
|
|
|
dynsym_value(const Symbol* sym) const
|
|
|
|
{ return this->do_dynsym_value(sym); }
|
|
|
|
|
2007-09-21 13:31:19 +08:00
|
|
|
// Return a string to use to fill out a code section. This is
|
|
|
|
// basically one or more NOPS which must fill out the specified
|
|
|
|
// length in bytes.
|
|
|
|
std::string
|
2008-02-28 08:18:24 +08:00
|
|
|
code_fill(section_size_type length) const
|
2007-09-21 13:31:19 +08:00
|
|
|
{ return this->do_code_fill(length); }
|
|
|
|
|
2007-11-15 00:53:25 +08:00
|
|
|
// Return whether SYM is known to be defined by the ABI. This is
|
|
|
|
// used to avoid inappropriate warnings about undefined symbols.
|
|
|
|
bool
|
2008-09-17 01:23:37 +08:00
|
|
|
is_defined_by_abi(const Symbol* sym) const
|
2007-11-15 00:53:25 +08:00
|
|
|
{ return this->do_is_defined_by_abi(sym); }
|
|
|
|
|
2009-03-24 08:31:29 +08:00
|
|
|
// Adjust the output file header before it is written out. VIEW
|
|
|
|
// points to the header in external form. LEN is the length.
|
|
|
|
void
|
|
|
|
adjust_elf_header(unsigned char* view, int len) const
|
|
|
|
{ return this->do_adjust_elf_header(view, len); }
|
|
|
|
|
2009-06-06 05:32:57 +08:00
|
|
|
// Return whether NAME is a local label name. This is used to implement the
|
|
|
|
// --discard-locals options.
|
|
|
|
bool
|
|
|
|
is_local_label_name(const char* name) const
|
|
|
|
{ return this->do_is_local_label_name(name); }
|
|
|
|
|
2010-01-09 03:33:18 +08:00
|
|
|
// Get the symbol index to use for a target specific reloc.
|
|
|
|
unsigned int
|
|
|
|
reloc_symbol_index(void* arg, unsigned int type) const
|
|
|
|
{ return this->do_reloc_symbol_index(arg, type); }
|
|
|
|
|
|
|
|
// Get the addend to use for a target specific reloc.
|
|
|
|
uint64_t
|
|
|
|
reloc_addend(void* arg, unsigned int type, uint64_t addend) const
|
|
|
|
{ return this->do_reloc_addend(arg, type, addend); }
|
|
|
|
|
2010-08-20 06:50:16 +08:00
|
|
|
// Return the PLT section to use for a global symbol. This is used
|
|
|
|
// for STT_GNU_IFUNC symbols.
|
|
|
|
Output_data*
|
|
|
|
plt_section_for_global(const Symbol* sym) const
|
|
|
|
{ return this->do_plt_section_for_global(sym); }
|
|
|
|
|
|
|
|
// Return the PLT section to use for a local symbol. This is used
|
|
|
|
// for STT_GNU_IFUNC symbols.
|
|
|
|
Output_data*
|
|
|
|
plt_section_for_local(const Relobj* object, unsigned int symndx) const
|
|
|
|
{ return this->do_plt_section_for_local(object, symndx); }
|
|
|
|
|
2010-03-11 09:10:53 +08:00
|
|
|
// Return true if a reference to SYM from a reloc of type R_TYPE
|
|
|
|
// means that the current function may call an object compiled
|
|
|
|
// without -fsplit-stack. SYM is known to be defined in an object
|
|
|
|
// compiled without -fsplit-stack.
|
|
|
|
bool
|
|
|
|
is_call_to_non_split(const Symbol* sym, unsigned int r_type) const
|
|
|
|
{ return this->do_is_call_to_non_split(sym, r_type); }
|
|
|
|
|
2009-10-07 06:58:27 +08:00
|
|
|
// A function starts at OFFSET in section SHNDX in OBJECT. That
|
|
|
|
// function was compiled with -fsplit-stack, but it refers to a
|
|
|
|
// function which was compiled without -fsplit-stack. VIEW is a
|
|
|
|
// modifiable view of the section; VIEW_SIZE is the size of the
|
|
|
|
// view. The target has to adjust the function so that it allocates
|
|
|
|
// enough stack.
|
|
|
|
void
|
|
|
|
calls_non_split(Relobj* object, unsigned int shndx,
|
|
|
|
section_offset_type fnoffset, section_size_type fnsize,
|
|
|
|
unsigned char* view, section_size_type view_size,
|
|
|
|
std::string* from, std::string* to) const
|
|
|
|
{
|
|
|
|
this->do_calls_non_split(object, shndx, fnoffset, fnsize, view, view_size,
|
|
|
|
from, to);
|
|
|
|
}
|
|
|
|
|
2009-08-19 07:49:29 +08:00
|
|
|
// Make an ELF object.
|
|
|
|
template<int size, bool big_endian>
|
|
|
|
Object*
|
|
|
|
make_elf_object(const std::string& name, Input_file* input_file,
|
|
|
|
off_t offset, const elfcpp::Ehdr<size, big_endian>& ehdr)
|
|
|
|
{ return this->do_make_elf_object(name, input_file, offset, ehdr); }
|
|
|
|
|
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 07:18:19 +08:00
|
|
|
// Make an output section.
|
|
|
|
Output_section*
|
|
|
|
make_output_section(const char* name, elfcpp::Elf_Word type,
|
|
|
|
elfcpp::Elf_Xword flags)
|
|
|
|
{ return this->do_make_output_section(name, type, flags); }
|
|
|
|
|
2009-09-17 Doug Kwan <dougkwan@google.com>
* debug.h (DEBUG_RELAXATION): New constant.
(DEBUG_ALL): Add DEBUG_RELAXATION.
(debug_string_to_enum): Add relaxation debug option.
* layout.cc
(Layout::Relaxation_debug_check::check_output_data_for_reset_values,
Layout::Relaxation_debug_check::read_sections,
Layout::Relaxation_debug_check::read_sections): New method definitions.
(Layout::Layout): Initialize data members
record_output_section_data_from_scrips_,
script_output_section_data_list_ and relaxation_debug_check_.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method definitions.
(Layout::finalize): Support relaxation. Move section layout code to
Layout::relaxation_loop_body.
(Layout::set_asection_address_from_script): Move code for orphan
section placement out.
(Layout::place_orphan_sections_in_script): New method definition.
* layout.h (Output_segment_headers, Output_file_header):
New forward class declarations.
(Layout::~Layout): Define.
(Layout::new_output_section_data_from_script): New method definition.
(Layout::place_orphan_sections_in_script): New method declaration.
(Layout::Segment_states): New type declaration.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method declarations.
(Layout::Output_section_data_list): New type declaration.
(Layout::Relaxation_debug_check): New class definition.
(Layout::record_output_section_data_from_script_,
Layout::script_output_section_data_list_, Layout::segment_states_,
Layout::relaxation_debug_check_): New data members.
* output.cc: (Output_section_headers::do_size): New method definition.
(Output_section_headers::Output_section_headers): Move size
computation to Output_section_headers::do_size.
(Output_segment_headers::do_size): New method definition.
(Output_file_header::Output_file_header): Move size computation to
Output_file_header::do_size and call it.
(Output_file_header::do_size): New method definition.
(Output_data_group::Output_data_group): Adjust call to
Output_section_data.
(Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
(Output_symtab_xindex::do_write): Add array bound check.
(Output_section::Input_section::print_to_mapfile): Handle
RELAXED_INPUT_SECTION_CODE.
(Output_section::Output_section): Initialize data member checkpoint_.
(Output_section::~Output_section): Delete checkpoint object pointed
by checkpoint_.
(Output_section::add_input_section): Always add an Input_section if
relaxing.
(Output_section::add_merge_input_section): Add assert.
(Output_section::relax_input_section): New method definition.
(Output_section::set_final_data_size): Set load address to zero for
an unallocated section.
(Output_section::do_address_and_file_offset_have_reset_values):
New method definition.
(Output_section::Input_section_sort_enty::Input_section_sort_enty):
Handle relaxed input section.
(Output_section::sort_attached_input_sections): Checkpoint input
section list lazily.
(Output_section::get_input_sections): Change type of input_sections to
list of Simple_input_section pointers. Checkpoint input section list
lazily. Also handle relaxed input sections.
(Output_section::add_input_section_for_script): Take a reference to
a Simple_input_section object instead of Relobj pointer and section
index as parameter. Handle relaxed input sections.
(Output_section::save_states, Output_section::restore_states): New
method definitions.
* output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
(Output_data::is_data_size_fixed): New method definition.
(Output_data::reset_addresss_and_file_offset): Do not reset data size
if it is fixed.
(Output_data::address_and_file_offset_have_reset_values): New method
definition.
(Output_data::do_address_and_file_offset_have_reset_values): New method
definition.
(Output_data::set_data_size): Check that data size is not fixed.
(Output_data::fix_data_size): New method definition.
(Output_data::is_data_size_fixed_): New data member.
(Output_section_headers::set_final_data_size): New method definition.
(Output_section_headers::do_size): New method declaration.
(Output_segment_headers::set_final_data_size): New method definition.
(Output_segment_headers::do_size): New method declaration.
(Output_file_header::set_final_data_size)::New method definition.
(Output_file_header::do_size)::New method declaration.
(Output_section_data::Output_section_data): Add new parameter
is_data_size_fixed and use it to fix data size.
(Output_data_const::Output_data_const): Adjust call to base class
constructor and fix data size.
(Output_data_const_buffer::Output_data_const_buffer): Adjust call to
base class constructor and fix data size.
(Output_data_fixed_space::Output_data_fixed_space): Adjust call to
base class constructor and fix data size.
(Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
class constructor and fix data size.
(Output_data_group::set_final_data_size): New method definition.
(Output_data_dynamic::Dynamic_entry::tag): New method definition.
(Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
class constructor and fix data size.
(Output_relaxed_input_section): New class definition.
(Output_section::Simple_input_section): New class definition.
(Output_section::get_input_sections): Adjust parameter list.
(Output_section::add_input_section_for_script): Same.
(Output_section::save_states, Output_section::restore_states,
Output_section::do_address_and_file_offset_have_reset_values,
(Output_section::Input_section::Input_section): Handle
RELAXED_INPUT_SECTION_CODE. Add new overload for
Output_relaxed_input_section.
(Output_section::Input_section::is_input_section,
Output_section::Input_section::set_output_section): Handle relaxed
input section.
(Output_section::Input_section::is_relaxed_input_section,
Output_section::Input_section::output_section_data,
Output_section::Input_section::relaxed_input_section): New method
definitions.
(Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
value.
(Output_section::Input_section::u1_): Update comments.
(Output_section::Input_section::u2_): Add new union member poris.
(Output_section::Checkpoint_output_section): New classs definition.
(Output_section::relax_input_section): New method declaration.
(Output_section::checkpoint_): New data member.
(Output_segment): Update comments.
(Output_segment::Output_segment): Un-privatize copy constructor.
(Output_segment::operator=): Un-privatize.
* script-sections.cc (Output_section_element::Input_section_list):
Change element type to Output_section::Simple_input_section.
(Output_section_element_dot_assignment::set_section_addresses):
Register output section data for relaxation clean up.
(Output_data_exression::Output_data_expression): Adjust call to base
constructor to fix data size.
(Output_section_element_data::set_section_addresses): Register
Output_data_expression object for relaxation clean up.
(struct Input_section_info): Replace Relobj pointer and section index
pair with Output_section::Simple_input_section and Convert struct to a
class.
(Input_section_sorter::operator()): Adjust access to
Input_section_info data member to use accessors.
(Output_section_element_input::set_section_addresses): Use layout
parameter. Adjust code to use Output_section::Simple_input_section
and Input_secction_info classes. Register filler for relaxation
clean up.
(Orphan_output_section::set_section_addresses): Replace Relobj pointer
and section index pair with Output_section::Simple_input_section
class. Adjust code accordingly.
(Phdrs_element::release_segment): New method definition.
(Script_sections::attach_sections_using_phdrs_clause): Do not modify
segment list.
(Script_sections::release_segments): New method definition.
* gold/script-sections.h (Script_sections::release_segments): New
method declaration.
* gold/target.h (Target::may_relax, Target::relax,
Target::do_may_relax, Target::do_relax): New method definitions.
2009-09-18 09:10:38 +08:00
|
|
|
// Return true if target wants to perform relaxation.
|
|
|
|
bool
|
|
|
|
may_relax() const
|
|
|
|
{
|
|
|
|
// Run the dummy relaxation pass twice if relaxation debugging is enabled.
|
|
|
|
if (is_debugging_enabled(DEBUG_RELAXATION))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return this->do_may_relax();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Perform a relaxation pass. Return true if layout may be changed.
|
|
|
|
bool
|
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 07:18:19 +08:00
|
|
|
relax(int pass, const Input_objects* input_objects, Symbol_table* symtab,
|
2010-11-09 15:56:10 +08:00
|
|
|
Layout* layout, const Task* task)
|
2009-09-17 Doug Kwan <dougkwan@google.com>
* debug.h (DEBUG_RELAXATION): New constant.
(DEBUG_ALL): Add DEBUG_RELAXATION.
(debug_string_to_enum): Add relaxation debug option.
* layout.cc
(Layout::Relaxation_debug_check::check_output_data_for_reset_values,
Layout::Relaxation_debug_check::read_sections,
Layout::Relaxation_debug_check::read_sections): New method definitions.
(Layout::Layout): Initialize data members
record_output_section_data_from_scrips_,
script_output_section_data_list_ and relaxation_debug_check_.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method definitions.
(Layout::finalize): Support relaxation. Move section layout code to
Layout::relaxation_loop_body.
(Layout::set_asection_address_from_script): Move code for orphan
section placement out.
(Layout::place_orphan_sections_in_script): New method definition.
* layout.h (Output_segment_headers, Output_file_header):
New forward class declarations.
(Layout::~Layout): Define.
(Layout::new_output_section_data_from_script): New method definition.
(Layout::place_orphan_sections_in_script): New method declaration.
(Layout::Segment_states): New type declaration.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method declarations.
(Layout::Output_section_data_list): New type declaration.
(Layout::Relaxation_debug_check): New class definition.
(Layout::record_output_section_data_from_script_,
Layout::script_output_section_data_list_, Layout::segment_states_,
Layout::relaxation_debug_check_): New data members.
* output.cc: (Output_section_headers::do_size): New method definition.
(Output_section_headers::Output_section_headers): Move size
computation to Output_section_headers::do_size.
(Output_segment_headers::do_size): New method definition.
(Output_file_header::Output_file_header): Move size computation to
Output_file_header::do_size and call it.
(Output_file_header::do_size): New method definition.
(Output_data_group::Output_data_group): Adjust call to
Output_section_data.
(Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
(Output_symtab_xindex::do_write): Add array bound check.
(Output_section::Input_section::print_to_mapfile): Handle
RELAXED_INPUT_SECTION_CODE.
(Output_section::Output_section): Initialize data member checkpoint_.
(Output_section::~Output_section): Delete checkpoint object pointed
by checkpoint_.
(Output_section::add_input_section): Always add an Input_section if
relaxing.
(Output_section::add_merge_input_section): Add assert.
(Output_section::relax_input_section): New method definition.
(Output_section::set_final_data_size): Set load address to zero for
an unallocated section.
(Output_section::do_address_and_file_offset_have_reset_values):
New method definition.
(Output_section::Input_section_sort_enty::Input_section_sort_enty):
Handle relaxed input section.
(Output_section::sort_attached_input_sections): Checkpoint input
section list lazily.
(Output_section::get_input_sections): Change type of input_sections to
list of Simple_input_section pointers. Checkpoint input section list
lazily. Also handle relaxed input sections.
(Output_section::add_input_section_for_script): Take a reference to
a Simple_input_section object instead of Relobj pointer and section
index as parameter. Handle relaxed input sections.
(Output_section::save_states, Output_section::restore_states): New
method definitions.
* output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
(Output_data::is_data_size_fixed): New method definition.
(Output_data::reset_addresss_and_file_offset): Do not reset data size
if it is fixed.
(Output_data::address_and_file_offset_have_reset_values): New method
definition.
(Output_data::do_address_and_file_offset_have_reset_values): New method
definition.
(Output_data::set_data_size): Check that data size is not fixed.
(Output_data::fix_data_size): New method definition.
(Output_data::is_data_size_fixed_): New data member.
(Output_section_headers::set_final_data_size): New method definition.
(Output_section_headers::do_size): New method declaration.
(Output_segment_headers::set_final_data_size): New method definition.
(Output_segment_headers::do_size): New method declaration.
(Output_file_header::set_final_data_size)::New method definition.
(Output_file_header::do_size)::New method declaration.
(Output_section_data::Output_section_data): Add new parameter
is_data_size_fixed and use it to fix data size.
(Output_data_const::Output_data_const): Adjust call to base class
constructor and fix data size.
(Output_data_const_buffer::Output_data_const_buffer): Adjust call to
base class constructor and fix data size.
(Output_data_fixed_space::Output_data_fixed_space): Adjust call to
base class constructor and fix data size.
(Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
class constructor and fix data size.
(Output_data_group::set_final_data_size): New method definition.
(Output_data_dynamic::Dynamic_entry::tag): New method definition.
(Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
class constructor and fix data size.
(Output_relaxed_input_section): New class definition.
(Output_section::Simple_input_section): New class definition.
(Output_section::get_input_sections): Adjust parameter list.
(Output_section::add_input_section_for_script): Same.
(Output_section::save_states, Output_section::restore_states,
Output_section::do_address_and_file_offset_have_reset_values,
(Output_section::Input_section::Input_section): Handle
RELAXED_INPUT_SECTION_CODE. Add new overload for
Output_relaxed_input_section.
(Output_section::Input_section::is_input_section,
Output_section::Input_section::set_output_section): Handle relaxed
input section.
(Output_section::Input_section::is_relaxed_input_section,
Output_section::Input_section::output_section_data,
Output_section::Input_section::relaxed_input_section): New method
definitions.
(Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
value.
(Output_section::Input_section::u1_): Update comments.
(Output_section::Input_section::u2_): Add new union member poris.
(Output_section::Checkpoint_output_section): New classs definition.
(Output_section::relax_input_section): New method declaration.
(Output_section::checkpoint_): New data member.
(Output_segment): Update comments.
(Output_segment::Output_segment): Un-privatize copy constructor.
(Output_segment::operator=): Un-privatize.
* script-sections.cc (Output_section_element::Input_section_list):
Change element type to Output_section::Simple_input_section.
(Output_section_element_dot_assignment::set_section_addresses):
Register output section data for relaxation clean up.
(Output_data_exression::Output_data_expression): Adjust call to base
constructor to fix data size.
(Output_section_element_data::set_section_addresses): Register
Output_data_expression object for relaxation clean up.
(struct Input_section_info): Replace Relobj pointer and section index
pair with Output_section::Simple_input_section and Convert struct to a
class.
(Input_section_sorter::operator()): Adjust access to
Input_section_info data member to use accessors.
(Output_section_element_input::set_section_addresses): Use layout
parameter. Adjust code to use Output_section::Simple_input_section
and Input_secction_info classes. Register filler for relaxation
clean up.
(Orphan_output_section::set_section_addresses): Replace Relobj pointer
and section index pair with Output_section::Simple_input_section
class. Adjust code accordingly.
(Phdrs_element::release_segment): New method definition.
(Script_sections::attach_sections_using_phdrs_clause): Do not modify
segment list.
(Script_sections::release_segments): New method definition.
* gold/script-sections.h (Script_sections::release_segments): New
method declaration.
* gold/target.h (Target::may_relax, Target::relax,
Target::do_may_relax, Target::do_relax): New method definitions.
2009-09-18 09:10:38 +08:00
|
|
|
{
|
|
|
|
// Run the dummy relaxation pass twice if relaxation debugging is enabled.
|
|
|
|
if (is_debugging_enabled(DEBUG_RELAXATION))
|
|
|
|
return pass < 2;
|
|
|
|
|
2010-11-09 15:56:10 +08:00
|
|
|
return this->do_relax(pass, input_objects, symtab, layout, task);
|
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 07:18:19 +08:00
|
|
|
}
|
2009-09-17 Doug Kwan <dougkwan@google.com>
* debug.h (DEBUG_RELAXATION): New constant.
(DEBUG_ALL): Add DEBUG_RELAXATION.
(debug_string_to_enum): Add relaxation debug option.
* layout.cc
(Layout::Relaxation_debug_check::check_output_data_for_reset_values,
Layout::Relaxation_debug_check::read_sections,
Layout::Relaxation_debug_check::read_sections): New method definitions.
(Layout::Layout): Initialize data members
record_output_section_data_from_scrips_,
script_output_section_data_list_ and relaxation_debug_check_.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method definitions.
(Layout::finalize): Support relaxation. Move section layout code to
Layout::relaxation_loop_body.
(Layout::set_asection_address_from_script): Move code for orphan
section placement out.
(Layout::place_orphan_sections_in_script): New method definition.
* layout.h (Output_segment_headers, Output_file_header):
New forward class declarations.
(Layout::~Layout): Define.
(Layout::new_output_section_data_from_script): New method definition.
(Layout::place_orphan_sections_in_script): New method declaration.
(Layout::Segment_states): New type declaration.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method declarations.
(Layout::Output_section_data_list): New type declaration.
(Layout::Relaxation_debug_check): New class definition.
(Layout::record_output_section_data_from_script_,
Layout::script_output_section_data_list_, Layout::segment_states_,
Layout::relaxation_debug_check_): New data members.
* output.cc: (Output_section_headers::do_size): New method definition.
(Output_section_headers::Output_section_headers): Move size
computation to Output_section_headers::do_size.
(Output_segment_headers::do_size): New method definition.
(Output_file_header::Output_file_header): Move size computation to
Output_file_header::do_size and call it.
(Output_file_header::do_size): New method definition.
(Output_data_group::Output_data_group): Adjust call to
Output_section_data.
(Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
(Output_symtab_xindex::do_write): Add array bound check.
(Output_section::Input_section::print_to_mapfile): Handle
RELAXED_INPUT_SECTION_CODE.
(Output_section::Output_section): Initialize data member checkpoint_.
(Output_section::~Output_section): Delete checkpoint object pointed
by checkpoint_.
(Output_section::add_input_section): Always add an Input_section if
relaxing.
(Output_section::add_merge_input_section): Add assert.
(Output_section::relax_input_section): New method definition.
(Output_section::set_final_data_size): Set load address to zero for
an unallocated section.
(Output_section::do_address_and_file_offset_have_reset_values):
New method definition.
(Output_section::Input_section_sort_enty::Input_section_sort_enty):
Handle relaxed input section.
(Output_section::sort_attached_input_sections): Checkpoint input
section list lazily.
(Output_section::get_input_sections): Change type of input_sections to
list of Simple_input_section pointers. Checkpoint input section list
lazily. Also handle relaxed input sections.
(Output_section::add_input_section_for_script): Take a reference to
a Simple_input_section object instead of Relobj pointer and section
index as parameter. Handle relaxed input sections.
(Output_section::save_states, Output_section::restore_states): New
method definitions.
* output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
(Output_data::is_data_size_fixed): New method definition.
(Output_data::reset_addresss_and_file_offset): Do not reset data size
if it is fixed.
(Output_data::address_and_file_offset_have_reset_values): New method
definition.
(Output_data::do_address_and_file_offset_have_reset_values): New method
definition.
(Output_data::set_data_size): Check that data size is not fixed.
(Output_data::fix_data_size): New method definition.
(Output_data::is_data_size_fixed_): New data member.
(Output_section_headers::set_final_data_size): New method definition.
(Output_section_headers::do_size): New method declaration.
(Output_segment_headers::set_final_data_size): New method definition.
(Output_segment_headers::do_size): New method declaration.
(Output_file_header::set_final_data_size)::New method definition.
(Output_file_header::do_size)::New method declaration.
(Output_section_data::Output_section_data): Add new parameter
is_data_size_fixed and use it to fix data size.
(Output_data_const::Output_data_const): Adjust call to base class
constructor and fix data size.
(Output_data_const_buffer::Output_data_const_buffer): Adjust call to
base class constructor and fix data size.
(Output_data_fixed_space::Output_data_fixed_space): Adjust call to
base class constructor and fix data size.
(Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
class constructor and fix data size.
(Output_data_group::set_final_data_size): New method definition.
(Output_data_dynamic::Dynamic_entry::tag): New method definition.
(Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
class constructor and fix data size.
(Output_relaxed_input_section): New class definition.
(Output_section::Simple_input_section): New class definition.
(Output_section::get_input_sections): Adjust parameter list.
(Output_section::add_input_section_for_script): Same.
(Output_section::save_states, Output_section::restore_states,
Output_section::do_address_and_file_offset_have_reset_values,
(Output_section::Input_section::Input_section): Handle
RELAXED_INPUT_SECTION_CODE. Add new overload for
Output_relaxed_input_section.
(Output_section::Input_section::is_input_section,
Output_section::Input_section::set_output_section): Handle relaxed
input section.
(Output_section::Input_section::is_relaxed_input_section,
Output_section::Input_section::output_section_data,
Output_section::Input_section::relaxed_input_section): New method
definitions.
(Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
value.
(Output_section::Input_section::u1_): Update comments.
(Output_section::Input_section::u2_): Add new union member poris.
(Output_section::Checkpoint_output_section): New classs definition.
(Output_section::relax_input_section): New method declaration.
(Output_section::checkpoint_): New data member.
(Output_segment): Update comments.
(Output_segment::Output_segment): Un-privatize copy constructor.
(Output_segment::operator=): Un-privatize.
* script-sections.cc (Output_section_element::Input_section_list):
Change element type to Output_section::Simple_input_section.
(Output_section_element_dot_assignment::set_section_addresses):
Register output section data for relaxation clean up.
(Output_data_exression::Output_data_expression): Adjust call to base
constructor to fix data size.
(Output_section_element_data::set_section_addresses): Register
Output_data_expression object for relaxation clean up.
(struct Input_section_info): Replace Relobj pointer and section index
pair with Output_section::Simple_input_section and Convert struct to a
class.
(Input_section_sorter::operator()): Adjust access to
Input_section_info data member to use accessors.
(Output_section_element_input::set_section_addresses): Use layout
parameter. Adjust code to use Output_section::Simple_input_section
and Input_secction_info classes. Register filler for relaxation
clean up.
(Orphan_output_section::set_section_addresses): Replace Relobj pointer
and section index pair with Output_section::Simple_input_section
class. Adjust code accordingly.
(Phdrs_element::release_segment): New method definition.
(Script_sections::attach_sections_using_phdrs_clause): Do not modify
segment list.
(Script_sections::release_segments): New method definition.
* gold/script-sections.h (Script_sections::release_segments): New
method declaration.
* gold/target.h (Target::may_relax, Target::relax,
Target::do_may_relax, Target::do_relax): New method definitions.
2009-09-18 09:10:38 +08:00
|
|
|
|
2009-12-06 10:49:46 +08:00
|
|
|
// Return the target-specific name of attributes section. This is
|
|
|
|
// NULL if a target does not use attributes section or if it uses
|
|
|
|
// the default section name ".gnu.attributes".
|
|
|
|
const char*
|
|
|
|
attributes_section() const
|
|
|
|
{ return this->pti_->attributes_section; }
|
|
|
|
|
|
|
|
// Return the vendor name of vendor attributes.
|
|
|
|
const char*
|
|
|
|
attributes_vendor() const
|
|
|
|
{ return this->pti_->attributes_vendor; }
|
|
|
|
|
|
|
|
// Whether a section called NAME is an attribute section.
|
|
|
|
bool
|
|
|
|
is_attributes_section(const char* name) const
|
|
|
|
{
|
|
|
|
return ((this->pti_->attributes_section != NULL
|
|
|
|
&& strcmp(name, this->pti_->attributes_section) == 0)
|
|
|
|
|| strcmp(name, ".gnu.attributes") == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return a bit mask of argument types for attribute with TAG.
|
|
|
|
int
|
|
|
|
attribute_arg_type(int tag) const
|
|
|
|
{ return this->do_attribute_arg_type(tag); }
|
|
|
|
|
|
|
|
// Return the attribute tag of the position NUM in the list of fixed
|
|
|
|
// attributes. Normally there is no reordering and
|
|
|
|
// attributes_order(NUM) == NUM.
|
|
|
|
int
|
|
|
|
attributes_order(int num) const
|
|
|
|
{ return this->do_attributes_order(num); }
|
|
|
|
|
2010-02-03 13:36:55 +08:00
|
|
|
// When a target is selected as the default target, we call this method,
|
|
|
|
// which may be used for expensive, target-specific initialization.
|
|
|
|
void
|
|
|
|
select_as_default_target()
|
|
|
|
{ this->do_select_as_default_target(); }
|
|
|
|
|
2006-08-19 06:29:20 +08:00
|
|
|
protected:
|
2006-09-28 06:53:42 +08:00
|
|
|
// This struct holds the constant information for a child class. We
|
|
|
|
// use a struct to avoid the overhead of virtual function calls for
|
|
|
|
// simple information.
|
|
|
|
struct Target_info
|
|
|
|
{
|
|
|
|
// Address size (32 or 64).
|
|
|
|
int size;
|
|
|
|
// Whether the target is big endian.
|
|
|
|
bool is_big_endian;
|
2006-09-30 03:58:17 +08:00
|
|
|
// The code to store in the e_machine field of the ELF header.
|
|
|
|
elfcpp::EM machine_code;
|
2006-09-28 06:53:42 +08:00
|
|
|
// Whether this target has a specific make_symbol function.
|
|
|
|
bool has_make_symbol;
|
|
|
|
// Whether this target has a specific resolve function.
|
|
|
|
bool has_resolve;
|
2007-09-21 13:31:19 +08:00
|
|
|
// Whether this target has a specific code fill function.
|
|
|
|
bool has_code_fill;
|
2007-10-23 13:05:48 +08:00
|
|
|
// Whether an object file with no .note.GNU-stack sections implies
|
|
|
|
// that the stack should be executable.
|
|
|
|
bool is_default_stack_executable;
|
2008-04-09 08:48:13 +08:00
|
|
|
// Prefix character to strip when checking for wrapping.
|
|
|
|
char wrap_char;
|
2006-11-15 03:21:05 +08:00
|
|
|
// The default dynamic linker name.
|
|
|
|
const char* dynamic_linker;
|
2006-09-28 06:53:42 +08:00
|
|
|
// The default text segment address.
|
2007-10-17 06:38:36 +08:00
|
|
|
uint64_t default_text_segment_address;
|
2006-09-28 06:53:42 +08:00
|
|
|
// The ABI specified page size.
|
|
|
|
uint64_t abi_pagesize;
|
|
|
|
// The common page size used by actual implementations.
|
|
|
|
uint64_t common_pagesize;
|
2009-06-22 14:51:53 +08:00
|
|
|
// The special section index for small common symbols; SHN_UNDEF
|
|
|
|
// if none.
|
|
|
|
elfcpp::Elf_Half small_common_shndx;
|
|
|
|
// The special section index for large common symbols; SHN_UNDEF
|
|
|
|
// if none.
|
|
|
|
elfcpp::Elf_Half large_common_shndx;
|
|
|
|
// Section flags for small common section.
|
|
|
|
elfcpp::Elf_Xword small_common_section_flags;
|
|
|
|
// Section flags for large common section.
|
|
|
|
elfcpp::Elf_Xword large_common_section_flags;
|
2009-12-06 10:49:46 +08:00
|
|
|
// Name of attributes section if it is not ".gnu.attributes".
|
|
|
|
const char* attributes_section;
|
|
|
|
// Vendor name of vendor attributes.
|
|
|
|
const char* attributes_vendor;
|
2006-09-28 06:53:42 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
Target(const Target_info* pti)
|
2009-10-30 Doug Kwan <dougkwan@google.com>
elfcpp/ChangeLog:
* arm.h (EF_ARM_BE8, EF_ARM_EABIMASK, EF_ARM_EABI_UNKNOWN,
EF_ARM_EABI_VER1, EF_ARM_EABI_VER2, EF_ARM_EABI_VER3,
EF_ARM_EABI_VER4, EF_ARM_EABI_VER5): New enums for processor-specific
flags.
(arm_eabi_version): New inline function.
* elfcpp.h: Add a comment about DT_ENCODING.
gold/ChangeLog:
* arm.cc (Arm_relobj::processor_specific_flags): New method
definition.
(Arm_relobj::do_read_symbols): New method declaration.
(Arm_relobj::processor_specific_flags_): New data member declaration.
(Arm_dynobj): New class definition.
(Target_arm::do_finalize_sections): Add input_objects parameter.
(Target_arm::do_adjust_elf_header): New method declaration.
(Target_arm::are_eabi_versions_compatible,
(Target_arm::merge_processor_specific_flags): New method declaration.
(Target_arm::do_make_elf_object): New overloaded method definitions
and declaration.
(Arm_relobj::do_read_symbols): New method definition.
(Arm_dynobj::do_read_symbols): Ditto.
(Target_arm::do_finalize_sections): Add input_objects parameters.
Merge processor-specific flags from all input objects.
(Target_arm::are_eabi_versions_compatible,
Target_arm::merge_processor_specific_flags,
Target_arm::do_adjust_elf_header, Target_arm::do_make_elf_object):
New method definitions.
* i386.cc (Target_i386::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
* layout.cc (Layout::finalize): Pass input objects to target's.
finalize_sections function.
* output.cc (Output_file_header::do_sized_write): Set ELF file
header's processor-specific flags.
* powerpc.cc (Target_powerpc::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
* sparc.cc (Target_sparc::do_finalize_sections): Same.
* target.h (Input_objects): New forward class declaration.
(Target::processor_specific_flags,
Target::are_processor_specific_flags_sect): New method definitions.
(Target::finalize_sections): Add input_objects parameter.
(Target::Target): Initialize processor_specific_flags_ and
are_processor_specific_flags_set_.
(Target::do_finalize_sections): Add unnamed Input_objects pointer type
parameter.
(Target::set_processor_specific_flags): New method definition.
(Target::processor_specific_flags_,
Target::are_processor_specific_flags_set_): New data member
declarations.
* x86_64.cc (Target_x86_64::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
2009-10-31 02:49:59 +08:00
|
|
|
: pti_(pti), processor_specific_flags_(0),
|
|
|
|
are_processor_specific_flags_set_(false)
|
2006-08-19 06:29:20 +08:00
|
|
|
{ }
|
|
|
|
|
2009-06-22 14:51:53 +08:00
|
|
|
// Virtual function which may be implemented by the child class.
|
|
|
|
virtual void
|
|
|
|
do_new_output_section(Output_section*) const
|
|
|
|
{ }
|
|
|
|
|
2006-12-01 07:52:50 +08:00
|
|
|
// Virtual function which may be implemented by the child class.
|
|
|
|
virtual void
|
2009-12-04 07:13:55 +08:00
|
|
|
do_finalize_sections(Layout*, const Input_objects*, Symbol_table*)
|
2006-12-01 07:52:50 +08:00
|
|
|
{ }
|
|
|
|
|
2007-09-23 13:31:48 +08:00
|
|
|
// Virtual function which may be implemented by the child class.
|
|
|
|
virtual uint64_t
|
|
|
|
do_dynsym_value(const Symbol*) const
|
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
2007-09-21 13:31:19 +08:00
|
|
|
// Virtual function which must be implemented by the child class if
|
|
|
|
// needed.
|
|
|
|
virtual std::string
|
2008-02-28 08:18:24 +08:00
|
|
|
do_code_fill(section_size_type) const
|
2007-09-21 13:31:19 +08:00
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
2007-11-15 00:53:25 +08:00
|
|
|
// Virtual function which may be implemented by the child class.
|
|
|
|
virtual bool
|
2008-09-17 01:23:37 +08:00
|
|
|
do_is_defined_by_abi(const Symbol*) const
|
2007-11-15 00:53:25 +08:00
|
|
|
{ return false; }
|
|
|
|
|
2009-03-24 08:31:29 +08:00
|
|
|
// Adjust the output file header before it is written out. VIEW
|
|
|
|
// points to the header in external form. LEN is the length, and
|
|
|
|
// will be one of the values of elfcpp::Elf_sizes<size>::ehdr_size.
|
|
|
|
// By default, we do nothing.
|
|
|
|
virtual void
|
|
|
|
do_adjust_elf_header(unsigned char*, int) const
|
|
|
|
{ }
|
|
|
|
|
2010-12-15 03:03:30 +08:00
|
|
|
// Virtual function which may be overridden by the child class.
|
2009-06-06 05:32:57 +08:00
|
|
|
virtual bool
|
|
|
|
do_is_local_label_name(const char*) const;
|
|
|
|
|
2010-01-09 03:33:18 +08:00
|
|
|
// Virtual function that must be overridden by a target which uses
|
|
|
|
// target specific relocations.
|
|
|
|
virtual unsigned int
|
|
|
|
do_reloc_symbol_index(void*, unsigned int) const
|
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
2010-12-15 03:03:30 +08:00
|
|
|
// Virtual function that must be overridden by a target which uses
|
2010-01-09 03:33:18 +08:00
|
|
|
// target specific relocations.
|
|
|
|
virtual uint64_t
|
|
|
|
do_reloc_addend(void*, unsigned int, uint64_t) const
|
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
2010-08-20 06:50:16 +08:00
|
|
|
// Virtual functions that must be overridden by a target that uses
|
|
|
|
// STT_GNU_IFUNC symbols.
|
|
|
|
virtual Output_data*
|
|
|
|
do_plt_section_for_global(const Symbol*) const
|
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
|
|
|
virtual Output_data*
|
|
|
|
do_plt_section_for_local(const Relobj*, unsigned int) const
|
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
2010-03-11 09:10:53 +08:00
|
|
|
// Virtual function which may be overridden by the child class. The
|
|
|
|
// default implementation is that any function not defined by the
|
|
|
|
// ABI is a call to a non-split function.
|
|
|
|
virtual bool
|
|
|
|
do_is_call_to_non_split(const Symbol* sym, unsigned int) const;
|
|
|
|
|
2009-10-07 06:58:27 +08:00
|
|
|
// Virtual function which may be overridden by the child class.
|
|
|
|
virtual void
|
|
|
|
do_calls_non_split(Relobj* object, unsigned int, section_offset_type,
|
|
|
|
section_size_type, unsigned char*, section_size_type,
|
|
|
|
std::string*, std::string*) const;
|
|
|
|
|
2009-08-19 07:49:29 +08:00
|
|
|
// make_elf_object hooks. There are four versions of these for
|
2010-04-08 05:42:22 +08:00
|
|
|
// different address sizes and endianness.
|
2009-10-07 06:58:27 +08:00
|
|
|
|
2009-10-30 Doug Kwan <dougkwan@google.com>
elfcpp/ChangeLog:
* arm.h (EF_ARM_BE8, EF_ARM_EABIMASK, EF_ARM_EABI_UNKNOWN,
EF_ARM_EABI_VER1, EF_ARM_EABI_VER2, EF_ARM_EABI_VER3,
EF_ARM_EABI_VER4, EF_ARM_EABI_VER5): New enums for processor-specific
flags.
(arm_eabi_version): New inline function.
* elfcpp.h: Add a comment about DT_ENCODING.
gold/ChangeLog:
* arm.cc (Arm_relobj::processor_specific_flags): New method
definition.
(Arm_relobj::do_read_symbols): New method declaration.
(Arm_relobj::processor_specific_flags_): New data member declaration.
(Arm_dynobj): New class definition.
(Target_arm::do_finalize_sections): Add input_objects parameter.
(Target_arm::do_adjust_elf_header): New method declaration.
(Target_arm::are_eabi_versions_compatible,
(Target_arm::merge_processor_specific_flags): New method declaration.
(Target_arm::do_make_elf_object): New overloaded method definitions
and declaration.
(Arm_relobj::do_read_symbols): New method definition.
(Arm_dynobj::do_read_symbols): Ditto.
(Target_arm::do_finalize_sections): Add input_objects parameters.
Merge processor-specific flags from all input objects.
(Target_arm::are_eabi_versions_compatible,
Target_arm::merge_processor_specific_flags,
Target_arm::do_adjust_elf_header, Target_arm::do_make_elf_object):
New method definitions.
* i386.cc (Target_i386::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
* layout.cc (Layout::finalize): Pass input objects to target's.
finalize_sections function.
* output.cc (Output_file_header::do_sized_write): Set ELF file
header's processor-specific flags.
* powerpc.cc (Target_powerpc::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
* sparc.cc (Target_sparc::do_finalize_sections): Same.
* target.h (Input_objects): New forward class declaration.
(Target::processor_specific_flags,
Target::are_processor_specific_flags_sect): New method definitions.
(Target::finalize_sections): Add input_objects parameter.
(Target::Target): Initialize processor_specific_flags_ and
are_processor_specific_flags_set_.
(Target::do_finalize_sections): Add unnamed Input_objects pointer type
parameter.
(Target::set_processor_specific_flags): New method definition.
(Target::processor_specific_flags_,
Target::are_processor_specific_flags_set_): New data member
declarations.
* x86_64.cc (Target_x86_64::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
2009-10-31 02:49:59 +08:00
|
|
|
// Set processor specific flags.
|
|
|
|
void
|
|
|
|
set_processor_specific_flags(elfcpp::Elf_Word flags)
|
|
|
|
{
|
|
|
|
this->processor_specific_flags_ = flags;
|
|
|
|
this->are_processor_specific_flags_set_ = true;
|
|
|
|
}
|
|
|
|
|
2009-08-19 07:49:29 +08:00
|
|
|
#ifdef HAVE_TARGET_32_LITTLE
|
2010-12-15 03:03:30 +08:00
|
|
|
// Virtual functions which may be overridden by the child class.
|
2009-08-19 07:49:29 +08:00
|
|
|
virtual Object*
|
|
|
|
do_make_elf_object(const std::string&, Input_file*, off_t,
|
|
|
|
const elfcpp::Ehdr<32, false>&);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_TARGET_32_BIG
|
2010-12-15 03:03:30 +08:00
|
|
|
// Virtual functions which may be overridden by the child class.
|
2009-08-19 07:49:29 +08:00
|
|
|
virtual Object*
|
|
|
|
do_make_elf_object(const std::string&, Input_file*, off_t,
|
|
|
|
const elfcpp::Ehdr<32, true>&);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_TARGET_64_LITTLE
|
2010-12-15 03:03:30 +08:00
|
|
|
// Virtual functions which may be overridden by the child class.
|
2009-08-19 07:49:29 +08:00
|
|
|
virtual Object*
|
|
|
|
do_make_elf_object(const std::string&, Input_file*, off_t,
|
|
|
|
const elfcpp::Ehdr<64, false>& ehdr);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_TARGET_64_BIG
|
2010-12-15 03:03:30 +08:00
|
|
|
// Virtual functions which may be overridden by the child class.
|
2009-08-19 07:49:29 +08:00
|
|
|
virtual Object*
|
|
|
|
do_make_elf_object(const std::string& name, Input_file* input_file,
|
|
|
|
off_t offset, const elfcpp::Ehdr<64, true>& ehdr);
|
|
|
|
#endif
|
|
|
|
|
2010-12-15 03:03:30 +08:00
|
|
|
// Virtual functions which may be overridden by the child class.
|
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 07:18:19 +08:00
|
|
|
virtual Output_section*
|
|
|
|
do_make_output_section(const char* name, elfcpp::Elf_Word type,
|
|
|
|
elfcpp::Elf_Xword flags);
|
|
|
|
|
2010-12-15 03:03:30 +08:00
|
|
|
// Virtual function which may be overridden by the child class.
|
2009-09-17 Doug Kwan <dougkwan@google.com>
* debug.h (DEBUG_RELAXATION): New constant.
(DEBUG_ALL): Add DEBUG_RELAXATION.
(debug_string_to_enum): Add relaxation debug option.
* layout.cc
(Layout::Relaxation_debug_check::check_output_data_for_reset_values,
Layout::Relaxation_debug_check::read_sections,
Layout::Relaxation_debug_check::read_sections): New method definitions.
(Layout::Layout): Initialize data members
record_output_section_data_from_scrips_,
script_output_section_data_list_ and relaxation_debug_check_.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method definitions.
(Layout::finalize): Support relaxation. Move section layout code to
Layout::relaxation_loop_body.
(Layout::set_asection_address_from_script): Move code for orphan
section placement out.
(Layout::place_orphan_sections_in_script): New method definition.
* layout.h (Output_segment_headers, Output_file_header):
New forward class declarations.
(Layout::~Layout): Define.
(Layout::new_output_section_data_from_script): New method definition.
(Layout::place_orphan_sections_in_script): New method declaration.
(Layout::Segment_states): New type declaration.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method declarations.
(Layout::Output_section_data_list): New type declaration.
(Layout::Relaxation_debug_check): New class definition.
(Layout::record_output_section_data_from_script_,
Layout::script_output_section_data_list_, Layout::segment_states_,
Layout::relaxation_debug_check_): New data members.
* output.cc: (Output_section_headers::do_size): New method definition.
(Output_section_headers::Output_section_headers): Move size
computation to Output_section_headers::do_size.
(Output_segment_headers::do_size): New method definition.
(Output_file_header::Output_file_header): Move size computation to
Output_file_header::do_size and call it.
(Output_file_header::do_size): New method definition.
(Output_data_group::Output_data_group): Adjust call to
Output_section_data.
(Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
(Output_symtab_xindex::do_write): Add array bound check.
(Output_section::Input_section::print_to_mapfile): Handle
RELAXED_INPUT_SECTION_CODE.
(Output_section::Output_section): Initialize data member checkpoint_.
(Output_section::~Output_section): Delete checkpoint object pointed
by checkpoint_.
(Output_section::add_input_section): Always add an Input_section if
relaxing.
(Output_section::add_merge_input_section): Add assert.
(Output_section::relax_input_section): New method definition.
(Output_section::set_final_data_size): Set load address to zero for
an unallocated section.
(Output_section::do_address_and_file_offset_have_reset_values):
New method definition.
(Output_section::Input_section_sort_enty::Input_section_sort_enty):
Handle relaxed input section.
(Output_section::sort_attached_input_sections): Checkpoint input
section list lazily.
(Output_section::get_input_sections): Change type of input_sections to
list of Simple_input_section pointers. Checkpoint input section list
lazily. Also handle relaxed input sections.
(Output_section::add_input_section_for_script): Take a reference to
a Simple_input_section object instead of Relobj pointer and section
index as parameter. Handle relaxed input sections.
(Output_section::save_states, Output_section::restore_states): New
method definitions.
* output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
(Output_data::is_data_size_fixed): New method definition.
(Output_data::reset_addresss_and_file_offset): Do not reset data size
if it is fixed.
(Output_data::address_and_file_offset_have_reset_values): New method
definition.
(Output_data::do_address_and_file_offset_have_reset_values): New method
definition.
(Output_data::set_data_size): Check that data size is not fixed.
(Output_data::fix_data_size): New method definition.
(Output_data::is_data_size_fixed_): New data member.
(Output_section_headers::set_final_data_size): New method definition.
(Output_section_headers::do_size): New method declaration.
(Output_segment_headers::set_final_data_size): New method definition.
(Output_segment_headers::do_size): New method declaration.
(Output_file_header::set_final_data_size)::New method definition.
(Output_file_header::do_size)::New method declaration.
(Output_section_data::Output_section_data): Add new parameter
is_data_size_fixed and use it to fix data size.
(Output_data_const::Output_data_const): Adjust call to base class
constructor and fix data size.
(Output_data_const_buffer::Output_data_const_buffer): Adjust call to
base class constructor and fix data size.
(Output_data_fixed_space::Output_data_fixed_space): Adjust call to
base class constructor and fix data size.
(Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
class constructor and fix data size.
(Output_data_group::set_final_data_size): New method definition.
(Output_data_dynamic::Dynamic_entry::tag): New method definition.
(Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
class constructor and fix data size.
(Output_relaxed_input_section): New class definition.
(Output_section::Simple_input_section): New class definition.
(Output_section::get_input_sections): Adjust parameter list.
(Output_section::add_input_section_for_script): Same.
(Output_section::save_states, Output_section::restore_states,
Output_section::do_address_and_file_offset_have_reset_values,
(Output_section::Input_section::Input_section): Handle
RELAXED_INPUT_SECTION_CODE. Add new overload for
Output_relaxed_input_section.
(Output_section::Input_section::is_input_section,
Output_section::Input_section::set_output_section): Handle relaxed
input section.
(Output_section::Input_section::is_relaxed_input_section,
Output_section::Input_section::output_section_data,
Output_section::Input_section::relaxed_input_section): New method
definitions.
(Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
value.
(Output_section::Input_section::u1_): Update comments.
(Output_section::Input_section::u2_): Add new union member poris.
(Output_section::Checkpoint_output_section): New classs definition.
(Output_section::relax_input_section): New method declaration.
(Output_section::checkpoint_): New data member.
(Output_segment): Update comments.
(Output_segment::Output_segment): Un-privatize copy constructor.
(Output_segment::operator=): Un-privatize.
* script-sections.cc (Output_section_element::Input_section_list):
Change element type to Output_section::Simple_input_section.
(Output_section_element_dot_assignment::set_section_addresses):
Register output section data for relaxation clean up.
(Output_data_exression::Output_data_expression): Adjust call to base
constructor to fix data size.
(Output_section_element_data::set_section_addresses): Register
Output_data_expression object for relaxation clean up.
(struct Input_section_info): Replace Relobj pointer and section index
pair with Output_section::Simple_input_section and Convert struct to a
class.
(Input_section_sorter::operator()): Adjust access to
Input_section_info data member to use accessors.
(Output_section_element_input::set_section_addresses): Use layout
parameter. Adjust code to use Output_section::Simple_input_section
and Input_secction_info classes. Register filler for relaxation
clean up.
(Orphan_output_section::set_section_addresses): Replace Relobj pointer
and section index pair with Output_section::Simple_input_section
class. Adjust code accordingly.
(Phdrs_element::release_segment): New method definition.
(Script_sections::attach_sections_using_phdrs_clause): Do not modify
segment list.
(Script_sections::release_segments): New method definition.
* gold/script-sections.h (Script_sections::release_segments): New
method declaration.
* gold/target.h (Target::may_relax, Target::relax,
Target::do_may_relax, Target::do_relax): New method definitions.
2009-09-18 09:10:38 +08:00
|
|
|
virtual bool
|
|
|
|
do_may_relax() const
|
|
|
|
{ return parameters->options().relax(); }
|
|
|
|
|
2010-12-15 03:03:30 +08:00
|
|
|
// Virtual function which may be overridden by the child class.
|
2009-09-17 Doug Kwan <dougkwan@google.com>
* debug.h (DEBUG_RELAXATION): New constant.
(DEBUG_ALL): Add DEBUG_RELAXATION.
(debug_string_to_enum): Add relaxation debug option.
* layout.cc
(Layout::Relaxation_debug_check::check_output_data_for_reset_values,
Layout::Relaxation_debug_check::read_sections,
Layout::Relaxation_debug_check::read_sections): New method definitions.
(Layout::Layout): Initialize data members
record_output_section_data_from_scrips_,
script_output_section_data_list_ and relaxation_debug_check_.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method definitions.
(Layout::finalize): Support relaxation. Move section layout code to
Layout::relaxation_loop_body.
(Layout::set_asection_address_from_script): Move code for orphan
section placement out.
(Layout::place_orphan_sections_in_script): New method definition.
* layout.h (Output_segment_headers, Output_file_header):
New forward class declarations.
(Layout::~Layout): Define.
(Layout::new_output_section_data_from_script): New method definition.
(Layout::place_orphan_sections_in_script): New method declaration.
(Layout::Segment_states): New type declaration.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method declarations.
(Layout::Output_section_data_list): New type declaration.
(Layout::Relaxation_debug_check): New class definition.
(Layout::record_output_section_data_from_script_,
Layout::script_output_section_data_list_, Layout::segment_states_,
Layout::relaxation_debug_check_): New data members.
* output.cc: (Output_section_headers::do_size): New method definition.
(Output_section_headers::Output_section_headers): Move size
computation to Output_section_headers::do_size.
(Output_segment_headers::do_size): New method definition.
(Output_file_header::Output_file_header): Move size computation to
Output_file_header::do_size and call it.
(Output_file_header::do_size): New method definition.
(Output_data_group::Output_data_group): Adjust call to
Output_section_data.
(Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
(Output_symtab_xindex::do_write): Add array bound check.
(Output_section::Input_section::print_to_mapfile): Handle
RELAXED_INPUT_SECTION_CODE.
(Output_section::Output_section): Initialize data member checkpoint_.
(Output_section::~Output_section): Delete checkpoint object pointed
by checkpoint_.
(Output_section::add_input_section): Always add an Input_section if
relaxing.
(Output_section::add_merge_input_section): Add assert.
(Output_section::relax_input_section): New method definition.
(Output_section::set_final_data_size): Set load address to zero for
an unallocated section.
(Output_section::do_address_and_file_offset_have_reset_values):
New method definition.
(Output_section::Input_section_sort_enty::Input_section_sort_enty):
Handle relaxed input section.
(Output_section::sort_attached_input_sections): Checkpoint input
section list lazily.
(Output_section::get_input_sections): Change type of input_sections to
list of Simple_input_section pointers. Checkpoint input section list
lazily. Also handle relaxed input sections.
(Output_section::add_input_section_for_script): Take a reference to
a Simple_input_section object instead of Relobj pointer and section
index as parameter. Handle relaxed input sections.
(Output_section::save_states, Output_section::restore_states): New
method definitions.
* output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
(Output_data::is_data_size_fixed): New method definition.
(Output_data::reset_addresss_and_file_offset): Do not reset data size
if it is fixed.
(Output_data::address_and_file_offset_have_reset_values): New method
definition.
(Output_data::do_address_and_file_offset_have_reset_values): New method
definition.
(Output_data::set_data_size): Check that data size is not fixed.
(Output_data::fix_data_size): New method definition.
(Output_data::is_data_size_fixed_): New data member.
(Output_section_headers::set_final_data_size): New method definition.
(Output_section_headers::do_size): New method declaration.
(Output_segment_headers::set_final_data_size): New method definition.
(Output_segment_headers::do_size): New method declaration.
(Output_file_header::set_final_data_size)::New method definition.
(Output_file_header::do_size)::New method declaration.
(Output_section_data::Output_section_data): Add new parameter
is_data_size_fixed and use it to fix data size.
(Output_data_const::Output_data_const): Adjust call to base class
constructor and fix data size.
(Output_data_const_buffer::Output_data_const_buffer): Adjust call to
base class constructor and fix data size.
(Output_data_fixed_space::Output_data_fixed_space): Adjust call to
base class constructor and fix data size.
(Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
class constructor and fix data size.
(Output_data_group::set_final_data_size): New method definition.
(Output_data_dynamic::Dynamic_entry::tag): New method definition.
(Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
class constructor and fix data size.
(Output_relaxed_input_section): New class definition.
(Output_section::Simple_input_section): New class definition.
(Output_section::get_input_sections): Adjust parameter list.
(Output_section::add_input_section_for_script): Same.
(Output_section::save_states, Output_section::restore_states,
Output_section::do_address_and_file_offset_have_reset_values,
(Output_section::Input_section::Input_section): Handle
RELAXED_INPUT_SECTION_CODE. Add new overload for
Output_relaxed_input_section.
(Output_section::Input_section::is_input_section,
Output_section::Input_section::set_output_section): Handle relaxed
input section.
(Output_section::Input_section::is_relaxed_input_section,
Output_section::Input_section::output_section_data,
Output_section::Input_section::relaxed_input_section): New method
definitions.
(Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
value.
(Output_section::Input_section::u1_): Update comments.
(Output_section::Input_section::u2_): Add new union member poris.
(Output_section::Checkpoint_output_section): New classs definition.
(Output_section::relax_input_section): New method declaration.
(Output_section::checkpoint_): New data member.
(Output_segment): Update comments.
(Output_segment::Output_segment): Un-privatize copy constructor.
(Output_segment::operator=): Un-privatize.
* script-sections.cc (Output_section_element::Input_section_list):
Change element type to Output_section::Simple_input_section.
(Output_section_element_dot_assignment::set_section_addresses):
Register output section data for relaxation clean up.
(Output_data_exression::Output_data_expression): Adjust call to base
constructor to fix data size.
(Output_section_element_data::set_section_addresses): Register
Output_data_expression object for relaxation clean up.
(struct Input_section_info): Replace Relobj pointer and section index
pair with Output_section::Simple_input_section and Convert struct to a
class.
(Input_section_sorter::operator()): Adjust access to
Input_section_info data member to use accessors.
(Output_section_element_input::set_section_addresses): Use layout
parameter. Adjust code to use Output_section::Simple_input_section
and Input_secction_info classes. Register filler for relaxation
clean up.
(Orphan_output_section::set_section_addresses): Replace Relobj pointer
and section index pair with Output_section::Simple_input_section
class. Adjust code accordingly.
(Phdrs_element::release_segment): New method definition.
(Script_sections::attach_sections_using_phdrs_clause): Do not modify
segment list.
(Script_sections::release_segments): New method definition.
* gold/script-sections.h (Script_sections::release_segments): New
method declaration.
* gold/target.h (Target::may_relax, Target::relax,
Target::do_may_relax, Target::do_relax): New method definitions.
2009-09-18 09:10:38 +08:00
|
|
|
virtual bool
|
2010-11-09 15:56:10 +08:00
|
|
|
do_relax(int, const Input_objects*, Symbol_table*, Layout*, const Task*)
|
2009-09-17 Doug Kwan <dougkwan@google.com>
* debug.h (DEBUG_RELAXATION): New constant.
(DEBUG_ALL): Add DEBUG_RELAXATION.
(debug_string_to_enum): Add relaxation debug option.
* layout.cc
(Layout::Relaxation_debug_check::check_output_data_for_reset_values,
Layout::Relaxation_debug_check::read_sections,
Layout::Relaxation_debug_check::read_sections): New method definitions.
(Layout::Layout): Initialize data members
record_output_section_data_from_scrips_,
script_output_section_data_list_ and relaxation_debug_check_.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method definitions.
(Layout::finalize): Support relaxation. Move section layout code to
Layout::relaxation_loop_body.
(Layout::set_asection_address_from_script): Move code for orphan
section placement out.
(Layout::place_orphan_sections_in_script): New method definition.
* layout.h (Output_segment_headers, Output_file_header):
New forward class declarations.
(Layout::~Layout): Define.
(Layout::new_output_section_data_from_script): New method definition.
(Layout::place_orphan_sections_in_script): New method declaration.
(Layout::Segment_states): New type declaration.
(Layout::save_segments, Layout::restore_segments,
Layout::clean_up_after_relaxation, Layout::prepare_for_relaxation,
Layout::relaxation_loop_body): New method declarations.
(Layout::Output_section_data_list): New type declaration.
(Layout::Relaxation_debug_check): New class definition.
(Layout::record_output_section_data_from_script_,
Layout::script_output_section_data_list_, Layout::segment_states_,
Layout::relaxation_debug_check_): New data members.
* output.cc: (Output_section_headers::do_size): New method definition.
(Output_section_headers::Output_section_headers): Move size
computation to Output_section_headers::do_size.
(Output_segment_headers::do_size): New method definition.
(Output_file_header::Output_file_header): Move size computation to
Output_file_header::do_size and call it.
(Output_file_header::do_size): New method definition.
(Output_data_group::Output_data_group): Adjust call to
Output_section_data.
(Output_data_dynamic::set_final_data_size): Add DT_NULL tag only once.
(Output_symtab_xindex::do_write): Add array bound check.
(Output_section::Input_section::print_to_mapfile): Handle
RELAXED_INPUT_SECTION_CODE.
(Output_section::Output_section): Initialize data member checkpoint_.
(Output_section::~Output_section): Delete checkpoint object pointed
by checkpoint_.
(Output_section::add_input_section): Always add an Input_section if
relaxing.
(Output_section::add_merge_input_section): Add assert.
(Output_section::relax_input_section): New method definition.
(Output_section::set_final_data_size): Set load address to zero for
an unallocated section.
(Output_section::do_address_and_file_offset_have_reset_values):
New method definition.
(Output_section::Input_section_sort_enty::Input_section_sort_enty):
Handle relaxed input section.
(Output_section::sort_attached_input_sections): Checkpoint input
section list lazily.
(Output_section::get_input_sections): Change type of input_sections to
list of Simple_input_section pointers. Checkpoint input section list
lazily. Also handle relaxed input sections.
(Output_section::add_input_section_for_script): Take a reference to
a Simple_input_section object instead of Relobj pointer and section
index as parameter. Handle relaxed input sections.
(Output_section::save_states, Output_section::restore_states): New
method definitions.
* output.h (Output_data::Output_data): Initialize is_data_size_fixed_.
(Output_data::is_data_size_fixed): New method definition.
(Output_data::reset_addresss_and_file_offset): Do not reset data size
if it is fixed.
(Output_data::address_and_file_offset_have_reset_values): New method
definition.
(Output_data::do_address_and_file_offset_have_reset_values): New method
definition.
(Output_data::set_data_size): Check that data size is not fixed.
(Output_data::fix_data_size): New method definition.
(Output_data::is_data_size_fixed_): New data member.
(Output_section_headers::set_final_data_size): New method definition.
(Output_section_headers::do_size): New method declaration.
(Output_segment_headers::set_final_data_size): New method definition.
(Output_segment_headers::do_size): New method declaration.
(Output_file_header::set_final_data_size)::New method definition.
(Output_file_header::do_size)::New method declaration.
(Output_section_data::Output_section_data): Add new parameter
is_data_size_fixed and use it to fix data size.
(Output_data_const::Output_data_const): Adjust call to base class
constructor and fix data size.
(Output_data_const_buffer::Output_data_const_buffer): Adjust call to
base class constructor and fix data size.
(Output_data_fixed_space::Output_data_fixed_space): Adjust call to
base class constructor and fix data size.
(Output_data_zero_fill::Output_data_zero_fill): Adjust call to base
class constructor and fix data size.
(Output_data_group::set_final_data_size): New method definition.
(Output_data_dynamic::Dynamic_entry::tag): New method definition.
(Output_symtab_xindex::Output_symtab_xindex): Adjust call to base
class constructor and fix data size.
(Output_relaxed_input_section): New class definition.
(Output_section::Simple_input_section): New class definition.
(Output_section::get_input_sections): Adjust parameter list.
(Output_section::add_input_section_for_script): Same.
(Output_section::save_states, Output_section::restore_states,
Output_section::do_address_and_file_offset_have_reset_values,
(Output_section::Input_section::Input_section): Handle
RELAXED_INPUT_SECTION_CODE. Add new overload for
Output_relaxed_input_section.
(Output_section::Input_section::is_input_section,
Output_section::Input_section::set_output_section): Handle relaxed
input section.
(Output_section::Input_section::is_relaxed_input_section,
Output_section::Input_section::output_section_data,
Output_section::Input_section::relaxed_input_section): New method
definitions.
(Output_section::Input_section::RELAXED_INPUT_SECTION_CODE): New enum
value.
(Output_section::Input_section::u1_): Update comments.
(Output_section::Input_section::u2_): Add new union member poris.
(Output_section::Checkpoint_output_section): New classs definition.
(Output_section::relax_input_section): New method declaration.
(Output_section::checkpoint_): New data member.
(Output_segment): Update comments.
(Output_segment::Output_segment): Un-privatize copy constructor.
(Output_segment::operator=): Un-privatize.
* script-sections.cc (Output_section_element::Input_section_list):
Change element type to Output_section::Simple_input_section.
(Output_section_element_dot_assignment::set_section_addresses):
Register output section data for relaxation clean up.
(Output_data_exression::Output_data_expression): Adjust call to base
constructor to fix data size.
(Output_section_element_data::set_section_addresses): Register
Output_data_expression object for relaxation clean up.
(struct Input_section_info): Replace Relobj pointer and section index
pair with Output_section::Simple_input_section and Convert struct to a
class.
(Input_section_sorter::operator()): Adjust access to
Input_section_info data member to use accessors.
(Output_section_element_input::set_section_addresses): Use layout
parameter. Adjust code to use Output_section::Simple_input_section
and Input_secction_info classes. Register filler for relaxation
clean up.
(Orphan_output_section::set_section_addresses): Replace Relobj pointer
and section index pair with Output_section::Simple_input_section
class. Adjust code accordingly.
(Phdrs_element::release_segment): New method definition.
(Script_sections::attach_sections_using_phdrs_clause): Do not modify
segment list.
(Script_sections::release_segments): New method definition.
* gold/script-sections.h (Script_sections::release_segments): New
method declaration.
* gold/target.h (Target::may_relax, Target::relax,
Target::do_may_relax, Target::do_relax): New method definitions.
2009-09-18 09:10:38 +08:00
|
|
|
{ return false; }
|
|
|
|
|
2009-10-07 06:58:27 +08:00
|
|
|
// A function for targets to call. Return whether BYTES/LEN matches
|
|
|
|
// VIEW/VIEW_SIZE at OFFSET.
|
|
|
|
bool
|
|
|
|
match_view(const unsigned char* view, section_size_type view_size,
|
|
|
|
section_offset_type offset, const char* bytes, size_t len) const;
|
|
|
|
|
|
|
|
// Set the contents of a VIEW/VIEW_SIZE to nops starting at OFFSET
|
|
|
|
// for LEN bytes.
|
|
|
|
void
|
|
|
|
set_view_to_nop(unsigned char* view, section_size_type view_size,
|
|
|
|
section_offset_type offset, size_t len) const;
|
|
|
|
|
2010-12-15 03:03:30 +08:00
|
|
|
// This must be overridden by the child class if it has target-specific
|
2009-12-06 10:49:46 +08:00
|
|
|
// attributes subsection in the attribute section.
|
|
|
|
virtual int
|
|
|
|
do_attribute_arg_type(int) const
|
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
|
|
|
// This may be overridden by the child class.
|
|
|
|
virtual int
|
|
|
|
do_attributes_order(int num) const
|
|
|
|
{ return num; }
|
|
|
|
|
2010-02-03 13:36:55 +08:00
|
|
|
// This may be overridden by the child class.
|
|
|
|
virtual void
|
|
|
|
do_select_as_default_target()
|
|
|
|
{ }
|
|
|
|
|
2006-08-19 06:29:20 +08:00
|
|
|
private:
|
2009-08-19 07:49:29 +08:00
|
|
|
// The implementations of the four do_make_elf_object virtual functions are
|
2010-04-08 05:42:22 +08:00
|
|
|
// almost identical except for their sizes and endianness. We use a template.
|
2009-08-19 07:49:29 +08:00
|
|
|
// for their implementations.
|
|
|
|
template<int size, bool big_endian>
|
|
|
|
inline Object*
|
|
|
|
do_make_elf_object_implementation(const std::string&, Input_file*, off_t,
|
|
|
|
const elfcpp::Ehdr<size, big_endian>&);
|
|
|
|
|
2006-08-19 06:29:20 +08:00
|
|
|
Target(const Target&);
|
|
|
|
Target& operator=(const Target&);
|
|
|
|
|
2006-09-28 06:53:42 +08:00
|
|
|
// The target information.
|
|
|
|
const Target_info* pti_;
|
2009-10-30 Doug Kwan <dougkwan@google.com>
elfcpp/ChangeLog:
* arm.h (EF_ARM_BE8, EF_ARM_EABIMASK, EF_ARM_EABI_UNKNOWN,
EF_ARM_EABI_VER1, EF_ARM_EABI_VER2, EF_ARM_EABI_VER3,
EF_ARM_EABI_VER4, EF_ARM_EABI_VER5): New enums for processor-specific
flags.
(arm_eabi_version): New inline function.
* elfcpp.h: Add a comment about DT_ENCODING.
gold/ChangeLog:
* arm.cc (Arm_relobj::processor_specific_flags): New method
definition.
(Arm_relobj::do_read_symbols): New method declaration.
(Arm_relobj::processor_specific_flags_): New data member declaration.
(Arm_dynobj): New class definition.
(Target_arm::do_finalize_sections): Add input_objects parameter.
(Target_arm::do_adjust_elf_header): New method declaration.
(Target_arm::are_eabi_versions_compatible,
(Target_arm::merge_processor_specific_flags): New method declaration.
(Target_arm::do_make_elf_object): New overloaded method definitions
and declaration.
(Arm_relobj::do_read_symbols): New method definition.
(Arm_dynobj::do_read_symbols): Ditto.
(Target_arm::do_finalize_sections): Add input_objects parameters.
Merge processor-specific flags from all input objects.
(Target_arm::are_eabi_versions_compatible,
Target_arm::merge_processor_specific_flags,
Target_arm::do_adjust_elf_header, Target_arm::do_make_elf_object):
New method definitions.
* i386.cc (Target_i386::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
* layout.cc (Layout::finalize): Pass input objects to target's.
finalize_sections function.
* output.cc (Output_file_header::do_sized_write): Set ELF file
header's processor-specific flags.
* powerpc.cc (Target_powerpc::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
* sparc.cc (Target_sparc::do_finalize_sections): Same.
* target.h (Input_objects): New forward class declaration.
(Target::processor_specific_flags,
Target::are_processor_specific_flags_sect): New method definitions.
(Target::finalize_sections): Add input_objects parameter.
(Target::Target): Initialize processor_specific_flags_ and
are_processor_specific_flags_set_.
(Target::do_finalize_sections): Add unnamed Input_objects pointer type
parameter.
(Target::set_processor_specific_flags): New method definition.
(Target::processor_specific_flags_,
Target::are_processor_specific_flags_set_): New data member
declarations.
* x86_64.cc (Target_x86_64::do_finalize_sections): Add unnamed
Input_objects pointer type parameter.
2009-10-31 02:49:59 +08:00
|
|
|
// Processor-specific flags.
|
|
|
|
elfcpp::Elf_Word processor_specific_flags_;
|
|
|
|
// Whether the processor-specific flags are set at least once.
|
|
|
|
bool are_processor_specific_flags_set_;
|
2006-08-05 07:10:59 +08:00
|
|
|
};
|
|
|
|
|
2006-08-19 06:29:20 +08:00
|
|
|
// The abstract class for a specific size and endianness of target.
|
|
|
|
// Each actual target implementation class should derive from an
|
|
|
|
// instantiation of Sized_target.
|
|
|
|
|
|
|
|
template<int size, bool big_endian>
|
|
|
|
class Sized_target : public Target
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Make a new symbol table entry for the target. This should be
|
|
|
|
// overridden by a target which needs additional information in the
|
|
|
|
// symbol table. This will only be called if has_make_symbol()
|
|
|
|
// returns true.
|
|
|
|
virtual Sized_symbol<size>*
|
2006-12-06 08:02:36 +08:00
|
|
|
make_symbol() const
|
2006-11-30 01:56:40 +08:00
|
|
|
{ gold_unreachable(); }
|
2006-08-19 06:29:20 +08:00
|
|
|
|
|
|
|
// Resolve a symbol for the target. This should be overridden by a
|
|
|
|
// target which needs to take special action. TO is the
|
|
|
|
// pre-existing symbol. SYM is the new symbol, seen in OBJECT.
|
2006-12-06 08:02:36 +08:00
|
|
|
// VERSION is the version of SYM. This will only be called if
|
|
|
|
// has_resolve() returns true.
|
2006-08-19 06:29:20 +08:00
|
|
|
virtual void
|
2006-12-06 08:02:36 +08:00
|
|
|
resolve(Symbol*, const elfcpp::Sym<size, big_endian>&, Object*,
|
|
|
|
const char*)
|
2006-11-30 01:56:40 +08:00
|
|
|
{ gold_unreachable(); }
|
2006-08-19 06:29:20 +08:00
|
|
|
|
2009-01-28 10:25:33 +08:00
|
|
|
// Process the relocs for a section, and record information of the
|
|
|
|
// mapping from source to destination sections. This mapping is later
|
|
|
|
// used to determine unreferenced garbage sections. This procedure is
|
|
|
|
// only called during garbage collection.
|
|
|
|
virtual void
|
* object.h (class Relobj): Drop options parameter from
gc_process_relocs, scan_relocs, relocate, do_gc_process_relocs,
do_scan_relocs, do_relocate. Change all callers.
(class Sized_relobj): Drop options parameters from
do_gc_process_relocs, do_scan_relocs, do_relocate,
do_relocate_sections, relocate_sections, emit_relocs_scan,
emit_relocs_scan_reltype. Change all callers.
(struct Relocate_info): Remove options field and all references to
it.
* reloc.h (class Read_relocs): Remove options constructor
parameter and options_ field. Change all callers.
(class Gc_process_relocs, class Scan_relocs): Likewise.
(class Relocate_task): Likewise.
* target-reloc.h (scan_relocs): Remove options parameter. Change
all callers.
(scan_relocatable_relocs): Likewise.
* target.h (class Sized_target): Remove options parameter from
gc_process_relocs, scan_relocs, scan_relocatable_relocs. Change
all callers.
* gc.h (gc_process_relocs): Remove options parameter. Change all
callers.
* arm.cc: Update functions to remove options parameters.
* i386.cc: Likewise.
* powerpc.cc: Likewise.
* sparc.cc: Likewise.
* x86_64.cc: Likewise.
* testsuite/testfile.cc: Likewise.
2009-10-29 13:16:23 +08:00
|
|
|
gc_process_relocs(Symbol_table* symtab,
|
|
|
|
Layout* layout,
|
|
|
|
Sized_relobj<size, big_endian>* object,
|
|
|
|
unsigned int data_shndx,
|
|
|
|
unsigned int sh_type,
|
|
|
|
const unsigned char* prelocs,
|
|
|
|
size_t reloc_count,
|
|
|
|
Output_section* output_section,
|
|
|
|
bool needs_special_offset_handling,
|
|
|
|
size_t local_symbol_count,
|
|
|
|
const unsigned char* plocal_symbols) = 0;
|
2009-01-28 10:25:33 +08:00
|
|
|
|
2006-10-21 04:40:49 +08:00
|
|
|
// Scan the relocs for a section, and record any information
|
* object.h (class Relobj): Drop options parameter from
gc_process_relocs, scan_relocs, relocate, do_gc_process_relocs,
do_scan_relocs, do_relocate. Change all callers.
(class Sized_relobj): Drop options parameters from
do_gc_process_relocs, do_scan_relocs, do_relocate,
do_relocate_sections, relocate_sections, emit_relocs_scan,
emit_relocs_scan_reltype. Change all callers.
(struct Relocate_info): Remove options field and all references to
it.
* reloc.h (class Read_relocs): Remove options constructor
parameter and options_ field. Change all callers.
(class Gc_process_relocs, class Scan_relocs): Likewise.
(class Relocate_task): Likewise.
* target-reloc.h (scan_relocs): Remove options parameter. Change
all callers.
(scan_relocatable_relocs): Likewise.
* target.h (class Sized_target): Remove options parameter from
gc_process_relocs, scan_relocs, scan_relocatable_relocs. Change
all callers.
* gc.h (gc_process_relocs): Remove options parameter. Change all
callers.
* arm.cc: Update functions to remove options parameters.
* i386.cc: Likewise.
* powerpc.cc: Likewise.
* sparc.cc: Likewise.
* x86_64.cc: Likewise.
* testsuite/testfile.cc: Likewise.
2009-10-29 13:16:23 +08:00
|
|
|
// required for the symbol. SYMTAB is the symbol table. OBJECT is
|
|
|
|
// the object in which the section appears. DATA_SHNDX is the
|
|
|
|
// section index that these relocs apply to. SH_TYPE is the type of
|
|
|
|
// the relocation section, SHT_REL or SHT_RELA. PRELOCS points to
|
|
|
|
// the relocation data. RELOC_COUNT is the number of relocs.
|
|
|
|
// LOCAL_SYMBOL_COUNT is the number of local symbols.
|
|
|
|
// OUTPUT_SECTION is the output section.
|
2007-11-09 15:00:15 +08:00
|
|
|
// NEEDS_SPECIAL_OFFSET_HANDLING is true if offsets to the output
|
|
|
|
// sections are not mapped as usual. PLOCAL_SYMBOLS points to the
|
|
|
|
// local symbol data from OBJECT. GLOBAL_SYMBOLS is the array of
|
|
|
|
// pointers to the global symbol table from OBJECT.
|
2006-09-30 03:58:17 +08:00
|
|
|
virtual void
|
* object.h (class Relobj): Drop options parameter from
gc_process_relocs, scan_relocs, relocate, do_gc_process_relocs,
do_scan_relocs, do_relocate. Change all callers.
(class Sized_relobj): Drop options parameters from
do_gc_process_relocs, do_scan_relocs, do_relocate,
do_relocate_sections, relocate_sections, emit_relocs_scan,
emit_relocs_scan_reltype. Change all callers.
(struct Relocate_info): Remove options field and all references to
it.
* reloc.h (class Read_relocs): Remove options constructor
parameter and options_ field. Change all callers.
(class Gc_process_relocs, class Scan_relocs): Likewise.
(class Relocate_task): Likewise.
* target-reloc.h (scan_relocs): Remove options parameter. Change
all callers.
(scan_relocatable_relocs): Likewise.
* target.h (class Sized_target): Remove options parameter from
gc_process_relocs, scan_relocs, scan_relocatable_relocs. Change
all callers.
* gc.h (gc_process_relocs): Remove options parameter. Change all
callers.
* arm.cc: Update functions to remove options parameters.
* i386.cc: Likewise.
* powerpc.cc: Likewise.
* sparc.cc: Likewise.
* x86_64.cc: Likewise.
* testsuite/testfile.cc: Likewise.
2009-10-29 13:16:23 +08:00
|
|
|
scan_relocs(Symbol_table* symtab,
|
2006-11-04 02:26:11 +08:00
|
|
|
Layout* layout,
|
2006-11-07 06:46:08 +08:00
|
|
|
Sized_relobj<size, big_endian>* object,
|
2006-11-30 01:56:40 +08:00
|
|
|
unsigned int data_shndx,
|
2006-10-21 04:40:49 +08:00
|
|
|
unsigned int sh_type,
|
|
|
|
const unsigned char* prelocs,
|
|
|
|
size_t reloc_count,
|
2007-11-09 15:00:15 +08:00
|
|
|
Output_section* output_section,
|
|
|
|
bool needs_special_offset_handling,
|
2006-10-21 04:40:49 +08:00
|
|
|
size_t local_symbol_count,
|
2007-11-09 15:00:15 +08:00
|
|
|
const unsigned char* plocal_symbols) = 0;
|
2006-10-21 04:40:49 +08:00
|
|
|
|
|
|
|
// Relocate section data. SH_TYPE is the type of the relocation
|
|
|
|
// section, SHT_REL or SHT_RELA. PRELOCS points to the relocation
|
2007-11-09 15:00:15 +08:00
|
|
|
// information. RELOC_COUNT is the number of relocs.
|
|
|
|
// OUTPUT_SECTION is the output section.
|
|
|
|
// NEEDS_SPECIAL_OFFSET_HANDLING is true if offsets must be mapped
|
|
|
|
// to correspond to the output section. VIEW is a view into the
|
|
|
|
// output file holding the section contents, VIEW_ADDRESS is the
|
|
|
|
// virtual address of the view, and VIEW_SIZE is the size of the
|
|
|
|
// view. If NEEDS_SPECIAL_OFFSET_HANDLING is true, the VIEW_xx
|
|
|
|
// parameters refer to the complete output section data, not just
|
|
|
|
// the input section data.
|
2006-10-21 04:40:49 +08:00
|
|
|
virtual void
|
|
|
|
relocate_section(const Relocate_info<size, big_endian>*,
|
|
|
|
unsigned int sh_type,
|
|
|
|
const unsigned char* prelocs,
|
|
|
|
size_t reloc_count,
|
2007-11-09 15:00:15 +08:00
|
|
|
Output_section* output_section,
|
|
|
|
bool needs_special_offset_handling,
|
2006-10-21 04:40:49 +08:00
|
|
|
unsigned char* view,
|
|
|
|
typename elfcpp::Elf_types<size>::Elf_Addr view_address,
|
2009-10-07 06:58:27 +08:00
|
|
|
section_size_type view_size,
|
|
|
|
const Reloc_symbol_changes*) = 0;
|
2006-09-30 03:58:17 +08:00
|
|
|
|
2008-02-06 16:13:50 +08:00
|
|
|
// Scan the relocs during a relocatable link. The parameters are
|
|
|
|
// like scan_relocs, with an additional Relocatable_relocs
|
|
|
|
// parameter, used to record the disposition of the relocs.
|
|
|
|
virtual void
|
* object.h (class Relobj): Drop options parameter from
gc_process_relocs, scan_relocs, relocate, do_gc_process_relocs,
do_scan_relocs, do_relocate. Change all callers.
(class Sized_relobj): Drop options parameters from
do_gc_process_relocs, do_scan_relocs, do_relocate,
do_relocate_sections, relocate_sections, emit_relocs_scan,
emit_relocs_scan_reltype. Change all callers.
(struct Relocate_info): Remove options field and all references to
it.
* reloc.h (class Read_relocs): Remove options constructor
parameter and options_ field. Change all callers.
(class Gc_process_relocs, class Scan_relocs): Likewise.
(class Relocate_task): Likewise.
* target-reloc.h (scan_relocs): Remove options parameter. Change
all callers.
(scan_relocatable_relocs): Likewise.
* target.h (class Sized_target): Remove options parameter from
gc_process_relocs, scan_relocs, scan_relocatable_relocs. Change
all callers.
* gc.h (gc_process_relocs): Remove options parameter. Change all
callers.
* arm.cc: Update functions to remove options parameters.
* i386.cc: Likewise.
* powerpc.cc: Likewise.
* sparc.cc: Likewise.
* x86_64.cc: Likewise.
* testsuite/testfile.cc: Likewise.
2009-10-29 13:16:23 +08:00
|
|
|
scan_relocatable_relocs(Symbol_table* symtab,
|
2008-02-06 16:13:50 +08:00
|
|
|
Layout* layout,
|
|
|
|
Sized_relobj<size, big_endian>* object,
|
|
|
|
unsigned int data_shndx,
|
|
|
|
unsigned int sh_type,
|
|
|
|
const unsigned char* prelocs,
|
|
|
|
size_t reloc_count,
|
|
|
|
Output_section* output_section,
|
|
|
|
bool needs_special_offset_handling,
|
|
|
|
size_t local_symbol_count,
|
|
|
|
const unsigned char* plocal_symbols,
|
|
|
|
Relocatable_relocs*) = 0;
|
|
|
|
|
|
|
|
// Relocate a section during a relocatable link. The parameters are
|
|
|
|
// like relocate_section, with additional parameters for the view of
|
|
|
|
// the output reloc section.
|
|
|
|
virtual void
|
|
|
|
relocate_for_relocatable(const Relocate_info<size, big_endian>*,
|
|
|
|
unsigned int sh_type,
|
|
|
|
const unsigned char* prelocs,
|
|
|
|
size_t reloc_count,
|
|
|
|
Output_section* output_section,
|
|
|
|
off_t offset_in_output_section,
|
|
|
|
const Relocatable_relocs*,
|
|
|
|
unsigned char* view,
|
|
|
|
typename elfcpp::Elf_types<size>::Elf_Addr
|
|
|
|
view_address,
|
|
|
|
section_size_type view_size,
|
|
|
|
unsigned char* reloc_view,
|
|
|
|
section_size_type reloc_view_size) = 0;
|
2010-05-26 11:33:59 +08:00
|
|
|
|
|
|
|
// Perform target-specific processing in a relocatable link. This is
|
|
|
|
// only used if we use the relocation strategy RELOC_SPECIAL.
|
|
|
|
// RELINFO points to a Relocation_info structure. SH_TYPE is the relocation
|
|
|
|
// section type. PRELOC_IN points to the original relocation. RELNUM is
|
|
|
|
// the index number of the relocation in the relocation section.
|
|
|
|
// OUTPUT_SECTION is the output section to which the relocation is applied.
|
|
|
|
// OFFSET_IN_OUTPUT_SECTION is the offset of the relocation input section
|
|
|
|
// within the output section. VIEW points to the output view of the
|
|
|
|
// output section. VIEW_ADDRESS is output address of the view. VIEW_SIZE
|
|
|
|
// is the size of the output view and PRELOC_OUT points to the new
|
|
|
|
// relocation in the output object.
|
|
|
|
//
|
|
|
|
// A target only needs to override this if the generic code in
|
|
|
|
// target-reloc.h cannot handle some relocation types.
|
2008-02-06 16:13:50 +08:00
|
|
|
|
2010-05-26 11:33:59 +08:00
|
|
|
virtual void
|
|
|
|
relocate_special_relocatable(const Relocate_info<size, big_endian>*
|
|
|
|
/*relinfo */,
|
|
|
|
unsigned int /* sh_type */,
|
|
|
|
const unsigned char* /* preloc_in */,
|
|
|
|
size_t /* relnum */,
|
|
|
|
Output_section* /* output_section */,
|
|
|
|
off_t /* offset_in_output_section */,
|
|
|
|
unsigned char* /* view */,
|
|
|
|
typename elfcpp::Elf_types<size>::Elf_Addr
|
|
|
|
/* view_address */,
|
|
|
|
section_size_type /* view_size */,
|
|
|
|
unsigned char* /* preloc_out*/)
|
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
2010-08-13 06:15:00 +08:00
|
|
|
// Return the number of entries in the GOT. This is only used for
|
|
|
|
// laying out the incremental link info sections. A target needs
|
|
|
|
// to implement this to support incremental linking.
|
|
|
|
|
|
|
|
virtual unsigned int
|
|
|
|
got_entry_count() const
|
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
|
|
|
// Return the number of entries in the PLT. This is only used for
|
|
|
|
// laying out the incremental link info sections. A target needs
|
|
|
|
// to implement this to support incremental linking.
|
|
|
|
|
|
|
|
virtual unsigned int
|
|
|
|
plt_entry_count() const
|
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
|
|
|
// Return the offset of the first non-reserved PLT entry. This is
|
|
|
|
// only used for laying out the incremental link info sections.
|
|
|
|
// A target needs to implement this to support incremental linking.
|
|
|
|
|
|
|
|
virtual unsigned int
|
|
|
|
first_plt_entry_offset() const
|
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
|
|
|
// Return the size of each PLT entry. This is only used for
|
|
|
|
// laying out the incremental link info sections. A target needs
|
|
|
|
// to implement this to support incremental linking.
|
|
|
|
|
|
|
|
virtual unsigned int
|
|
|
|
plt_entry_size() const
|
|
|
|
{ gold_unreachable(); }
|
|
|
|
|
2006-08-19 06:29:20 +08:00
|
|
|
protected:
|
2006-09-28 06:53:42 +08:00
|
|
|
Sized_target(const Target::Target_info* pti)
|
|
|
|
: Target(pti)
|
|
|
|
{
|
2006-11-30 01:56:40 +08:00
|
|
|
gold_assert(pti->size == size);
|
|
|
|
gold_assert(pti->is_big_endian ? big_endian : !big_endian);
|
2006-09-28 06:53:42 +08:00
|
|
|
}
|
2006-08-19 06:29:20 +08:00
|
|
|
};
|
2006-08-05 07:10:59 +08:00
|
|
|
|
|
|
|
} // End namespace gold.
|
|
|
|
|
|
|
|
#endif // !defined(GOLD_TARGET_H)
|