Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
897 stars 200 forks source link

Renaming objective-c method stubs in the __objc_stubs section #5843

Open 52617365 opened 1 month ago

52617365 commented 1 month ago

What is the feature you'd like to have? When binary ninja analyses a binary, it creates a __objc_stubs section. It would be nice if the method stubs would be named after the methods they call.

For example, it would be nice if this stub:

0000000104573c40  int64_t sub_xxxxxxxx(void* arg1)
0000000104573c50      return _objc_msgSend(self: arg1, cmd: "JPEGData") __tailcall

Would be automatically renamed to something like this (or something else):

0000000104573c40  int64_t objc_stub_caller_JPEGData(void* arg1)
0000000104573c50      return _objc_msgSend(self: arg1, cmd: "JPEGData") __tailcall

Is your feature request related to a problem? Stubs don't get named in a handy way, the names of the method stubs are left as sub_xxxxxxx when in my opinion they could be named in a better way to better signal what the functions are doing (acting as a "bridge" to the actual function call)

Are any alternative solutions acceptable? For my purpose I created a binja script that does exactly this, the link to the gist containing the code is here: rename_objc_stubs_binja.py

Additional Information: Renaming the functions with the script removed a lot of noise from the symbol list.

Masrepus commented 1 month ago

Of course I don't know what binary you were looking at, but I don't think Binja is the one creating those stubs: Recent versions of clang started producing them, likely to save some space in the binaries. The names those stubs receive are of the format _objc_msgSend$<selector>, i.e. in this case _objc_msgSend$JPEGData, so I would suggest to use those exact names for any heuristic renaming