mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198590 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c8fd2c57c8
commit
ba7548302b
@ -720,6 +720,12 @@ void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
||||
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);
|
||||
|
||||
|
@ -648,14 +648,25 @@ void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user