splat icon indicating copy to clipboard operation
splat copied to clipboard

Improve C defined function detection / add C declared variable detection

Open ethteck opened this issue 5 years ago • 2 comments

We try to do this, but it clearly has some issues as #11 mentions

Conversely, functions defined in C code but non-matching should be disassembled

  • Run cpp on c files to figure out which functions are defined
  • Improve detection of defined functions
  • Add support for detection of declared (non-externed) variables.
  • Mark these symbols as defined so they don't get written to undefined_syms_auto

ethteck avatar Nov 07 '20 15:11 ethteck

I don't think detecting defined variables in C code is viable without using pycparser, which is insanely slow. If anyone has other ideas, I'm all ears, but this seems really difficult..

ethteck avatar Apr 18 '21 09:04 ethteck

Notes around c function detection:

  1. This function will not be detected due to unsigned int being 2 tokens, it is fine if the return type is 1 token, e.g. u32.
unsigned long my_function(int foo) {
    return 0;
}
  1. This function will not be detected due to the whitespace between my_function and (int foo).
long my_function (int foo) {
    return 0;
}

I discovered both of these due to me copying the LIBSPU.H definition for a PSX library function, e.g.

extern unsigned long SpuSetNoiseVoice (long on_off, unsigned long voice_bit);

mkst avatar Mar 03 '22 08:03 mkst