Skip to content

Commit 6156813

Browse files
authored
Merge pull request #16267 from argotorg/record_linker_symbols
EVM instruction interpreter: record linker symbols
2 parents 34754a5 + 2086874 commit 6156813

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

test/tools/yulInterpreter/EVMInstructionInterpreter.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,8 @@ u256 EVMInstructionInterpreter::evalBuiltin(
534534
return u256(keccak256(arg)) & 0xfff;
535535
}
536536
}
537-
else if (fun == "datacopy")
537+
538+
if (fun == "datacopy")
538539
{
539540
// This is identical to codecopy.
540541
if (
@@ -550,11 +551,21 @@ u256 EVMInstructionInterpreter::evalBuiltin(
550551
);
551552
return 0;
552553
}
553-
else if (fun == "memoryguard")
554+
555+
if (fun == "memoryguard")
554556
return _evaluatedArguments.at(0);
555-
else
556-
yulAssert(false, "Unknown builtin: " + fun);
557-
return 0;
557+
558+
if (fun == "linkersymbol")
559+
{
560+
yulAssert(_arguments.size() == 1);
561+
yulAssert(std::holds_alternative<Literal>(_arguments[0]));
562+
std::string const placeholder = formatLiteral(std::get<Literal>(_arguments[0]));
563+
h256 const identifier(keccak256(placeholder));
564+
m_linkerSymbols.emplace(identifier, placeholder);
565+
return 0;
566+
}
567+
568+
yulAssert(false, "Unknown builtin: " + fun);
558569
}
559570

560571

test/tools/yulInterpreter/EVMInstructionInterpreter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ class EVMInstructionInterpreter
168168
InterpreterState& m_state;
169169
/// Flag to disable trace of instructions that write to memory.
170170
bool m_disableMemoryWriteInstructions;
171+
/// mapping from linker identifier (hash of literal) to original string representation, populated by linkersymbol
172+
/// calls
173+
std::map<util::h256, std::string> m_linkerSymbols;
174+
171175
public:
172176
/// Maximum length for range-based memory access operations.
173177
static constexpr unsigned s_maxRangeSize = 0xffff;

0 commit comments

Comments
 (0)