diff --git a/lib/Target/EVM/MCTargetDesc/EVMAsmBackend.cpp b/lib/Target/EVM/MCTargetDesc/EVMAsmBackend.cpp index dfa56b2ab00bd..8b0e6057fbcbb 100644 --- a/lib/Target/EVM/MCTargetDesc/EVMAsmBackend.cpp +++ b/lib/Target/EVM/MCTargetDesc/EVMAsmBackend.cpp @@ -17,12 +17,16 @@ #include #include +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/MC/MCValue.h" #define DEBUG_TYPE "evm_asmbackend" using namespace llvm; +static cl::opt DebugOffset("evm-debug-offset", cl::init(0), + cl::Hidden, cl::desc("Artifical offset for relocation")); + namespace { class EVMAsmBackend : public MCAsmBackend { @@ -90,9 +94,12 @@ void EVMAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, Value = Data.size(); } - // The offset points to the beginning of the instruction, so we have to - // + 1 - support::endian::write(&Data[Fixup.getOffset()], + if (DebugOffset != 0) { + LLVM_DEBUG(dbgs() << "Artifically adding " << DebugOffset + << " to all Fixup relocation.\n";); + } + + support::endian::write(&Data[Fixup.getOffset() + DebugOffset], static_cast(Value), Endian); }