[llvm-commits] [llvm] r98266 - in /llvm/trunk: include/llvm/MC/MCAssembler.h lib/MC/MCAssembler.cpp
Daniel Dunbar
daniel at zuster.org
Thu Mar 11 10:22:51 PST 2010
Author: ddunbar
Date: Thu Mar 11 12:22:51 2010
New Revision: 98266
URL: http://llvm.org/viewvc/llvm-project?rev=98266&view=rev
Log:
MC/Mach-O: Add MCSymbolData::getAddress() utility.
Modified:
llvm/trunk/include/llvm/MC/MCAssembler.h
llvm/trunk/lib/MC/MCAssembler.cpp
Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=98266&r1=98265&r2=98266&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Thu Mar 11 12:22:51 2010
@@ -507,6 +507,11 @@
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
/// @{
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=98266&r1=98265&r2=98266&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Thu Mar 11 12:22:51 2010
@@ -400,7 +400,7 @@
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 @@
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 @@
// 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 @@
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;
More information about the llvm-commits
mailing list