Skip to content

Commit

Permalink
lld: fix crash linking the FreeBSD/arm64 kernel
Browse files Browse the repository at this point in the history
As reported by dim@ in LLVM PR33821 lld was crashing while linking the
FreeBSD/arm64 kernel, with a null linker script command section:

  1337      Cmd->Sec->addSection(Sentinel);
  (gdb) p Cmd->Sec
  $4 = (lld::elf::OutputSection *) 0x0

Under discussion upstream, https://llvm.org/pr33821.  Not yet certain if
this fix is correct, but it does prevent the crash and the LLD test
suite passes with the change.
  • Loading branch information
emaste committed Jul 18, 2017
1 parent e608585 commit 1d3dfff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/llvm/tools/lld/ELF/Writer.cpp
Expand Up @@ -1331,7 +1331,7 @@ template <class ELFT> void Writer<ELFT>::addPredefinedSections() {
// ARM ABI requires .ARM.exidx to be terminated by some piece of data.
// We have the terminater synthetic section class. Add that at the end.
OutputSectionCommand *Cmd = findSectionCommand(".ARM.exidx");
if (!Cmd || Cmd->Commands.empty() || Config->Relocatable)
if (!Cmd || !Cmd->Sec || Cmd->Commands.empty() || Config->Relocatable)
return;

auto *Sentinel = make<ARMExidxSentinelSection>();
Expand Down

0 comments on commit 1d3dfff

Please sign in to comment.