@@ -1101,14 +1101,6 @@ static bool compareSegmentsByOffset(const Segment *A, const Segment *B) {
1101
1101
return A->Index < B->Index ;
1102
1102
}
1103
1103
1104
- static bool compareSegmentsByPAddr (const Segment *A, const Segment *B) {
1105
- if (A->PAddr < B->PAddr )
1106
- return true ;
1107
- if (A->PAddr > B->PAddr )
1108
- return false ;
1109
- return A->Index < B->Index ;
1110
- }
1111
-
1112
1104
void BasicELFBuilder::initFileHeader () {
1113
1105
Obj->Flags = 0x0 ;
1114
1106
Obj->Type = ET_REL;
@@ -2224,34 +2216,6 @@ Error BinaryWriter::write() {
2224
2216
}
2225
2217
2226
2218
Error BinaryWriter::finalize () {
2227
- // We need a temporary list of segments that has a special order to it
2228
- // so that we know that anytime ->ParentSegment is set that segment has
2229
- // already had it's offset properly set. We only want to consider the segments
2230
- // that will affect layout of allocated sections so we only add those.
2231
- std::vector<Segment *> OrderedSegments;
2232
- for (const SectionBase &Sec : Obj.allocSections ())
2233
- if (Sec.ParentSegment != nullptr )
2234
- OrderedSegments.push_back (Sec.ParentSegment );
2235
-
2236
- // For binary output, we're going to use physical addresses instead of
2237
- // virtual addresses, since a binary output is used for cases like ROM
2238
- // loading and physical addresses are intended for ROM loading.
2239
- // However, if no segment has a physical address, we'll fallback to using
2240
- // virtual addresses for all.
2241
- if (all_of (OrderedSegments,
2242
- [](const Segment *Seg) { return Seg->PAddr == 0 ; }))
2243
- for (Segment *Seg : OrderedSegments)
2244
- Seg->PAddr = Seg->VAddr ;
2245
-
2246
- llvm::stable_sort (OrderedSegments, compareSegmentsByPAddr);
2247
-
2248
- // Because we add a ParentSegment for each section we might have duplicate
2249
- // segments in OrderedSegments. If there were duplicates then layoutSegments
2250
- // would do very strange things.
2251
- auto End =
2252
- std::unique (std::begin (OrderedSegments), std::end (OrderedSegments));
2253
- OrderedSegments.erase (End, std::end (OrderedSegments));
2254
-
2255
2219
// Compute the section LMA based on its sh_offset and the containing segment's
2256
2220
// p_offset and p_paddr. Also compute the minimum LMA of all sections as
2257
2221
// MinAddr. In the output, the contents between address 0 and MinAddr will be
0 commit comments