aboutsummaryrefslogtreecommitdiff
path: root/gold/layout.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2010-01-06 22:37:18 +0000
committerIan Lance Taylor <ian@airs.com>2010-01-06 22:37:18 +0000
commita192ba05083cb72a218e7c7722f30eadb9973833 (patch)
treefd02bf5a6447fb6c1ec2ba8655779f583ee8892e /gold/layout.cc
parentd5551862dfa8c22746642b9a7f66b076557a0325 (diff)
downloadgdb-a192ba05083cb72a218e7c7722f30eadb9973833.zip
gdb-a192ba05083cb72a218e7c7722f30eadb9973833.tar.gz
gdb-a192ba05083cb72a218e7c7722f30eadb9973833.tar.bz2
PR 10980
* options.cc (General_options::parse_section_start): New function. (General_options::section_start): New function. (General_options::General_options): Initialize all members. * options.h: Include <map> (class General_options): Add --section-start. Add section_starts_ member. * layout.cc (Layout::attach_allocated_section_to_segment): If --section-start was used, set the address of the segment. Remove local sort_sections. (Layout::relaxation_loop_body): If the address of the load segment has been set by --section-start, don't use it. * output.h (Output_segment::update_flags_for_output_section): New function. * output.cc (Output_segment::add_output_section): Call update_flags_for_output_section.
Diffstat (limited to 'gold/layout.cc')
-rw-r--r--gold/layout.cc29
1 files changed, 26 insertions, 3 deletions
diff --git a/gold/layout.cc b/gold/layout.cc
index c633d7b..13c7f7e 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -1025,7 +1025,9 @@ Layout::attach_allocated_section_to_segment(Output_section* os)
elfcpp::Elf_Word seg_flags = Layout::section_flags_to_segment(flags);
- bool sort_sections = !this->script_options_->saw_sections_clause();
+ // Check for --section-start.
+ uint64_t addr;
+ bool is_address_set = parameters->options().section_start(os->name(), &addr);
// In general the only thing we really care about for PT_LOAD
// segments is whether or not they are writable, so that is how we
@@ -1054,7 +1056,18 @@ Layout::attach_allocated_section_to_segment(Output_section* os)
if (os->is_large_data_section() && !(*p)->is_large_data_segment())
continue;
- (*p)->add_output_section(os, seg_flags, sort_sections);
+ if (is_address_set)
+ {
+ if ((*p)->are_addresses_set())
+ continue;
+
+ (*p)->add_initial_output_data(os);
+ (*p)->update_flags_for_output_section(seg_flags);
+ (*p)->set_addresses(addr, addr);
+ break;
+ }
+
+ (*p)->add_output_section(os, seg_flags, true);
break;
}
@@ -1064,7 +1077,9 @@ Layout::attach_allocated_section_to_segment(Output_section* os)
seg_flags);
if (os->is_large_data_section())
oseg->set_is_large_data_segment();
- oseg->add_output_section(os, seg_flags, sort_sections);
+ oseg->add_output_section(os, seg_flags, true);
+ if (is_address_set)
+ oseg->set_addresses(addr, addr);
}
// If we see a loadable SHT_NOTE section, we create a PT_NOTE
@@ -1492,6 +1507,14 @@ Layout::relaxation_loop_body(
|| load_seg != NULL
|| this->script_options_->saw_sections_clause());
+ // If the address of the load segment we found has been set by
+ // --section-start rather than by a script, then we don't want to
+ // use it for the file and segment headers.
+ if (load_seg != NULL
+ && load_seg->are_addresses_set()
+ && !this->script_options_->saw_sections_clause())
+ load_seg = NULL;
+
// Lay out the segment headers.
if (!parameters->options().relocatable())
{