Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/lib/MC/MCAssembler.cpp
Show First 20 Lines • Show All 714 Lines • ▼ Show 20 Lines | MCAssembler::handleFixup(const MCAsmLayout &Layout, MCFragment &F, | ||||
uint64_t FixedValue; | uint64_t FixedValue; | ||||
bool WasForced; | bool WasForced; | ||||
bool IsResolved = evaluateFixup(Layout, Fixup, &F, Target, FixedValue, | bool IsResolved = evaluateFixup(Layout, Fixup, &F, Target, FixedValue, | ||||
WasForced); | WasForced); | ||||
if (!IsResolved) { | if (!IsResolved) { | ||||
// The fixup was unresolved, we need a relocation. Inform the object | // The fixup was unresolved, we need a relocation. Inform the object | ||||
// writer of the relocation, and give it an opportunity to adjust the | // writer of the relocation, and give it an opportunity to adjust the | ||||
// fixup value if need be. | // fixup value if need be. | ||||
getWriter().recordRelocation(*this, Layout, &F, Fixup, Target, FixedValue); | if (Target.getSymA() && Target.getSymB() && | ||||
getBackend().requiresDiffExpressionRelocations()) { | |||||
// The fixup represents the difference between two symbols, which the | |||||
// backend has indicated must be resolved at link time. Split up the fixup | |||||
// into two relocations, one for the add, and one for the sub, and emit | |||||
// both of these. The constant will be associated with the add half of the | |||||
// expression. | |||||
MCFixup FixupAdd = MCFixup::createAddFor(Fixup); | |||||
MCValue TargetAdd = | |||||
MCValue::get(Target.getSymA(), nullptr, Target.getConstant()); | |||||
getWriter().recordRelocation(*this, Layout, &F, FixupAdd, TargetAdd, | |||||
FixedValue); | |||||
MCFixup FixupSub = MCFixup::createSubFor(Fixup); | |||||
MCValue TargetSub = MCValue::get(Target.getSymB()); | |||||
getWriter().recordRelocation(*this, Layout, &F, FixupSub, TargetSub, | |||||
FixedValue); | |||||
} else { | |||||
getWriter().recordRelocation(*this, Layout, &F, Fixup, Target, | |||||
FixedValue); | |||||
} | |||||
} | } | ||||
return std::make_tuple(Target, FixedValue, IsResolved); | return std::make_tuple(Target, FixedValue, IsResolved); | ||||
} | } | ||||
void MCAssembler::layout(MCAsmLayout &Layout) { | void MCAssembler::layout(MCAsmLayout &Layout) { | ||||
assert(getBackendPtr() && "Expected assembler backend"); | assert(getBackendPtr() && "Expected assembler backend"); | ||||
DEBUG_WITH_TYPE("mc-dump", { | DEBUG_WITH_TYPE("mc-dump", { | ||||
errs() << "assembler backend - pre-layout\n--\n"; | errs() << "assembler backend - pre-layout\n--\n"; | ||||
▲ Show 20 Lines • Show All 312 Lines • Show Last 20 Lines |