radare2 icon indicating copy to clipboard operation
radare2 copied to clipboard

inline functions

Open trufae opened this issue 2 years ago • 1 comments

taking inspiration on a chat discussion:

  • Theres no "inline" attribute in r2, and im not sure how that should be handled. As it ferls like inline functions could be analyzed as byte patterns using zignatures. But those may be different kind of monsters because a single name can refer to N addresses where this function is implemented
  • The graph could be folding the basic blocks of the inline function in the fcn cfg
  • This seems like an interesting thing to implement in r2
  • As the analyzer could define inline functions and the disasm can take advantage of this information to reduce duplicated code
  • Maybe radius can be abused to handle this but i think that byte batterns associated with a name can be enough. The disasm can check if the byte pattern matches somewhere inside the block and fold it and the search command can be used to search for inline functions
  • It can be even used to reduce prologues and epilogues
  • For now i think that byte pattern can be enough but will be good to be open to support esil dfg analysis or other scan methods to detect such patterns

trufae avatar Sep 18 '22 17:09 trufae

Inline functions would be a very welcome addition.

For starters we could allow users to designate a set of basic blocks as an inline function. Then r2 would auto search for other inline. Zignatures should work to discover the other inlines very easily, though with false negatives.

Inlines don't obey calling conventions, there is no call. The compiler seems to choose which registers to use depending on the context of the surrounding code. So we should have a translation map to let the user know what the input and output of the inline function is. This could be abstracted by variables maybe.

swoops avatar Sep 20 '22 21:09 swoops