#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCAssembler.h"
+#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixupKindInfo.h"
assert(W.OS.tell() - Start == Size);
}
+static bool isFixupTargetValid(const MCValue &Target) {
+ // Target is (LHS - RHS + cst).
+ // We don't support the form where LHS is null: -RHS + cst
+ if (!Target.getSymA() && Target.getSymB())
+ return false;
+ return true;
+}
+
void MachObjectWriter::recordRelocation(MCAssembler &Asm,
const MCAsmLayout &Layout,
const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) {
+ if (!isFixupTargetValid(Target)) {
+ Asm.getContext().reportError(Fixup.getLoc(),
+ "unsupported relocation expression");
+ return;
+ }
+
TargetObjectWriter->recordRelocation(this, Asm, Layout, Fragment, Fixup,
Target, FixedValue);
}