diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.h b/llvm/tools/dsymutil/DwarfLinkerForBinary.h --- a/llvm/tools/dsymutil/DwarfLinkerForBinary.h +++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.h @@ -214,7 +214,7 @@ void copySwiftReflectionMetadata( const llvm::dsymutil::DebugMapObject *Obj, DwarfStreamer *Streamer, - const std::vector &SectionToOffsetInDwarf, + std::vector &SectionToOffsetInDwarf, std::vector &RelocationsToApply); diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp --- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp +++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp @@ -494,7 +494,7 @@ void DwarfLinkerForBinary::copySwiftReflectionMetadata( const llvm::dsymutil::DebugMapObject *Obj, DwarfStreamer *Streamer, - const std::vector &SectionToOffsetInDwarf, + std::vector &SectionToOffsetInDwarf, std::vector &RelocationsToApply) { using binaryformat::Swift5ReflectionSectionKind; @@ -539,6 +539,10 @@ collectRelocationsToApplyToSwiftReflectionSections( Section, *SectionContents, MO, SectionToOffsetInDwarf, Obj, RelocationsToApply); + // Update the section start with the current section's contribution, so + // the next section we copy from a different .o file points to the correct + // place. + SectionToOffsetInDwarf[SectionKind] += Section.getSize(); Streamer->emitSwiftReflectionSection(SectionKind, *SectionContents, Section.getAlignment(), Section.getSize());