forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 21
Function Layouts
Alan.Li edited this page Jan 9, 2020
·
4 revisions
EVM bytecode has a flat structure. It does not have explicit function entries, nor symbol tables. All executions starts from address 0x00
.
The function dispatcher
function (usually called main
function in some contexts) is always placed at the beginning of the generated binary bytecode. The dispatcher is responsible for:
- parse the call data and find the called function address in the jump table using the hash value provided in the call data.
- extract the call arguments, and push them on to stack.
- call the function address specified in the jump table.
Start of address
+----------------> +-------------------------+
| Function dispatcher |
| Jump Table |
| (Func1, |
| Func2, |
| Func3) |
+-------------------------+
| |
| Func1 |
| |
+-------------------------+
| |
| Func2 |
| |
+-------------------------+
| |
| Func3 |
| |
+-------------------------+