* script-sections.cc (Sort_output_sections::script_compare):
Rename from is_before, change return type. (Sort_output_sections::operator()): Adjust accordingly.
This commit is contained in:
parent
20453c56b1
commit
fd7a005d9d
|
@ -1,3 +1,9 @@
|
||||||
|
2011-03-14 Ian Lance Taylor <iant@google.com>
|
||||||
|
|
||||||
|
* script-sections.cc (Sort_output_sections::script_compare):
|
||||||
|
Rename from is_before, change return type.
|
||||||
|
(Sort_output_sections::operator()): Adjust accordingly.
|
||||||
|
|
||||||
2011-03-11 Jeffrey Yasskin <jyasskin@google.com>
|
2011-03-11 Jeffrey Yasskin <jyasskin@google.com>
|
||||||
|
|
||||||
PR gold/12572
|
PR gold/12572
|
||||||
|
|
|
@ -3561,8 +3561,8 @@ class Sort_output_sections
|
||||||
operator()(const Output_section* os1, const Output_section* os2) const;
|
operator()(const Output_section* os1, const Output_section* os2) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool
|
int
|
||||||
is_before(const Output_section* os1, const Output_section* os2) const;
|
script_compare(const Output_section* os1, const Output_section* os2) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Script_sections::Sections_elements* elements_;
|
const Script_sections::Sections_elements* elements_;
|
||||||
|
@ -3586,6 +3586,12 @@ Sort_output_sections::operator()(const Output_section* os1,
|
||||||
if (os1->address() != os2->address())
|
if (os1->address() != os2->address())
|
||||||
return os1->address() < os2->address();
|
return os1->address() < os2->address();
|
||||||
|
|
||||||
|
// If the linker script says which of these sections is first, go
|
||||||
|
// with what it says.
|
||||||
|
int i = this->script_compare(os1, os2);
|
||||||
|
if (i != 0)
|
||||||
|
return i < 0;
|
||||||
|
|
||||||
// Sort PROGBITS before NOBITS.
|
// Sort PROGBITS before NOBITS.
|
||||||
bool nobits1 = os1->type() == elfcpp::SHT_NOBITS;
|
bool nobits1 = os1->type() == elfcpp::SHT_NOBITS;
|
||||||
bool nobits2 = os2->type() == elfcpp::SHT_NOBITS;
|
bool nobits2 = os2->type() == elfcpp::SHT_NOBITS;
|
||||||
|
@ -3605,37 +3611,45 @@ Sort_output_sections::operator()(const Output_section* os1,
|
||||||
if (!os1->is_noload() && os2->is_noload())
|
if (!os1->is_noload() && os2->is_noload())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// The sections have the same address. Check the section positions
|
// The sections seem practically identical. Sort by name to get a
|
||||||
// in accordance with the linker script.
|
// stable sort.
|
||||||
return this->is_before(os1, os2);
|
return os1->name() < os2->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if OS1 comes before OS2 in ELEMENTS_. This ensures
|
// Return -1 if OS1 comes before OS2 in ELEMENTS_, 1 if comes after, 0
|
||||||
// that we keep empty sections in the order in which they appear in a
|
// if either OS1 or OS2 is not mentioned. This ensures that we keep
|
||||||
// linker script.
|
// empty sections in the order in which they appear in a linker
|
||||||
|
// script.
|
||||||
|
|
||||||
bool
|
int
|
||||||
Sort_output_sections::is_before(const Output_section* os1,
|
Sort_output_sections::script_compare(const Output_section* os1,
|
||||||
const Output_section* os2) const
|
const Output_section* os2) const
|
||||||
{
|
{
|
||||||
if (this->elements_ == NULL)
|
if (this->elements_ == NULL)
|
||||||
return false;
|
return 0;
|
||||||
|
|
||||||
|
bool found_os1 = false;
|
||||||
|
bool found_os2 = false;
|
||||||
for (Script_sections::Sections_elements::const_iterator
|
for (Script_sections::Sections_elements::const_iterator
|
||||||
p = this->elements_->begin();
|
p = this->elements_->begin();
|
||||||
p != this->elements_->end();
|
p != this->elements_->end();
|
||||||
++p)
|
++p)
|
||||||
{
|
{
|
||||||
if (os1 == (*p)->get_output_section())
|
if (os2 == (*p)->get_output_section())
|
||||||
{
|
{
|
||||||
for (++p; p != this->elements_->end(); ++p)
|
if (found_os1)
|
||||||
if (os2 == (*p)->get_output_section())
|
return -1;
|
||||||
return true;
|
found_os2 = true;
|
||||||
break;
|
}
|
||||||
|
else if (os1 == (*p)->get_output_section())
|
||||||
|
{
|
||||||
|
if (found_os2)
|
||||||
|
return 1;
|
||||||
|
found_os1 = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return whether OS is a BSS section. This is a SHT_NOBITS section.
|
// Return whether OS is a BSS section. This is a SHT_NOBITS section.
|
||||||
|
|
Loading…
Reference in New Issue