Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OS X Fragile Compatibility #54

Open
2 tasks done
t0rr3sp3dr0 opened this issue May 1, 2024 · 6 comments
Open
2 tasks done

Mac OS X Fragile Compatibility #54

t0rr3sp3dr0 opened this issue May 1, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request triage

Comments

@t0rr3sp3dr0
Copy link
Contributor

t0rr3sp3dr0 commented May 1, 2024

Is your feature request related to a problem? Please describe.

The current implementation of go-macho only properly supports the non-fragile version of the Mac OS X Objective-C Runtime. Code that targeting the fragile version of the runtime may not be parsed correctly. In clang, the runtime can be defined through the -fobjc-runtime=${OBJC_RUNTIME} flag (https://clang.llvm.org/doxygen/classclang_1_1ObjCRuntime.html#af19fe070a7073df4ecc666b44137c4e5).

Describe the solution you'd like

Have a solution that is able to handle both runtime variants. If possible to distinguish the runtime used from the binary, implement full support, otherwise prioritize compatibility with the non-fragile runtime.

Describe alternatives you've considered

Not implement support for the Mac OS X Fragile Runtime and explicitly state that go-macho support the non-fragile runtime only. If possible, reject or warn about binaries using incompatible runtimes.

Search

  • I did search for other open and closed issues before opening this

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

No response

@t0rr3sp3dr0 t0rr3sp3dr0 added enhancement New feature or request triage labels May 1, 2024
@blacktop
Copy link
Owner

blacktop commented May 2, 2024

Can you include 2 binaries compiled in the 2 different ways?

@t0rr3sp3dr0
Copy link
Contributor Author

Take a look at these files, I've complied them with gcc for all architectures supported during the transition from PowerPC to Intel. class-dump is able to parse the gcc-compiled binaries without a problem, but go-macho fails with different errors.

I also compiled the same thing with the latest version clang using different Objective-C runtimes. Strangely, even when using the default Objective-C runtime, go-macho is failing to decode types.

@t0rr3sp3dr0
Copy link
Contributor Author

Btw, I was under the impression that older versions of Xcode used the GNU runtime by default, but that's not the case. On those versions, Xcode uses what LLVM calls the Mac OS X Fragile runtime. I couldn't make clang or gcc use runtimes that were not NeXT-like. It looks like no one ever bothered to support GNU-like runtimes on macOS, I've only been able to use them on Linux. But since those binaries are ELFs not Mach-Os, supporting them is definitely out of the scope of this project and we should focus on the NeXT-like runtimes.

@t0rr3sp3dr0 t0rr3sp3dr0 changed the title GNU Compatibility Mac OS X Fragile Compatibility May 5, 2024
@t0rr3sp3dr0
Copy link
Contributor Author

Actually, I just figured out the ObjFW Runtime has a compiler of its own and was able to use it on macOS. It doesn't support cross-compilation though, so I could only generate binaries for Intel and Apple Silicon.

@t0rr3sp3dr0
Copy link
Contributor Author

For extra reference, sharing two binaries from the Mac OS X 10.0 Public Beta. I think they will be the worst case we will ever see. go-macho, MachOExplorer, and MachOView have no idea how to parse them, but class-dump is able to process these binaries normally.

@t0rr3sp3dr0
Copy link
Contributor Author

While I'm here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage
Projects
None yet
Development

No branches or pull requests

2 participants