Line 3934... |
Line 3934... |
++pnext;
|
++pnext;
|
}
|
}
|
|
|
saw_tls = true;
|
saw_tls = true;
|
}
|
}
|
|
|
|
// If we are making a shared library, and we see a section named
|
|
// .interp then put the .interp section in a PT_INTERP segment.
|
|
// This is for GNU ld compatibility.
|
|
if (strcmp((*p)->name(), ".interp") == 0)
|
|
{
|
|
elfcpp::Elf_Word seg_flags =
|
|
Layout::section_flags_to_segment((*p)->flags());
|
|
Output_segment* oseg = layout->make_output_segment(elfcpp::PT_INTERP,
|
|
seg_flags);
|
|
oseg->add_output_section_to_nonload(*p, seg_flags);
|
|
}
|
}
|
}
|
}
|
}
|
|
|
// Add a program header. The PHDRS clause is syntactically distinct
|
// Add a program header. The PHDRS clause is syntactically distinct
|
// from the SECTIONS clause, but we implement it with the SECTIONS
|
// from the SECTIONS clause, but we implement it with the SECTIONS
|
Line 4036... |
Line 4048... |
bool load_segments_only = false;
|
bool load_segments_only = false;
|
for (Sections_elements::const_iterator p = this->sections_elements_->begin();
|
for (Sections_elements::const_iterator p = this->sections_elements_->begin();
|
p != this->sections_elements_->end();
|
p != this->sections_elements_->end();
|
++p)
|
++p)
|
{
|
{
|
bool orphan;
|
bool is_orphan;
|
String_list* old_phdr_names = phdr_names;
|
String_list* old_phdr_names = phdr_names;
|
Output_section* os = (*p)->allocate_to_segment(&phdr_names, &orphan);
|
Output_section* os = (*p)->allocate_to_segment(&phdr_names, &is_orphan);
|
if (os == NULL)
|
if (os == NULL)
|
continue;
|
continue;
|
|
|
|
elfcpp::Elf_Word seg_flags =
|
|
Layout::section_flags_to_segment(os->flags());
|
|
|
if (phdr_names == NULL)
|
if (phdr_names == NULL)
|
{
|
{
|
gold_error(_("allocated section not in any segment"));
|
// Don't worry about empty orphan sections.
|
|
if (is_orphan && os->current_data_size() > 0)
|
|
gold_error(_("allocated section %s not in any segment"),
|
|
os->name());
|
|
|
|
// To avoid later crashes drop this section into the first
|
|
// PT_LOAD segment.
|
|
for (Phdrs_elements::const_iterator ppe =
|
|
this->phdrs_elements_->begin();
|
|
ppe != this->phdrs_elements_->end();
|
|
++ppe)
|
|
{
|
|
Output_segment* oseg = (*ppe)->segment();
|
|
if (oseg->type() == elfcpp::PT_LOAD)
|
|
{
|
|
oseg->add_output_section_to_load(layout, os, seg_flags);
|
|
break;
|
|
}
|
|
}
|
|
|
continue;
|
continue;
|
}
|
}
|
|
|
// We see a list of segments names. Disable PT_LOAD segment only
|
// We see a list of segments names. Disable PT_LOAD segment only
|
// filtering.
|
// filtering.
|
Line 4059... |
Line 4093... |
// mentioned in the linker script--then it should not inherit
|
// mentioned in the linker script--then it should not inherit
|
// any segment type other than PT_LOAD. Otherwise, e.g., the
|
// any segment type other than PT_LOAD. Otherwise, e.g., the
|
// PT_INTERP segment will pick up following orphan sections,
|
// PT_INTERP segment will pick up following orphan sections,
|
// which does not make sense. If this is not an orphan section,
|
// which does not make sense. If this is not an orphan section,
|
// we trust the linker script.
|
// we trust the linker script.
|
if (orphan)
|
if (is_orphan)
|
{
|
{
|
// Enable PT_LOAD segments only filtering until we see another
|
// Enable PT_LOAD segments only filtering until we see another
|
// list of segment names.
|
// list of segment names.
|
load_segments_only = true;
|
load_segments_only = true;
|
}
|
}
|
Line 4080... |
Line 4114... |
{
|
{
|
if (load_segments_only
|
if (load_segments_only
|
&& r->second->type() != elfcpp::PT_LOAD)
|
&& r->second->type() != elfcpp::PT_LOAD)
|
continue;
|
continue;
|
|
|
elfcpp::Elf_Word seg_flags =
|
|
Layout::section_flags_to_segment(os->flags());
|
|
|
|
if (r->second->type() != elfcpp::PT_LOAD)
|
if (r->second->type() != elfcpp::PT_LOAD)
|
r->second->add_output_section_to_nonload(os, seg_flags);
|
r->second->add_output_section_to_nonload(os, seg_flags);
|
else
|
else
|
{
|
{
|
r->second->add_output_section_to_load(layout, os, seg_flags);
|
r->second->add_output_section_to_load(layout, os, seg_flags);
|