Skip to content

Commit

Permalink
Issue #27: Adding an option to let us able to artifically change offs…
Browse files Browse the repository at this point in the history
…et starting location.
  • Loading branch information
lialan committed Nov 18, 2019
1 parent d13020b commit 419d90c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/Target/EVM/MCTargetDesc/EVMAsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
#include <cassert>
#include <cstdint>

#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<unsigned> DebugOffset("evm-debug-offset", cl::init(0),
cl::Hidden, cl::desc("Artifical offset for relocation"));

namespace {

class EVMAsmBackend : public MCAsmBackend {
Expand Down Expand Up @@ -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<uint16_t>(&Data[Fixup.getOffset()],
if (DebugOffset != 0) {
LLVM_DEBUG(dbgs() << "Artifically adding " << DebugOffset
<< " to all Fixup relocation.\n";);
}

support::endian::write<uint16_t>(&Data[Fixup.getOffset() + DebugOffset],
static_cast<uint16_t>(Value), Endian);
}

Expand Down

0 comments on commit 419d90c

Please sign in to comment.