unsigned Index = 0;
unsigned IsExtern = 0;
unsigned Type = 0;
- const MCSymbolData *RelSymbol = nullptr;
+ const MCSymbol *RelSymbol = nullptr;
Value = Target.getConstant();
if (A->isTemporary())
A = &Writer->findAliasedSymbol(*A);
const MCSymbolData &A_SD = Asm.getSymbolData(*A);
- const MCSymbolData *A_Base = Asm.getAtom(&A_SD);
+ const MCSymbol *A_Base = Asm.getAtom(&A_SD);
const MCSymbol *B = &Target.getSymB()->getSymbol();
if (B->isTemporary())
B = &Writer->findAliasedSymbol(*B);
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
- const MCSymbolData *B_Base = Asm.getAtom(&B_SD);
+ const MCSymbol *B_Base = Asm.getAtom(&B_SD);
// Neither symbol can be modified.
if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None ||
Name + "' can not be undefined in a subtraction expression");
}
- Value += Writer->getSymbolAddress(&A_SD, Layout) -
- (!A_Base ? 0 : Writer->getSymbolAddress(A_Base, Layout));
- Value -= Writer->getSymbolAddress(&B_SD, Layout) -
- (!B_Base ? 0 : Writer->getSymbolAddress(B_Base, Layout));
+ Value +=
+ Writer->getSymbolAddress(&A_SD, Layout) -
+ (!A_Base ? 0 : Writer->getSymbolAddress(&A_Base->getData(), Layout));
+ Value -=
+ Writer->getSymbolAddress(&B_SD, Layout) -
+ (!B_Base ? 0 : Writer->getSymbolAddress(&B_Base->getData(), Layout));
if (!A_Base)
Index = A_SD.getFragment()->getParent()->getOrdinal() + 1;
MRE.r_word0 = FixupOffset;
MRE.r_word1 =
(Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
+ Writer->addRelocation(A_Base ? &A_Base->getData() : nullptr,
+ Fragment->getParent(), MRE);
if (B_Base)
RelSymbol = B_Base;
// non-local symbol).
if (RelSymbol) {
// Add the local offset, if needed.
- if (RelSymbol != &SD)
- Value +=
- Layout.getSymbolOffset(&SD) - Layout.getSymbolOffset(RelSymbol);
+ if (&RelSymbol->getData() != &SD)
+ Value += Layout.getSymbolOffset(&SD) -
+ Layout.getSymbolOffset(&RelSymbol->getData());
} else if (Symbol->isInSection() && !Symbol->isVariable()) {
// The index is the section ordinal (1-based).
Index = SD.getFragment()->getParent()->getOrdinal() + 1;
MRE.r_word0 = FixupOffset;
MRE.r_word1 = (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) |
(IsExtern << 27) | (Type << 28);
- Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
+ Writer->addRelocation(RelSymbol ? &RelSymbol->getData() : nullptr,
+ Fragment->getParent(), MRE);
}
bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,