Skip to content

Commit

Permalink
Issue #26: deploy.size fixed up with generated binary size.
Browse files Browse the repository at this point in the history
  • Loading branch information
lialan committed Nov 10, 2019
1 parent 68b4d36 commit 6271ae1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/Target/EVM/MCTargetDesc/EVMAsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include <cassert>
#include <cstdint>

#include "llvm/Support/Debug.h"
#include "llvm/MC/MCValue.h"
#define DEBUG_TYPE "evm_asmbackend"

using namespace llvm;

namespace {
Expand Down Expand Up @@ -77,6 +81,15 @@ void EVMAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
assert(Fixup.getKind() == FK_SecRel_2);
assert(Value <= 0xFFFF);

if (Target.getSymA()->getSymbol().getName() == "deploy.size") {
LLVM_DEBUG(
dbgs()
<< "Found \"deploy.size\" symbol, fixing it up with binary size: "
<< Data.size() << ".\n");
assert(Data.size() <= 0xFFFF);
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()],
Expand Down

0 comments on commit 6271ae1

Please sign in to comment.