MC/Mach-O: Add MCSymbolData::getAddress() utility.

llvm-svn: 98266
This commit is contained in:
Daniel Dunbar 2010-03-11 18:22:51 +00:00
parent 3a106e7029
commit 64b408b124
2 changed files with 9 additions and 4 deletions

View File

@ -507,6 +507,11 @@ public:
uint64_t getOffset() const { return Offset; }
void setOffset(uint64_t Value) { Offset = Value; }
uint64_t getAddress() const {
assert(getFragment() && "Invalid getAddress() on undefined symbol!");
return getFragment()->getAddress() + getOffset();
}
/// @}
/// @name Symbol Attributes
/// @{

View File

@ -400,7 +400,7 @@ public:
if (Symbol.isAbsolute()) {
llvm_unreachable("FIXME: Not yet implemented!");
} else {
Address = Data.getFragment()->getAddress() + Data.getOffset();
Address = Data.getAddress();
}
} else if (Data.isCommon()) {
// Common symbols are encoded with the size in the address
@ -452,7 +452,7 @@ public:
llvm_report_error("symbol '" + A->getName() +
"' can not be undefined in a subtraction expression");
uint32_t Value = A_SD->getFragment()->getAddress() + A_SD->getOffset();
uint32_t Value = A_SD->getAddress();
uint32_t Value2 = 0;
if (const MCSymbol *B = Target.getSymB()) {
@ -468,7 +468,7 @@ public:
// relocation types from the linkers point of view, this is done solely
// for pedantic compatibility with 'as'.
Type = A_SD->isExternal() ? RIT_Difference : RIT_LocalDifference;
Value2 = B_SD->getFragment()->getAddress() + B_SD->getOffset();
Value2 = B_SD->getAddress();
}
// The value which goes in the fixup is current value of the expression.
@ -561,7 +561,7 @@ public:
if (&*it == SD->getFragment()->getParent())
break;
assert(it != ie && "Unable to find section index!");
Value = SD->getFragment()->getAddress() + SD->getOffset();
Value = SD->getAddress();
}
Type = RIT_Vanilla;