llvm.org GIT mirror llvm / 39b2e22
[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 Bruno Cardoso Lopes 5 years ago
2 changed file(s) with 19 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
20852085 MCValue MV;
20862086 if (!(*ME)->evaluateAsRelocatable(MV, nullptr, nullptr) || MV.isAbsolute())
20872087 return;
2088
2089 const MCSymbol *GOTEquivSym = &MV.getSymA()->getSymbol();
2088 const MCSymbolRefExpr *SymA = MV.getSymA();
2089 if (!SymA)
2090 return;
2091
2092 // Check that GOT equivalent symbol is cached.
2093 const MCSymbol *GOTEquivSym = &SymA->getSymbol();
20902094 if (!AP.GlobalGOTEquivs.count(GOTEquivSym))
20912095 return;
20922096
20942098 if (!BaseGV)
20952099 return;
20962100
2101 // Check for a valid base symbol
20972102 const MCSymbol *BaseSym = AP.getSymbol(BaseGV);
2098 if (BaseSym != &MV.getSymB()->getSymbol())
2103 const MCSymbolRefExpr *SymB = MV.getSymB();
2104
2105 if (!SymB || BaseSym != &SymB->getSymbol())
20992106 return;
21002107
21012108 // Make sure to match:
8383 define i32** @t1() {
8484 ret i32** @bargotequiv
8585 }
86
87 ; Do not crash when a pattern cannot be matched as a GOT equivalent
88
89 @a = external global i8
90 @b = internal unnamed_addr constant i8* @a
91
92 ; X86-LABEL: _c:
93 ; X86: .quad _b
94 @c = global i8** @b