disasm: Return values
See original GitHub issueUnfortunately selector hashes don’t include the return value, so none of the 4byte databases include return types.
Questions:
- How do we detect whether a function has a return value at all?
- If it does, can we do anything to guess the type or size?
What we have:
- Function selectors with instruction pointers
- Boundaries for selectors’ functions (they seem to be assembled contiguously based on a few anecdotal examinations).
Updated challenges:
- Old Solidity (e.g. WETH compiled with 0.4.x) assembles functions with simple return macros, so those are fairly easily detectable by looking back for RETURNfrom the end of each selector function’s boundary.
- Modern Solidity assembles returns through chains of helper branches that prepare the data. I can’t think of a way to resolve these in a ~single pass. Anyone have ideas?
- One of the helper branches is a STOPbranch, which shouldn’t be too hard to find in isolation (basicallyJUMPDEST STOP, sometimes there are multiples, not sure why). Could we just use the absence of aSTOPorJUMPto aSTOPoffset as an indicator whether there is a return value of somekind?
 
- One of the helper branches is a 
- In either case, I’m having trouble finding a reliable pattern for extracting the size of the return values, even in the old-Solidity simple case.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (4 by maintainers)
 Top Results From Across the Web
Top Results From Across the Web
DISASM - IBM
Returns information about the specified instruction. ... done using the current target program register values at the time of the EXTRACT DISASM command....
Read more >Programming with Python language - Capstone engine
In return, disasm gives back a list of instructions of the class type CsInsn, and the for loop here iterates this list. Line...
Read more >GDB Command Reference - disassemble command
The disassemble command disassembles a specified function or a function ... the disassemble command will show the raw byte values of all disassembled ......
Read more >dis — Disassembler for Python bytecode — Python 3.11.1 ...
Return a formatted view of the bytecode operations (the same as printed by ... numeric code for operation, corresponding to the opcode values...
Read more >scanf return value - Reverse Engineering Stack Exchange
From man page, scanf() return an int value representing the number of input items successfully matched and assigned.
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free Top Related Reddit Thread
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

Started a WIP PR in #14, here are the vibes so far (from PR):
Also I thought it’d be easier to detect address type outputs because they’re 20 bytes rather than the usual 32, but I forgot that things get padded so it still ends up being 32 bytes.
I probably need to sleep on this in case there’s other clever solutions but not looking great for single-pass static analysis right now. 😅
Updated the current state and challenges in the issue description, going to pass it around to some folks to see if anyone else has ideas. Feel free to re-share. 😃