* layout.cc (Layout::set_segment_offsets): Align the file offset

to the segment aligment for -N or -n with no load segment.
	* output.cc (Output_segment::add_output_section): Don't crash if
	the first section is a TLS section.
	(Output_segment::set_section_list_addresses): Print an error
	message if the address moves backward in a linker script.
	* script-sections.cc
	(Output_section_element_input::set_section_addresses): Don't
	increase *dot_value for a SHF_TLS/SHT_NOBITS section.
	(Orphan_output_section::set_section_addresses): Likewise.
This commit is contained in:
Ian Lance Taylor
2009-10-16 05:00:29 +00:00
parent 6b3159bb46
commit 661be1e21e
4 changed files with 99 additions and 36 deletions

View File

@ -1372,6 +1372,7 @@ Output_section_element_input::set_section_addresses(
// sections are otherwise equal. Add each input section to the
// output section.
uint64_t dot = *dot_value;
for (size_t i = 0; i < input_pattern_count; ++i)
{
if (matching_sections[i].empty())
@ -1396,12 +1397,12 @@ Output_section_element_input::set_section_addresses(
if (this_subalign < subalign)
this_subalign = subalign;
uint64_t address = align_address(*dot_value, this_subalign);
uint64_t address = align_address(dot, this_subalign);
if (address > *dot_value && !fill->empty())
if (address > dot && !fill->empty())
{
section_size_type length =
convert_to_section_size_type(address - *dot_value);
convert_to_section_size_type(address - dot);
std::string this_fill = this->get_fill_string(fill, length);
Output_section_data* posd = new Output_data_const(this_fill, 0);
output_section->add_output_section_data(posd);
@ -1412,10 +1413,17 @@ Output_section_element_input::set_section_addresses(
p->size(),
this_subalign);
*dot_value = address + p->size();
dot = address + p->size();
}
}
// An SHF_TLS/SHT_NOBITS section does not take up any
// address space.
if (output_section == NULL
|| (output_section->flags() & elfcpp::SHF_TLS) == 0
|| output_section->type() != elfcpp::SHT_NOBITS)
*dot_value = dot;
this->final_dot_value_ = *dot_value;
this->final_dot_section_ = *dot_section;
}
@ -2311,12 +2319,18 @@ Orphan_output_section::set_section_addresses(Symbol_table*, Layout*,
address += size;
}
if (!have_load_address)
*load_address = address;
else
*load_address += address - *dot_value;
// An SHF_TLS/SHT_NOBITS section does not take up any address space.
if (this->os_ == NULL
|| (this->os_->flags() & elfcpp::SHF_TLS) == 0
|| this->os_->type() != elfcpp::SHT_NOBITS)
{
if (!have_load_address)
*load_address = address;
else
*load_address += address - *dot_value;
*dot_value = address;
*dot_value = address;
}
}
// Get the list of segments to use for an allocated section when using