diff options
author | Ian Lance Taylor <ian@airs.com> | 2011-06-29 00:39:54 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2011-06-29 00:39:54 +0000 |
commit | aecf301fb9a06b3d05280260758bcd3e85d7413e (patch) | |
tree | 6abfce385d16ede9a1a234bb95054427b1e5a99c /gold/layout.cc | |
parent | d555a4fbf322f7818ea970c1d8108730d9f3f33e (diff) | |
download | gdb-aecf301fb9a06b3d05280260758bcd3e85d7413e.zip gdb-aecf301fb9a06b3d05280260758bcd3e85d7413e.tar.gz gdb-aecf301fb9a06b3d05280260758bcd3e85d7413e.tar.bz2 |
PR gold/12898
* layout.cc (Layout::segment_precedes): Don't crash if a linker
script create indistinguishable segments.
(Layout::set_segment_offsets): Use stable_sort when sorting
segments. Pass this to Compare_segments constructor.
* layout.h (class Layout): Make segment_precedes non-static.
(class Compare_segments): Change from struct to class. Add
layout_ field. Add constructor.
* script-sections.cc
(Script_sections::attach_sections_using_phdrs_clause): Rename
local orphan to is_orphan. Don't report failure to put empty
section in segment. On attachment failure, report name of
section, and attach to first PT_LOAD segment.
Diffstat (limited to 'gold/layout.cc')
-rw-r--r-- | gold/layout.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gold/layout.cc b/gold/layout.cc index bfb1a7e..0ef13af 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -2751,7 +2751,7 @@ Layout::create_incremental_info_sections(Symbol_table* symtab) // Return whether SEG1 should be before SEG2 in the output file. This // is based entirely on the segment type and flags. When this is -// called the segment addresses has normally not yet been set. +// called the segment addresses have normally not yet been set. bool Layout::segment_precedes(const Output_segment* seg1, @@ -2877,8 +2877,10 @@ Layout::segment_precedes(const Output_segment* seg1, return (flags1 & elfcpp::PF_R) == 0; // We shouldn't get here--we shouldn't create segments which we - // can't distinguish. - gold_unreachable(); + // can't distinguish. Unless of course we are using a weird linker + // script. + gold_assert(this->script_options_->saw_phdrs_clause()); + return false; } // Increase OFF so that it is congruent to ADDR modulo ABI_PAGESIZE. @@ -2902,9 +2904,11 @@ off_t Layout::set_segment_offsets(const Target* target, Output_segment* load_seg, unsigned int* pshndx) { - // Sort them into the final order. - std::sort(this->segment_list_.begin(), this->segment_list_.end(), - Layout::Compare_segments()); + // Sort them into the final order. We use a stable sort so that we + // don't randomize the order of indistinguishable segments created + // by linker scripts. + std::stable_sort(this->segment_list_.begin(), this->segment_list_.end(), + Layout::Compare_segments(this)); // Find the PT_LOAD segments, and set their addresses and offsets // and their section's addresses and offsets. |