Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -536,6 +536,9 @@ } } + if (this->VersymSec && !this->Symtab) + error("SHT_GNU_versym should be associated with symbol table"); + this->initStringTable(); // DSOs are identified by soname, and they usually contain Index: test/ELF/invalid/verdef-no-symtab.s =================================================================== --- test/ELF/invalid/verdef-no-symtab.s +++ test/ELF/invalid/verdef-no-symtab.s @@ -0,0 +1,7 @@ +# REQUIRES: x86 + +## Version symbol section (SHT_GNU_versym) should be associated +## with symbol table. verdef-no-symtab.elf has SHT_GNU_versym section, +## but does not have .dynsym +# RUN: not ld.lld %S/Inputs/verdef-no-symtab.elf -o %t 2>&1 | FileCheck %s +# CHECK: SHT_GNU_versym should be associated with symbol table