diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp index 34781d56afd2..bf935659ed67 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -462,7 +462,7 @@ void Util::layoutSectionsInSegment(SegmentInfo *seg, uint64_t &addr) { seg->address = addr; for (SectionInfo *sect : seg->sections) { sect->address = alignTo(addr, sect->alignment); - addr += sect->size; + addr = sect->address + sect->size; } seg->size = llvm::RoundUpToAlignment(addr - seg->address,_context.pageSize()); }