diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index baa7a083404fe..8d98aad50a6ce 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -3800,7 +3800,8 @@ VersionTableSection::VersionTableSection(Ctx &ctx) void VersionTableSection::finalizeContents() { // At the moment of june 2016 GNU docs does not mention that sh_link field // should be set, but Sun docs do. Also readelf relies on this field. - getParent()->link = getPartition(ctx).dynSymTab->getParent()->sectionIndex; + if (OutputSection *sec = getPartition(ctx).dynSymTab->getParent()) + getParent()->link = sec->sectionIndex; } size_t VersionTableSection::getSize() const {