diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 11f834514def..ff81852a4ca1 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -589,6 +589,8 @@ uint64_t EhFrameSection::getFdePc(uint8_t *Buf, size_t FdeOff, template void EhFrameSection::writeTo(uint8_t *Buf) { const endianness E = ELFT::TargetEndianness; + + // Write CIE and FDE records. for (CieRecord *Rec : CieRecords) { size_t CieOffset = Rec->Cie->OutputOff; writeCieFde(Buf + CieOffset, Rec->Cie->data()); @@ -603,6 +605,9 @@ template void EhFrameSection::writeTo(uint8_t *Buf) { } } + // Apply relocations. .eh_frame section contents are not contiguous + // in the output buffer, but relocateAlloc() still works because + // getOffset() takes care of discontiguous section pieces. for (EhInputSection *S : Sections) S->relocateAlloc(Buf, nullptr);