link/MachO: bring in some of the Elf logic
link/MachO: bring in some of the Elf logic

There was missing incremental compilation logic in the MachO linker
code, causing test failures. With this logic ported over from the
corresponding ELF logic, tests pass again.

zig-lang/zig,zig-lang/zig,andrewrk/zig,andrewrk/zig,zig-lang/zig