Skip to content

Conversation

@hstk30-hw
Copy link
Contributor

Fix #88650

@llvmbot
Copy link
Member

llvmbot commented Jan 2, 2025

@llvm/pr-subscribers-lld

Author: None (hstk30-hw)

Changes

Fix #88650


Full diff: https://github.com/llvm/llvm-project/pull/121488.diff

1 Files Affected:

  • (modified) lld/ELF/SyntheticSections.cpp (+2-1)
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index baa7a083404fe7..8d98aad50a6ceb 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 {

@llvmbot
Copy link
Member

llvmbot commented Jan 2, 2025

@llvm/pr-subscribers-lld-elf

Author: None (hstk30-hw)

Changes

Fix #88650


Full diff: https://github.com/llvm/llvm-project/pull/121488.diff

1 Files Affected:

  • (modified) lld/ELF/SyntheticSections.cpp (+2-1)
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index baa7a083404fe7..8d98aad50a6ceb 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 {

@hstk30-hw hstk30-hw requested review from MaskRay and rui314 January 2, 2025 15:46
Copy link
Member

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that I did not look at #88650 in time. I will add a test case and fix the issue. It's important to mention in the commit message that it is for .gnu.version

@hstk30-hw hstk30-hw closed this Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ld.lld crashes on linker script removing .dynsym

3 participants