{
public:
Input_section_sort_entry()
- : input_section_(), index_(-1U), section_has_name_(false),
- section_name_()
+ : input_section_(), index_(-1U), section_name_()
{ }
Input_section_sort_entry(const Input_section& input_section,
unsigned int index,
- bool must_sort_attached_input_sections)
- : input_section_(input_section), index_(index),
- section_has_name_(input_section.is_input_section()
- || input_section.is_relaxed_input_section())
+ bool must_sort_attached_input_sections,
+ const char* output_section_name)
+ : input_section_(input_section), index_(index), section_name_()
{
- if (this->section_has_name_
+ if ((input_section.is_input_section()
+ || input_section.is_relaxed_input_section())
&& must_sort_attached_input_sections)
{
// This is only called single-threaded from Layout::finalize,
// Layout::layout if this becomes a speed problem.
this->section_name_ = obj->section_name(input_section.shndx());
}
+ else if (input_section.is_output_section_data()
+ && must_sort_attached_input_sections)
+ {
+ // For linker-generated sections, use the output section name.
+ this->section_name_.assign(output_section_name);
+ }
}
// Return the Input_section.
return this->index_;
}
- // Whether there is a section name.
- bool
- section_has_name() const
- { return this->section_has_name_; }
-
// The section name.
const std::string&
section_name() const
{
- gold_assert(this->section_has_name_);
return this->section_name_;
}
bool
has_priority() const
{
- gold_assert(this->section_has_name_);
return this->section_name_.find('.', 1) != std::string::npos;
}
unsigned int
get_priority() const
{
- gold_assert(this->section_has_name_);
bool is_ctors;
if (is_prefix_of(".ctors.", this->section_name_.c_str())
|| is_prefix_of(".dtors.", this->section_name_.c_str()))
Input_section input_section_;
// The index of this Input_section in the original list.
unsigned int index_;
- // Whether this Input_section has a section name--it won't if this
- // is some random Output_section_data.
- bool section_has_name_;
// The section name if there is one.
std::string section_name_;
};
return s1.index() < s2.index();
}
- // We sort all the sections with no names to the end.
- if (!s1.section_has_name() || !s2.section_has_name())
- {
- if (s1.section_has_name())
- return true;
- if (s2.section_has_name())
- return false;
- return s1.index() < s2.index();
- }
-
// A section with a priority follows a section without a priority.
bool s1_has_priority = s1.has_priority();
bool s2_has_priority = s2.has_priority();
const Output_section::Input_section_sort_entry& s1,
const Output_section::Input_section_sort_entry& s2) const
{
- // We sort all the sections with no names to the end.
- if (!s1.section_has_name() || !s2.section_has_name())
- {
- if (s1.section_has_name())
- return true;
- if (s2.section_has_name())
- return false;
- return s1.index() < s2.index();
- }
-
// A section without a priority follows a section with a priority.
// This is the reverse of .ctors and .dtors sections.
bool s1_has_priority = s1.has_priority();
const Output_section::Input_section_sort_entry& s1,
const Output_section::Input_section_sort_entry& s2) const
{
- // We sort all the sections with no names to the end.
- if (!s1.section_has_name() || !s2.section_has_name())
- {
- if (s1.section_has_name())
- return true;
- if (s2.section_has_name())
- return false;
- return s1.index() < s2.index();
- }
-
// Some input section names have special ordering requirements.
int o1 = Layout::special_ordering_of_input_section(s1.section_name().c_str());
int o2 = Layout::special_ordering_of_input_section(s2.section_name().c_str());
const Output_section::Input_section_sort_entry& s1,
const Output_section::Input_section_sort_entry& s2) const
{
- // We sort all the sections with no names to the end.
- if (!s1.section_has_name() || !s2.section_has_name())
- {
- if (s1.section_has_name())
- return true;
- if (s2.section_has_name())
- return false;
- return s1.index() < s2.index();
- }
-
// We sort by name.
int compare = s1.section_name().compare(s2.section_name());
if (compare != 0)
p != this->input_sections_.end();
++p, ++i)
sort_list.push_back(Input_section_sort_entry(*p, i,
- this->must_sort_attached_input_sections()));
+ this->must_sort_attached_input_sections(),
+ this->name()));
// Sort the input sections.
if (this->must_sort_attached_input_sections())