It seems MachO does not like padding between text block in __text
section. Unlike in Elf, there is no size information in symbol
struct `nlist_64`.
Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
Fixes a bug where the last written load command would accidentally
override the beginning of the __text section. Also defines missing
MachO constants and relocation structs/enums.
Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
This commit adds enough Mach-O linker implementation to write out simple
Mach-O object file. Be warned however, the object file is largely incomplete:
misses relocation info, debug symbols, etc. However, it seemed like a
good starting to get the basic understanding right.
Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
While we try to work out what the correlation between the OS and runtime
versions is, this commit hardcodes the latter to the minimum (compat)
version of 1.0.0.
Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
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.
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>
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>
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.