summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2015-06-25 15:17:23 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2015-06-25 15:17:23 +0000
commitedb876d52c907d6d9de60f0a4502c491485f7b2f (patch)
treeaa3495a39871cc5ee1b222bf396742435cf422ca /llvm/lib/CodeGen/AsmPrinter
parent549d405877de13141bcb73d7f93a86817143c476 (diff)
downloadbcm5719-llvm-edb876d52c907d6d9de60f0a4502c491485f7b2f.tar.gz
bcm5719-llvm-edb876d52c907d6d9de60f0a4502c491485f7b2f.zip
[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 llvm-svn: 240649
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 9e845e0e99b..28f5bc49dca 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -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:
OpenPOWER on IntegriCloud