Updated notes on Mach-O
All checks were successful
/ test (push) Successful in 15s

This commit is contained in:
Eduard Urbach 2025-07-10 15:26:32 +02:00
parent 7fe9efae21
commit 744ddcde54
Signed by: ed
GPG key ID: 49226B848C78F6C8

View file

@ -2,11 +2,21 @@
## Notes
- Headers must be included in the __TEXT segment.
- The start of the file must be loaded in some segment.
- The start of the file must be marked as readable + executable.
- Load command size must be divisible by 8.
- Segments must be page-aligned in the file[^1].
Due to the page alignment requirement on disk[^1] instead of just memory,
MacOS is the only OS that forces you to write bloated executables on disk.
Until this check is removed, we cannot produce smaller executables.
[^1]: https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/mach_loader.c#L2021-L2027
## Links
- https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/mach_loader.c
- https://github.com/apple-oss-distributions/xnu/blob/main/EXTERNAL_HEADERS/mach-o/loader.h
- https://en.wikipedia.org/wiki/Mach-O
- https://github.com/aidansteele/osx-abi-macho-file-format-reference