Skip to content

Commit

Permalink
2010-05-23 Doug Kwan <[email protected]>
Browse files Browse the repository at this point in the history
	* arm.cc (Arm_input_section::do_output_offset): Use convert_types
	instead of a cast.
	(Target_arm::apply_cortex_a8_workaround): Rewrite a conditional branch
	with a direct branch, not a conditional branch, to a stub.
	* merge.cc (Output_merge_base::record_input_section): New method
	defintion.
	(Output_merge_data::do_add_input_section): Record input section if
	keeps-input-sections flag is set.
	(Output_merge_string::do_add_input_section): Ditto.
	* merge.h (Output_merge_base::Output_merge_base): Initialize new data
	members KEEPS_INPUT_SECTIONS_, FIRST_RELOBJ_, FIRST_SHNDX_ and
	INPUT_SECTIONS_.
	(Output_merge_base::keeps_input_sections,
	Output_merge_base::set_keeps_input_sections,
	Output_merge_base::first_relobj, Output_merge_base::first_shndx): New
	method definitions.
	(Output_merge_base::Input_sections): New type declaration.
	(Output_merge_base::input_sections_begin,
	Output_merge_base::input_sections_end,
	Output_merge_base::do_set_keeps_input_sections): New method definitions.
	(Output_merge_base::bool keeps_input_sections_,
	Output_merge_base::first_relobj_, Output_merge_base::first_shndx_,
	Output_merge_base::input_sections_): New data members.
	(Output_merge_data::do_set_keeps_input_sections): New method
	defintion.
	(Output_merge_string::do_set_keeps_input_sections): Ditto.
	* output.cc (Output_section::Input_section::relobj): Move method
	defintion from class declaration to here and handle merge sections.
	(Output_section::Input_section::shndx): Ditto.
	(Output_section::Output_section): Remove initializations of removed
	data members and initialize new data member LOOKUP_MAPS_.
	(Output_section::add_input_section): Set keeps-input-sections flag
	for a newly created merge output section as appropriate.  Adjust code
	to use Output_section_lookup_maps class.
	(Output_section::add_relaxed_input_section): Adjst code for lookup
	maps code refactoring.
 	(Output_section::add_merge_input_section): Add a new parameter
	KEEPS_INPUT_SECTION.  Adjust code to use Output_section_lookup_maps
	class.  If adding input section to a newly created merge output
	section fails, remove the new merge section.
	(Output_section::convert_input_sections_in_list_to_relaxed_input_sections):
	Adjust code for use of the Output_section_lookup_maps class.
 	(Output_section::find_merge_section): Ditto.
	(Output_section::build_lookup_maps): New method defintion.
 	(Output_section::find_relaxed_input_section): Adjust code to use
	Output_section_lookup_maps class.
	(Output_section::get_input_sections): Export merge sections.  Adjust
	code to use Output_section_lookup_maps class.
	(Output_section:::add_script_input_section): Adjust code to use
	Output_section_lookup_maps class.  Update lookup maps for merge
	sections also.
	(Output_section::discard_states): Use Output_section_lookup_maps.
	(Output_section::restore_states): Same.
	* output.h (Merge_section_properties): Move class defintion out of
	Output_section.
	(Output_section_lookup_maps): New class.
	(Output_section::Input_section::is_merge_section): New method
	defintion.
	(Output_section::Input_section::relobj): Move defintion out of class
	defintion.  Declare method only.
	(Output_section::Input_section::shndx): Ditto.
	(Output_section::Input_section::output_merge_base): New method defintion.
     	(Output_section::Input_section::u2_.pomb): New union field.
	(Output_section::Merge_section_by_properties_map,
	Output_section::Output_section_data_by_input_section_map,
	Output_section::Ouptut_relaxed_input_section_by_input_section_map):
	Remove types.
   	(Output_section::add_merge_input_section): Add new parameter
	KEEPS_INPUT_SECTIONS.
	(Output_section::build_lookup_maps): New method declaration.
	(Output_section::merge_section_map_,
	Output_section::merge_section_by_properties_map_,
	Output_section::relaxed_input_section_map_,
	Output_section::is_relaxed_input_section_map_valid_): Remove data
	members.
	(Output_section::lookup_maps_): New data member.
  • Loading branch information
dougkwan committed May 23, 2010
1 parent f434ba0 commit 0439c79
Show file tree
Hide file tree
Showing 6 changed files with 564 additions and 182 deletions.
79 changes: 79 additions & 0 deletions gold/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,82 @@
2010-05-23 Doug Kwan <[email protected]>

* arm.cc (Arm_input_section::do_output_offset): Use convert_types
instead of a cast.
(Target_arm::apply_cortex_a8_workaround): Rewrite a conditional branch
with a direct branch, not a conditional branch, to a stub.
* merge.cc (Output_merge_base::record_input_section): New method
defintion.
(Output_merge_data::do_add_input_section): Record input section if
keeps-input-sections flag is set.
(Output_merge_string::do_add_input_section): Ditto.
* merge.h (Output_merge_base::Output_merge_base): Initialize new data
members KEEPS_INPUT_SECTIONS_, FIRST_RELOBJ_, FIRST_SHNDX_ and
INPUT_SECTIONS_.
(Output_merge_base::keeps_input_sections,
Output_merge_base::set_keeps_input_sections,
Output_merge_base::first_relobj, Output_merge_base::first_shndx): New
method definitions.
(Output_merge_base::Input_sections): New type declaration.
(Output_merge_base::input_sections_begin,
Output_merge_base::input_sections_end,
Output_merge_base::do_set_keeps_input_sections): New method definitions.
(Output_merge_base::bool keeps_input_sections_,
Output_merge_base::first_relobj_, Output_merge_base::first_shndx_,
Output_merge_base::input_sections_): New data members.
(Output_merge_data::do_set_keeps_input_sections): New method
defintion.
(Output_merge_string::do_set_keeps_input_sections): Ditto.
* output.cc (Output_section::Input_section::relobj): Move method
defintion from class declaration to here and handle merge sections.
(Output_section::Input_section::shndx): Ditto.
(Output_section::Output_section): Remove initializations of removed
data members and initialize new data member LOOKUP_MAPS_.
(Output_section::add_input_section): Set keeps-input-sections flag
for a newly created merge output section as appropriate. Adjust code
to use Output_section_lookup_maps class.
(Output_section::add_relaxed_input_section): Adjst code for lookup
maps code refactoring.
(Output_section::add_merge_input_section): Add a new parameter
KEEPS_INPUT_SECTION. Adjust code to use Output_section_lookup_maps
class. If adding input section to a newly created merge output
section fails, remove the new merge section.
(Output_section::convert_input_sections_in_list_to_relaxed_input_sections):
Adjust code for use of the Output_section_lookup_maps class.
(Output_section::find_merge_section): Ditto.
(Output_section::build_lookup_maps): New method defintion.
(Output_section::find_relaxed_input_section): Adjust code to use
Output_section_lookup_maps class.
(Output_section::get_input_sections): Export merge sections. Adjust
code to use Output_section_lookup_maps class.
(Output_section:::add_script_input_section): Adjust code to use
Output_section_lookup_maps class. Update lookup maps for merge
sections also.
(Output_section::discard_states): Use Output_section_lookup_maps.
(Output_section::restore_states): Same.
* output.h (Merge_section_properties): Move class defintion out of
Output_section.
(Output_section_lookup_maps): New class.
(Output_section::Input_section::is_merge_section): New method
defintion.
(Output_section::Input_section::relobj): Move defintion out of class
defintion. Declare method only.
(Output_section::Input_section::shndx): Ditto.
(Output_section::Input_section::output_merge_base): New method defintion.
(Output_section::Input_section::u2_.pomb): New union field.
(Output_section::Merge_section_by_properties_map,
Output_section::Output_section_data_by_input_section_map,
Output_section::Ouptut_relaxed_input_section_by_input_section_map):
Remove types.
(Output_section::add_merge_input_section): Add new parameter
KEEPS_INPUT_SECTIONS.
(Output_section::build_lookup_maps): New method declaration.
(Output_section::merge_section_map_,
Output_section::merge_section_by_properties_map_,
Output_section::relaxed_input_section_map_,
Output_section::is_relaxed_input_section_map_valid_): Remove data
members.
(Output_section::lookup_maps_): New data member.

2010-05-21 Doug Kwan <[email protected]>

