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

Add support for Mach-O files and Darwin .a files #2

Open
PathogenDavid opened this issue Oct 28, 2021 · 1 comment
Open

Add support for Mach-O files and Darwin .a files #2

PathogenDavid opened this issue Oct 28, 2021 · 1 comment

Comments

@PathogenDavid
Copy link
Owner

PathogenDavid commented Oct 28, 2021

Mach-O is the format macOS uses for executables and dynamic libraries.

It seems Apple no longer hosts documentation on its format (Wikipedia links to this archive). I did find this repo, which helpfully archived the original Apple PDF (Archive) and has a version of it adapted to markdown.

Alternatively we could just use ELFSharp (which contains Mach-O support) for Biohazrd, although this could put us in the same position as #1 where it does way more than we need and requires understanding the Mach-O spec to use properly anyway.

Library archives

Additionally we should support macOS static library archives. Like with everyone else, macOS .a files are a variant of the !<arch> format. Unlike everyone else they use the BSD variant since macOS is BSD-derived. Thankfully this different in format is somewhat easy to identify (there won't be any index file or longname files, and file names begin with #1/ with the real file name being part of the data portion of the file.)

In a BSD archive the equivalent of the index file (__.SYMDEF) is technically optional. macOS might use a variant that is sorted, which is denoted by the file being named __.SYMDEF SORTED. (This was used in the sample library I grabbed from my LLVM build.)

macOS can also apparently have a variant of the symbol table called __.SYMDEF_64, although it's unclear when it appears. (It wasn't there in the sample library.)

The actual object files appear to be Mach-O.

@PathogenDavid PathogenDavid changed the title Add support for Mach-O files Add support for Mach-O files and Darwin .a files Oct 28, 2021
@PathogenDavid
Copy link
Owner Author

The header files referenced by the documentation are present in the macOS SDK in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant