diff --git a/lib/Target/EVM/MCTargetDesc/EVMAsmBackend.cpp b/lib/Target/EVM/MCTargetDesc/EVMAsmBackend.cpp index 3c19b1505619..dfa56b2ab00b 100644 --- a/lib/Target/EVM/MCTargetDesc/EVMAsmBackend.cpp +++ b/lib/Target/EVM/MCTargetDesc/EVMAsmBackend.cpp @@ -17,6 +17,10 @@ #include #include +#include "llvm/Support/Debug.h" +#include "llvm/MC/MCValue.h" +#define DEBUG_TYPE "evm_asmbackend" + using namespace llvm; namespace { @@ -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(&Data[Fixup.getOffset()],