11 Commits

Author SHA1 Message Date
Jakub Konka
9745e7b512 Clean up draft for merging into upstream
Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-24 17:59:44 +02:00
Jakub Konka
1698e6d7a7 Link against libSystem when generating Mach-O exe
This is required when generating an exe on macOS.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-24 17:59:44 +02:00
Jakub Konka
2516db9645 Specify path to dyld in Mach-O
This is required since an exec on macOS always has to link against
libSystem.dylib.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-24 17:59:44 +02:00
Andrew Kelley
89b6c47e04 stage2: decouple codegen.zig from ELF
See #6113 for an alternate way of doing this that we didn't end up
following.

Closes #6079.

I also took the opportunity here to extract C.zig and Elf.zig from
link.zig.
2020-08-21 13:25:59 -07:00
Jakub Konka
ad79b80524
Apply suggestions from code review
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2020-08-20 09:14:37 +02:00
Jakub Konka
9164daaa39 Write page zero as first segment for Mach-O exes
According to the Mach-O file format reference, the first
load command should be a `__PAGEZERO` segment command. The
segment is located at virtual memory location 0, has no protection
rights, and causes acccesses to NULL to immediately crash.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-20 08:33:40 +02:00
Jakub Konka
ffdeb6af91
Update src-self-hosted/link/MachO.zig
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2020-08-19 07:43:33 +02:00
Jakub Konka
34e628a0a0 Fix compile error
Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-18 23:35:31 +02:00
Jakub Konka
e4b3da2720 Write out Mach-O header
This commit write out Mach-O header in the linker's `flush`
method. The header currently only populates the magic number,
filetype, and cpu info.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-18 23:35:31 +02:00
Isaac Freund
60fb50ee5a
stage2/wasm: write exports on flush, cleanup
Exports now have a dirty flag and are rewritten on flush if this flag
has been set.

A couple other minor changes have been made based on Andrew's review.
2020-08-18 01:01:13 +02:00
Jakub Konka
5cb96681d9 Move Mach-O to link/MachO.zig submodule
Remove `ptrWidth` since as of Catalina, all apps are 64bits only.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-17 18:16:29 +02:00