PR gold/11619
Expand Down
15 changes: 7 additions & 8 deletions gold/arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,8 @@ class Arm_input_section : public Output_relaxed_input_section
if ((object == this->relobj())
&& (shndx == this->shndx())
&& (offset >= 0)
&& (offset <= static_cast<section_offset_type>(this->original_size_)))
&& (offset <=
convert_types<section_offset_type, uint32_t>(this->original_size_)))
{
*poutput = offset;
return true;
Expand Down Expand Up @@ -10898,13 +10899,11 @@ Target_arm<big_endian>::apply_cortex_a8_workaround(
switch (stub->stub_template()->type())
{
case arm_stub_a8_veneer_b_cond:
gold_assert(!utils::has_overflow<21>(branch_offset));
upper_insn = RelocFuncs::thumb32_cond_branch_upper(upper_insn,
branch_offset);
lower_insn = RelocFuncs::thumb32_cond_branch_lower(lower_insn,
branch_offset);
break;

// For a conditional branch, we re-write it to be a uncondition
// branch to the stub. We use the THUMB-2 encoding here.
upper_insn = 0xf000U;
lower_insn = 0xb800U;
// Fall through
case arm_stub_a8_veneer_b:
case arm_stub_a8_veneer_bl:
case arm_stub_a8_veneer_blx:
Expand Down
28 changes: 28 additions & 0 deletions gold/merge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,26 @@ Output_merge_base::do_is_merge_section_for(const Relobj* object,
return this->merge_map_.is_merge_section_for(object, shndx);
}

// Record a merged input section for script processing.

void
Output_merge_base::record_input_section(Relobj* relobj, unsigned int shndx)
{
gold_assert(this->keeps_input_sections_ && relobj != NULL);
// If this is the first input section, record it. We need do this because
// this->input_sections_ is unordered.
if (this->first_relobj_ == NULL)
{
this->first_relobj_ = relobj;
this->first_shndx_ = shndx;
}

std::pair<Input_sections::iterator, bool> result =
this->input_sections_.insert(Section_id(relobj, shndx));
// We should insert a merge section once only.
gold_assert(result.second);
}

// Class Output_merge_data.

// Compute the hash code for a fixed-size constant.
Expand Down Expand Up @@ -414,6 +434,10 @@ Output_merge_data::do_add_input_section(Relobj* object, unsigned int shndx)
this->add_mapping(object, shndx, i, entsize, k);
}

// For script processing, we keep the input sections.
if (this->keeps_input_sections())
record_input_section(object, shndx);

return true;
}

Expand Down Expand Up @@ -517,6 +541,10 @@ Output_merge_string<Char_type>::do_add_input_section(Relobj* object,

this->input_count_ += count;

// For script processing, we keep the input sections.
if (this->keeps_input_sections())
record_input_section(object, shndx);

return true;
}

Expand Down
84 changes: 83 additions & 1 deletion gold/merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ class Output_merge_base : public Output_section_data
{
public:
Output_merge_base(uint64_t entsize, uint64_t addralign)
: Output_section_data(addralign), merge_map_(), entsize_(entsize)
: Output_section_data(addralign), merge_map_(), entsize_(entsize),
keeps_input_sections_(false), first_relobj_(NULL), first_shndx_(-1),
input_sections_()
{ }

// Return the entry size.
Expand All @@ -230,6 +232,52 @@ class Output_merge_base : public Output_section_data
is_string()
{ return this->do_is_string(); }

// Whether this keeps input sections.
bool
keeps_input_sections() const
{ return this->keeps_input_sections_; }

// Set the keeps-input-sections flag. This is virtual so that sub-classes
// can perform additional checks.
void
set_keeps_input_sections()
{ this->do_set_keeps_input_sections(); }

// Return the object of the first merged input section. This used
// for script processing. This is NULL if merge section is empty.
Relobj*
first_relobj() const
{ return this->first_relobj_; }

// Return the section index of the first merged input section. This
// is used for script processing. This is valid only if merge section
// is not valid.
unsigned int
first_shndx() const
{
gold_assert(this->first_relobj_ != NULL);
return this->first_shndx_;
}

// Set of merged input sections.
typedef Unordered_set<Section_id, Section_id_hash> Input_sections;

// Beginning of merged input sections.
Input_sections::const_iterator
input_sections_begin() const
{
gold_assert(this->keeps_input_sections_);
return this->input_sections_.begin();
}

// Beginning of merged input sections.
Input_sections::const_iterator
input_sections_end() const
{
gold_assert(this->keeps_input_sections_);
return this->input_sections_.end();
}

protected:
// Return the output offset for an input offset.
bool
Expand Down Expand Up @@ -257,13 +305,31 @@ class Output_merge_base : public Output_section_data
do_is_string()
{ return false; }

// This may be overridden by the child class.
virtual void
do_set_keeps_input_sections()
{ this->keeps_input_sections_ = true; }

// Record the merged input section for script processing.
void
record_input_section(Relobj* relobj, unsigned int shndx);

private:
// A mapping from input object/section/offset to offset in output
// section.
Merge_map merge_map_;
// The entry size. For fixed-size constants, this is the size of
// the constants. For strings, this is the size of a character.
uint64_t entsize_;
// Whether we keep input sections.
bool keeps_input_sections_;
// Object of the first merged input section. We use this for script
// processing.
Relobj* first_relobj_;
// Section index of the first merged input section.
unsigned int first_shndx_;
// Input sections. We only keep them is keeps_input_sections_ is true.
Input_sections input_sections_;
};

// Handle SHF_MERGE sections with fixed-size constant data.
Expand Down Expand Up @@ -303,6 +369,14 @@ class Output_merge_data : public Output_merge_base
void
do_print_merge_stats(const char* section_name);

// Set keeps-input-sections flag.
void
do_set_keeps_input_sections()
{
gold_assert(this->input_count_ == 0);
Output_merge_base::do_set_keeps_input_sections();
}

private:
// We build a hash table of the fixed-size constants. Each constant
// is stored as a pointer into the section data we are accumulating.
Expand Down Expand Up @@ -440,6 +514,14 @@ class Output_merge_string : public Output_merge_base
do_is_string()
{ return true; }

// Set keeps-input-sections flag.
void
do_set_keeps_input_sections()
{
gold_assert(this->input_count_ == 0);
Output_merge_base::do_set_keeps_input_sections();
}

private:
// The name of the string type, for stats.
const char*
Expand Down
Loading

0 comments on commit 0439c79

Please sign in to comment.