gigahorse-toolchain
gigahorse-toolchain copied to clipboard
The fallback function is not separated.
I wanted to use gigahorse to identify the proxy call instructions in the fallback function, but found that the fallback functions of some contracts were not separated, and the logic of these fallback functions was in the function selector. This was a hindrance to what I wanted to do. The example contract below fits this scenario.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract ReceiveEther {
uint public a = 0;
uint public b = 0;
fallback() external payable {
a += 1;
emit Received(msg.sender, msg.value, a);
}
receive() external payable {
b += 1;
emit Received(msg.sender, msg.value, b);
}
}
The following is the decompilation result of the example contract.
function __function_selector__() public {
...
// The logic of fallback function.
Begin block 0x93
prev=[0x33, 0x37], succ=[0xa4]
=================================
0x94: v94(0x1) = CONST
0x96: v96(0x0) = CONST
0x9a: v9a = SLOAD v96(0x0)
0x9b: v9b(0xa4) = CONST
0xa0: va0(0x1af) = CONST
0xa3: va3_0 = CALLPRIVATE va0(0x1af), v9a, v94(0x1), v9b(0xa4)
...
}