Skip to content

headers: add MH_IMPLICIT_PAGEZERO#935

Merged
MikeMcQuaid merged 1 commit intomainfrom
MH_IMPLICIT_PAGEZERO
Feb 1, 2026
Merged

headers: add MH_IMPLICIT_PAGEZERO#935
MikeMcQuaid merged 1 commit intomainfrom
MH_IMPLICIT_PAGEZERO

Conversation

@Bo98
Copy link
Member

@Bo98 Bo98 commented Feb 1, 2026

This one is pretty confusing. It was added to ld-classic but not regular ld in Xcode 15.3, as well as read support in otool.

But as far as I can tell I don't see anywhere that actually uses it, unless it's in some unusual closed source part of dyld or xnu.

And now that ld -ld_classic no longer allows options that only existed under ld-classic, the only way to actually use it is to point to the ld-classic executable directly.

I suspect it might have been an abandoned idea that still partially shipped but nevertheless, the bit was reserved and the name for it shipped in the macOS SDK.

Copilot AI review requested due to automatic review settings February 1, 2026 14:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds the MH_IMPLICIT_PAGEZERO Mach-O header flag constant that was introduced in Apple's Xcode 15.3 SDK. While the flag appears to be unused in practice (possibly an abandoned feature), it was officially reserved in the macOS SDK and should be included for completeness and SDK compatibility.

Changes:

  • Added MH_IMPLICIT_PAGEZERO constant with value 0x10000000 to the MH_FLAGS hash in headers.rb

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Bo98
Copy link
Member Author

Bo98 commented Feb 1, 2026

Another confusing one I didn't include yet: a reference to a MH_NO_DYNAMIC_ACCESS appeared in macOS 26 code (https://github.com/apple-oss-distributions/dyld/blob/3d26957467bbec4f999a0c27ebe09b6fc186f5cd/mach_o/Header.h#L101), which seems to have overtaken the flag previously used by MH_NOFIXPREBINDING (unused since Mac OS X 10.3.9). However nothing else has been updated - the SDK still has MH_NOFIXPREBINDING and otool still outputs the NOFIXPREBINDING name. The define was added to dyld specifically rather than the global mach-o/loader.h header that it shared among all projects, the only MH_ flag that has been done like that.

ruby-macho does have a typo and calls it MH_NOPREFIXBINDING however so that part perhaps needs fixing anyhow (though that's technically a breaking API change).

@Bo98
Copy link
Member Author

Bo98 commented Feb 1, 2026

However nothing else has been updated - the SDK still has MH_NOFIXPREBINDING and otool still outputs the NOFIXPREBINDING name.

Demonstration of this:

$ clang main.c                       
$ otool -hv a.out
a.out:
Mach header
      magic  cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64    ARM64        ALL  0x00     EXECUTE    16        744   NOUNDEFS DYLDLINK TWOLEVEL PIE

$ clang -Wl,-no_dynamic_access main.c
$ otool -hv a.out                    
a.out:
Mach header
      magic  cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
MH_MAGIC_64    ARM64        ALL  0x00     EXECUTE    16        744   NOUNDEFS DYLDLINK TWOLEVEL NOFIXPREBINDING PIE

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MikeMcQuaid MikeMcQuaid merged commit 724ea11 into main Feb 1, 2026
20 checks passed
@MikeMcQuaid MikeMcQuaid deleted the MH_IMPLICIT_PAGEZERO branch February 1, 2026 15:06
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

Successfully merging this pull request may close these issues.

3 participants