-
Notifications
You must be signed in to change notification settings - Fork 23
Description
go-ethereum provides a decent interface for executing EVM code. We could use it for our use of testing.
We will start with non-blockchain interacting correctness checking. In such cases, we compile a single function and feed it into evm and execute.
The compiled function takes a certain amount of arguments as input, plus the return address at the bottom of the stack. When function finishes executing, the last instruction will jump to the return address.
So to test the result and make sure the function returns correctly, we should push a return address onto stack before anything else. But that would alter the relocation offset.
One way to do this is to add an option to specify an offset to the relocation offset. Let’s say when we are fixing up a jump destination, and we have determined location at 0xabcd, and if we have specified -debug-offset-offset=2, then the 0xabcd will become 0xabcd + 2 = 0xabcf. By doing this we can acknowledge the prefix offsets added to test cases.