You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
improves the main function discovery heurisitics (#1336)
The problem was not in heuristic per se, but cyclic dependency between
the abi pass that discovers __libc_start_main, main, abi passes, and
api passes. Ideally, we should reimplement our ABI/API infrastructure
using the Knowledge Base, which was originally designed to handle such
dependencies, but it will take much more time than we currently have.
Therefore, right now we discover `__libc_start_main` in the ABI pass,
to be sure that we have types applied to it (which we need as we will
use them later to get the storage for the first argument). And we
delay the `main` function discovery after the api pass. After we find
main we also want types to be applied. Unfortunately, we can't can
call the api pass again (which is responsible for that), but we known
the prototype of main, so we don't really need to parse the C headers
anymore and can manually apply the prototype and translate it to the
arg terms.
Now the main function discovery works perfectly for the programs that
use glibc runtime, so yeah we can finally execute `/bin/true` and
`/bin/false` :)
```
$bap /bin/false --run --primus-print-obs=call-return | grep main
(call-return (main 0 0x40000008 1))
$ bap /bin/true --run --primus-print-obs=call-return | grep main
(call-return (main 0 0x40000008 0))
```
0 commit comments