When a relocation to an undefined symbol is an R_X86_64_PC32, an input
authorSterling Augustine <saugustine@google.com>
Tue, 4 Sep 2018 21:06:59 +0000 (21:06 +0000)
committerSterling Augustine <saugustine@google.com>
Tue, 4 Sep 2018 21:06:59 +0000 (21:06 +0000)
section will not have an input file. Don't crash under those circumstances.

Neither clang nor llvm-mc generates R_X86_64_PC32 relocations due to
https://reviews.llvm.org/D43383, which makes it hard to write a test case.
However, gcc does generate such relocations. I want to get a fix in now,
but will figure out a way to actually exercise this code path as soon
as I can.

llvm-svn: 341408

lld/ELF/InputSection.cpp

index 9c41097..a6b45e2 100644 (file)
@@ -947,7 +947,7 @@ void InputSectionBase::adjustSplitStackFunctionPrologues(uint8_t *Buf,
     // conservative.
     if (Defined *D = dyn_cast<Defined>(Rel.Sym))
       if (InputSection *IS = cast_or_null<InputSection>(D->Section))
-        if (!IS || IS->getFile<ELFT>()->SplitStack)
+        if (!IS || !IS->getFile<ELFT>() || IS->getFile<ELFT>()->SplitStack)
           continue;
 
     if (enclosingPrologueAttempted(Rel.Offset, Prologues))