Vector35 / binaryninja-api

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

scc runtime for multiple architectures broken between 2.0->2.1 #5340

Open psifertex opened 4 months ago

psifertex commented 4 months ago

In BN 2.1 (2020-07-10) and all newer builds, the following fails for all architectures except for x64, and x86:

$ cat test.c
int main() {
    puts("testing!");
    return 0;
}
$ scc2.1 -o /dev/null --arch mips test.c
error: unable to generate code for IL: assign reg1:U32 strlen:U32 reg5:U32
error: code generation failed for function 'fputs'

However, in 2.0 it succeeds:

$ scc2.0 -o /dev/null --arch mips test.c
Output is 2784 bytes

This was almost certainly caused by UB during a change from Make to cmake

psifertex commented 1 month ago

Another bug that may or may not be related:

# works on 2.0 scc
echo "void main(){}" | ~/scc-working --arch x64 -m64 --platform windows --stdin
Output is 538 bytes
...
# broken on 4.1 scc
stdin:1: error: type mismatch in parameter 2
psifertex commented 1 month ago

Not related to a specific compiler chain as the same behavior is observed across both linux and macos builds.

CouleeApps commented 1 month ago

Workaround steps for now:

  1. Make a copy of Binary Ninja
  2. Open that copy
  3. Enable the setting: updates.showAllVersions
  4. Open the Update Channel dialog (Edit menu or Application Menu on macOS)
  5. Switch to the Latest Binary Ninja Release channel and pick version 2.0, then press Download
  6. Let Binary Ninja update
  7. Copy binaryninja/plugins/scc from version 2.0 (on macOS: Binary Ninja.app/Contents/MacOS/plugins/scc)
  8. You can paste it into the latest version of Binary Ninja and it will work, however any time you update it will be reverted to the broken version, so keep a backup copy
  9. You can delete the copy of Binary Ninja you made for getting v2.0