diff --git a/gold/layout.cc b/gold/layout.cc index 07a359074e..bb13d7136e 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -3300,6 +3300,11 @@ bool Layout::segment_precedes(const Output_segment* seg1, const Output_segment* seg2) { + // In order to produce a stable ordering if we're called with the same pointer + // return false. + if (seg1 == seg2) + return false; + elfcpp::Elf_Word type1 = seg1->type(); elfcpp::Elf_Word type2 = seg2->type();