Skip to content

investment in unix x86_64 path parity#174

Closed
brandonros wants to merge 1 commit intosha0coder:mainfrom
brandonros:parity9
Closed

investment in unix x86_64 path parity#174
brandonros wants to merge 1 commit intosha0coder:mainfrom
brandonros:parity9

Conversation

@brandonros
Copy link
Copy Markdown
Contributor

addresses parts of #160

Summary

This brings the Unix x86_64 paths much closer to parity by wiring up the missing loader, syscall, and API-interception pieces for:

  • macOS x86_64 Mach-O binaries
  • Linux x86_64 ELF binaries

It also hardens the existing macOS AArch64 hello coverage and adds focused fixtures/tests for the new x86_64 paths.

What changed

Shared API ABI handling

  • Added a small shared ABI helper for Unix API shims
  • Updated the Linux libc and macOS libSystem gateways to read arguments / write return values for both:
    • AArch64
    • x86_64 SysV

macOS x86_64 support

  • Added x86_64 Mach-O detection and loader front-door support
  • Added macOS x86_64 initialization
  • Routed x86_64 syscall through a macOS syscall gateway instead of falling into the Windows path
  • Added x86_64 Unix API interception in set_rip()
  • Reused the existing libSystem/chained-fixup machinery for x86_64 Mach-O loading

Linux x86_64 support

  • Added Linux stub-lib loading from maps/maps_linux
  • Added a stub libc.so.6
  • Extended ELF dynamic-link handling to use:
    • DT_NEEDED
    • DT_RELA
    • DT_JMPREL
  • Implemented relocation patching for:
    • R_X86_64_GLOB_DAT
    • R_X86_64_JUMP_SLOT
  • Added symbol/address lookup maps for loaded ELF stub libraries
  • Added Linux x86_64 Unix API interception in set_rip()
  • Added a minimal __libc_start_main startup bridge for the dynamic hello-world path

Tests

  • Hardened the existing macOS AArch64 hello/libc test so it now asserts success instead of logging and passing
  • Added macOS x86_64 hello tests for:
    • raw syscall flow
    • libc/API interception flow
  • Added a Linux x86_64 dynamic ELF hello test covering:
    • _start
    • __libc_start_main
    • main
    • puts
    • exit

Tooling / repo support

  • Added ignore rules for local Zig/Cargo cache artifacts used while building fixtures

Validation

Ran:

  • cargo check -p libmwemu --target x86_64-apple-darwin
  • cargo test -p libmwemu macho64 --target x86_64-apple-darwin -- --nocapture
  • cargo test -p libmwemu elf64lin_dynamic_hello --target x86_64-apple-darwin -- --nocapture

Notes

  • This PR focuses on hello-world-level runtime bring-up and interception coverage.
  • Many libc/libSystem helpers are still stubbed or todo!() and remain follow-up work.
  • There are a few adjacent formatting-only changes in touched files; the functional intent of this PR is the Unix x86_64 bring-up described above.

@brandonros brandonros force-pushed the parity9 branch 2 times, most recently from a145b85 to 8269f76 Compare April 10, 2026 21:45
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.

1 participant