From 759f8f490e7670fb3ab9e72f5e7a195c02fe1431 Mon Sep 17 00:00:00 2001 From: hstk30-hw Date: Thu, 2 Jan 2025 23:43:59 +0800 Subject: [PATCH] [LLD]Fix lld crashes when linker script remove .dynsym section --- lld/ELF/SyntheticSections.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 {