Skip to content

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

Description

@PathogenDavid

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions