Index: tools/llvm-objcopy/Object.cpp =================================================================== --- tools/llvm-objcopy/Object.cpp +++ tools/llvm-objcopy/Object.cpp @@ -911,8 +911,10 @@ // so that we know that anytime ->ParentSegment is set that segment has // already had its offset properly set. std::vector OrderedSegments; - for (auto &Segment : Obj.segments()) - OrderedSegments.push_back(&Segment); + for (auto &Segment : Obj.segments()) { + if (Segment.FileSize > 0) + OrderedSegments.push_back(&Segment); + } OrderSegments(OrderedSegments); // The size of ELF + program headers will not change so it is ok to assume // that the first offset of the first segment is a good place to start