Add support for Mach-O Universal (aka "Fat") binaries and additional architectures#779
Merged
sindresorhus merged 2 commits intosindresorhus:mainfrom Jan 4, 2026
Conversation
Contributor
Author
|
NOTE: I was unable to build or find a reasonably sized and redistributable ppc64 binary. The only one I could find is |
Collaborator
|
Please resolve merge conflicts |
bf69789 to
24e76f4
Compare
Contributor
Author
|
Rebased! Thanks @Borewit and Happy New Year 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mach-O single architecture (aka "thin") binaries
Mach-O "thin" binaries have different magic numbers depending on the architecture "bitness" and endianness (source: https://en.wikipedia.org/wiki/Mach-O#Mach-O_header):
0xFE 0xED 0xFA 0xCE32-bit, big-endian (e.g., ppc)0xFE 0xED 0xFA 0xCF64-bit, big-endian (e.g., ppc64)0xCE 0xFA 0xED 0xFE32-bit, little-endian (e.g., i386)0xCF 0xFA 0xED 0xFE64-bit, little-endian (e.g., x86_64 and arm64)Mach-O multi-architecture (aka Universal or "fat") binaries
Mach-O multi-architecture binaries, unfortunately, have the same
0xca 0xfe 0xba 0xbemagic number as Java.classfiles:These two formats can be disambiguated by the next 4 bytes, which specify the number of binaries in a Mach-O multi-architecture binary (should be a small-ish number) or the Java Class format minor and major version (first supported major version was 45). We can adopt a similar approach to that used by
file: https://github.com/file/file/blob/master/magic/Magdir/cafebabeSee also: