diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 64f688e1a964..7e3e1bbbb8a7 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -78,6 +78,8 @@ ELFData::getSymbolsHelper(bool Local) { } template void ELFData::initStringTable() { + if (!Symtab) + return; ErrorOr StringTableOrErr = ELFObj.getStringTableForSymtab(*Symtab); error(StringTableOrErr.getError()); StringTable = *StringTableOrErr; diff --git a/lld/test/elf2/Inputs/no-symtab.o b/lld/test/elf2/Inputs/no-symtab.o new file mode 100644 index 000000000000..7368ba280d79 Binary files /dev/null and b/lld/test/elf2/Inputs/no-symtab.o differ diff --git a/lld/test/elf2/no-symtab.s b/lld/test/elf2/no-symtab.s new file mode 100644 index 000000000000..47a5f0ad6180 --- /dev/null +++ b/lld/test/elf2/no-symtab.s @@ -0,0 +1,4 @@ +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +// RUN: lld -flavor gnu2 %t.o %p/Inputs/no-symtab.o -o %t +.global _start +_start: