[llvm] r198590 - MC: Fatally error if subtraction operand is bad
David Majnemer
david.majnemer at gmail.com
Tue Jan 21 12:44:39 PST 2014
Sorry, forgot to add the files. Fixed in r199765.
On Fri, Jan 17, 2014 at 9:09 AM, Rafael EspĂndola <
rafael.espindola at gmail.com> wrote:
> testcase?
>
> On 5 January 2014 23:39, David Majnemer <david.majnemer at gmail.com> wrote:
> > Author: majnemer
> > Date: Mon Jan 6 01:39:46 2014
> > New Revision: 198590
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=198590&view=rev
> > Log:
> > MC: Fatally error if subtraction operand is bad
> >
> > Instead of crashing, raise an error when a subtraction expression
> > involves an undefined symbol.
> >
> > This fixes PR18375.
> >
> > Modified:
> > llvm/trunk/lib/MC/ELFObjectWriter.cpp
> > llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
> >
> > Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=198590&r1=198589&r2=198590&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
> > +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Jan 6 01:39:46 2014
> > @@ -720,6 +720,12 @@ void ELFObjectWriter::RecordRelocation(c
> > MCSymbolData &SDB = Asm.getSymbolData(SymbolB);
> > IsPCRel = true;
> >
> > + if (!SDB.getFragment())
> > + Asm.getContext().FatalError(
> > + Fixup.getLoc(),
> > + Twine("symbol '") + SymbolB.getName() +
> > + "' can not be undefined in a subtraction expression");
> > +
> > // Offset of the symbol in the section
> > int64_t a = Layout.getSymbolOffset(&SDB);
> >
> >
> > Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=198590&r1=198589&r2=198590&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
> > +++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Mon Jan 6 01:39:46 2014
> > @@ -648,14 +648,25 @@ void WinCOFFObjectWriter::RecordRelocati
> >
> > COFFSection *coff_section = SectionMap[&SectionData->getSection()];
> > COFFSymbol *coff_symbol = SymbolMap[&A_SD.getSymbol()];
> > - const MCSymbolRefExpr *SymA = Target.getSymA();
> > const MCSymbolRefExpr *SymB = Target.getSymB();
> > - const bool CrossSection = SymB &&
> > - &SymA->getSymbol().getSection() != &SymB->getSymbol().getSection();
> > + bool CrossSection = false;
> >
> > - if (Target.getSymB()) {
> > - const MCSymbol *B = &Target.getSymB()->getSymbol();
> > + if (SymB) {
> > + const MCSymbol *B = &SymB->getSymbol();
> > MCSymbolData &B_SD = Asm.getSymbolData(*B);
> > + if (!B_SD.getFragment())
> > + Asm.getContext().FatalError(
> > + Fixup.getLoc(),
> > + Twine("symbol '") + B->getName() +
> > + "' can not be undefined in a subtraction expression");
> > +
> > + if (!A_SD.getFragment())
> > + Asm.getContext().FatalError(
> > + Fixup.getLoc(),
> > + Twine("symbol '") + Symbol.getName() +
> > + "' can not be undefined in a subtraction expression");
> > +
> > + CrossSection = &Symbol.getSection() != &B->getSection();
> >
> > // Offset of the symbol in the section
> > int64_t a = Layout.getSymbolOffset(&B_SD);
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140121/7e66ea27/attachment.html>
More information about the llvm-commits
mailing list