stage2: enable zig test on x86_64-macos (#10551)
* stage2: put decls in different MachO sections Use `getDeclVAddrWithReloc` when targeting MachO backend rather than `getDeclVAddr` - this fn returns a zero vaddr and instead creates a relocation on the linker side which will get automatically updated whenever the target decl is moved in memory. This fn also records a rebase of the target pointer so that its value is correctly slid in presence of ASLR. This commit enables `zig test` on x86_64-macos. * stage2: fix output section selection for type,val pairs
This commit is contained in:
@@ -465,9 +465,15 @@ fn lowerDeclRef(
|
||||
|
||||
if (decl.analysis != .complete) return error.AnalysisFail;
|
||||
markDeclAlive(decl);
|
||||
// TODO handle the dependency of this symbol on the decl's vaddr.
|
||||
// If the decl changes vaddr, then this symbol needs to get regenerated.
|
||||
const vaddr = bin_file.getDeclVAddr(decl);
|
||||
const vaddr = vaddr: {
|
||||
if (bin_file.cast(link.File.MachO)) |macho_file| {
|
||||
break :vaddr try macho_file.getDeclVAddrWithReloc(decl, code.items.len);
|
||||
}
|
||||
// TODO handle the dependency of this symbol on the decl's vaddr.
|
||||
// If the decl changes vaddr, then this symbol needs to get regenerated.
|
||||
break :vaddr bin_file.getDeclVAddr(decl);
|
||||
};
|
||||
|
||||
const endian = bin_file.options.target.cpu.arch.endian();
|
||||
switch (bin_file.options.target.cpu.arch.ptrBitWidth()) {
|
||||
16 => mem.writeInt(u16, try code.addManyAsArray(2), @intCast(u16, vaddr), endian),
|
||||
|
||||
Reference in New Issue
Block a user