MC: Improve error reporting for equated symbols and undefined labels
Currently, the code path is likely only reachable with super edge-case scenario, but will be more reachable with the upcoming parseAssignmentExpression improvement to address a pile of hacks.
This commit is contained in:
@@ -415,8 +415,8 @@ static bool getLabelOffset(const MCAssembler &Asm, const MCSymbol &S,
|
||||
bool ReportError, uint64_t &Val) {
|
||||
if (!S.getFragment()) {
|
||||
if (ReportError)
|
||||
report_fatal_error("unable to evaluate offset to undefined symbol '" +
|
||||
S.getName() + "'");
|
||||
reportFatalUsageError("cannot evaluate undefined symbol '" + S.getName() +
|
||||
"'");
|
||||
return false;
|
||||
}
|
||||
Val = Asm.getFragmentOffset(*S.getFragment()) + S.getOffset();
|
||||
@@ -431,8 +431,8 @@ static bool getSymbolOffsetImpl(const MCAssembler &Asm, const MCSymbol &S,
|
||||
// If SD is a variable, evaluate it.
|
||||
MCValue Target;
|
||||
if (!S.getVariableValue()->evaluateAsValue(Target, Asm))
|
||||
report_fatal_error("unable to evaluate offset for variable '" +
|
||||
S.getName() + "'");
|
||||
reportFatalUsageError("cannot evaluate equated symbol '" + S.getName() +
|
||||
"'");
|
||||
|
||||
uint64_t Offset = Target.getConstant();
|
||||
|
||||
|
||||
@@ -538,6 +538,8 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
|
||||
// Allows aliases with zero offset.
|
||||
if (Res.getConstant() == 0 && (!A || !B))
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// RUN: not --crash llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o %t.o 2> %t.err
|
||||
// RUN: not llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o %t.o 2> %t.err
|
||||
// RUN: FileCheck < %t.err %s
|
||||
|
||||
.data
|
||||
t0_a:
|
||||
t0_x = t0_a - t0_b
|
||||
// CHECK: unable to evaluate offset to undefined symbol 't0_b'
|
||||
// CHECK: cannot evaluate undefined symbol 't0_b'
|
||||
.long t0_x
|
||||
|
||||
Reference in New Issue
Block a user