mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
MC/Mach-O: Update getSymbolAddress() to support evaluation of variables.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130522 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5ff919b324
commit
173aa9ce32
@ -121,6 +121,33 @@ private:
|
||||
}
|
||||
uint64_t getSymbolAddress(const MCSymbolData* SD,
|
||||
const MCAsmLayout &Layout) const {
|
||||
const MCSymbol &S = SD->getSymbol();
|
||||
|
||||
// If this is a variable, then recursively evaluate now.
|
||||
if (S.isVariable()) {
|
||||
MCValue Target;
|
||||
if (!S.getVariableValue()->EvaluateAsRelocatable(Target, Layout))
|
||||
report_fatal_error("unable to evaluate offset for variable '" +
|
||||
S.getName() + "'");
|
||||
|
||||
// Verify that any used symbols are defined.
|
||||
if (Target.getSymA() && Target.getSymA()->getSymbol().isUndefined())
|
||||
report_fatal_error("unable to evaluate offset to undefined symbol '" +
|
||||
Target.getSymA()->getSymbol().getName() + "'");
|
||||
if (Target.getSymB() && Target.getSymB()->getSymbol().isUndefined())
|
||||
report_fatal_error("unable to evaluate offset to undefined symbol '" +
|
||||
Target.getSymB()->getSymbol().getName() + "'");
|
||||
|
||||
uint64_t Address = Target.getConstant();
|
||||
if (Target.getSymA())
|
||||
Address += getSymbolAddress(&Layout.getAssembler().getSymbolData(
|
||||
Target.getSymA()->getSymbol()), Layout);
|
||||
if (Target.getSymB())
|
||||
Address += getSymbolAddress(&Layout.getAssembler().getSymbolData(
|
||||
Target.getSymB()->getSymbol()), Layout);
|
||||
return Address;
|
||||
}
|
||||
|
||||
return getSectionAddress(SD->getFragment()->getParent()) +
|
||||
Layout.getSymbolOffset(SD);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user