Vector35 / binaryninja-api

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

Unusable IL in code calling objc_msgSend in libraries manually extracted from dyld shared cache #6117

Open bdash opened 3 days ago

bdash commented 3 days ago

Version and Platform (required):

Bug Description: When analyzing Objective-C code in a framework extracted from the macOS dyld shared cache using a third-party tool, the high-level IL of a function is often collapsed to a single jump(…). The majority of the logic is missing. The low-level IL also terminates at what appears to be the first call to objc_msgSend, inlined from within an direct messaging stub function.

Steps To Reproduce:

  1. Use a tool like https://github.com/keith/dyld-shared-cache-extractor to extract frameworks from the macOS shared cache.
  2. Load /System/Library/Frameworks/AppKit.framework/Version/C/AppKit from the directory you extracted the shared cache to.
  3. Search for _NSFullScreenMenuBarCompanionController dispose in the symbol list.
  4. Observe that in any of the IL or pseudo-code views, most of the function body is missing compared to the disassembly.

Expected Behavior: Branches whose destinations cannot be resolved should not result in the entire function being collapsed.

Screenshots/Video Recording: Low level IL, showing truncated IL

Screenshot 2024-11-12 at 10 35 32 AM

High level IL, showing body as a single jump(…)

Screenshot 2024-11-12 at 10 42 53 AM

First part of the disassembly

Screenshot 2024-11-12 at 10 37 35 AM

Binary: See steps to reproduce.

Additional Information: This is not specific to this particular function. Most/all functions within AppKit show this behavior.

The new built-in dyld shared cache extractor does not have this problem. Sadly its performance and memory use make it hard to use for quick analysis.

bdash commented 3 days ago

I suspect this boils down to the extracted binaries being improperly formed (#5596), but this is a particularly confusing failure mode that makes Binary Ninja appear broken vs other tools opening the same files.