[AsmPrinter] Fix crash in handleIndirectSymViaGOTPCRel

Check for symbols in MCValue before using them. Bail out early in case
they are null. This fixes PR23779.

Differential Revision: http://reviews.llvm.org/D10712

rdar://problem/21532830

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240649 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bruno Cardoso Lopes
2015-06-25 15:17:23 +00:00
parent 8eb93196be
commit 39b2e22f00
2 changed files with 18 additions and 2 deletions

View File

@@ -2086,8 +2086,12 @@ static void handleIndirectSymViaGOTPCRel(AsmPrinter &AP, const MCExpr **ME,
MCValue MV;
if (!(*ME)->evaluateAsRelocatable(MV, nullptr, nullptr) || MV.isAbsolute())
return;
const MCSymbolRefExpr *SymA = MV.getSymA();
if (!SymA)
return;
const MCSymbol *GOTEquivSym = &MV.getSymA()->getSymbol();
// Check that GOT equivalent symbol is cached.
const MCSymbol *GOTEquivSym = &SymA->getSymbol();
if (!AP.GlobalGOTEquivs.count(GOTEquivSym))
return;
@@ -2095,8 +2099,11 @@ static void handleIndirectSymViaGOTPCRel(AsmPrinter &AP, const MCExpr **ME,
if (!BaseGV)
return;
// Check for a valid base symbol
const MCSymbol *BaseSym = AP.getSymbol(BaseGV);
if (BaseSym != &MV.getSymB()->getSymbol())
const MCSymbolRefExpr *SymB = MV.getSymB();
if (!SymB || BaseSym != &SymB->getSymbol())
return;
// Make sure to match: