aboutsummaryrefslogtreecommitdiff
path: root/lib/MC/MCAssembler.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-03-10 00:58:25 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-03-10 00:58:25 +0000
commita015c1c876bb74a83cbbae06449056e0c6f0e9c9 (patch)
tree1706557373cac775780582feffc791063c660348 /lib/MC/MCAssembler.cpp
parent7c617b5e53987d786451dd668b5113f2e2b983f8 (diff)
MC/Mach-O: Use the SECTDIFF relocation type for (A - B + constant) where A is external.
- I'm not sure why, but this is what 'as' does. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98115 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCAssembler.cpp')
-rw-r--r--lib/MC/MCAssembler.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index cf02cc15c5..b44cd1e698 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -446,24 +446,27 @@ public:
// See <reloc.h>.
const MCSymbol *A = Target.getSymA();
- MCSymbolData *SD = SymbolMap.lookup(A);
+ MCSymbolData *A_SD = SymbolMap.lookup(A);
- if (!SD->getFragment())
+ if (!A_SD->getFragment())
llvm_report_error("symbol '" + A->getName() +
"' can not be undefined in a subtraction expression");
- uint32_t Value = SD->getFragment()->getAddress() + SD->getOffset();
+ uint32_t Value = A_SD->getFragment()->getAddress() + A_SD->getOffset();
uint32_t Value2 = 0;
if (const MCSymbol *B = Target.getSymB()) {
- MCSymbolData *SD = SymbolMap.lookup(B);
+ MCSymbolData *B_SD = SymbolMap.lookup(B);
- if (!SD->getFragment())
+ if (!B_SD->getFragment())
llvm_report_error("symbol '" + B->getName() +
"' can not be undefined in a subtraction expression");
- Type = RIT_LocalDifference;
- Value2 = SD->getFragment()->getAddress() + SD->getOffset();
+ // FIXME: This change of type based on the external bit doesn't make much
+ // sense, it seems to be redundant with the other information in the
+ // relocation entry.
+ Type = A_SD->isExternal() ? RIT_Difference : RIT_LocalDifference;
+ Value2 = B_SD->getFragment()->getAddress() + B_SD->getOffset();
}
// The value which goes in the fixup is current value of the expression.
@@ -488,7 +491,7 @@ public:
MRE.Word1 = Value;
Relocs.push_back(MRE);
- if (Type == RIT_LocalDifference) {
+ if (Type == RIT_Difference || Type == RIT_LocalDifference) {
MachRelocationEntry MRE;
MRE.Word0 = ((0 << 0) |
(RIT_Pair << 24) |