Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The fallback function is not separated. #128

Open
kongqp opened this issue Mar 4, 2024 · 0 comments
Open

The fallback function is not separated. #128

kongqp opened this issue Mar 4, 2024 · 0 comments
Assignees

Comments

@kongqp
Copy link

kongqp commented Mar 4, 2024

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)
    ...
}
@sifislag sifislag self-assigned this Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants