mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 03:03:09 +00:00
codegen: re-enable MachO support in genDeclRef
This commit is contained in:
parent
82e92fe5f6
commit
76dc305d4e
@ -984,22 +984,24 @@ fn genDeclRef(
|
||||
}
|
||||
return GenResult.mcv(.{ .load_symbol = sym.esym_index });
|
||||
} else if (lf.cast(link.File.MachO)) |macho_file| {
|
||||
_ = macho_file;
|
||||
if (is_extern) {
|
||||
// TODO make this part of getGlobalSymbol
|
||||
// const name = zcu.intern_pool.stringToSlice(decl.name);
|
||||
// const sym_name = try std.fmt.allocPrint(gpa, "_{s}", .{name});
|
||||
// defer gpa.free(sym_name);
|
||||
// const global_index = try macho_file.addUndefined(sym_name, .{ .add_got = true });
|
||||
// return GenResult.mcv(.{ .load_got = link.File.MachO.global_symbol_bit | global_index });
|
||||
const name = zcu.intern_pool.stringToSlice(decl.name);
|
||||
const sym_name = try std.fmt.allocPrint(gpa, "_{s}", .{name});
|
||||
defer gpa.free(sym_name);
|
||||
const lib_name = if (decl.getOwnedVariable(zcu)) |ov|
|
||||
zcu.intern_pool.stringToSliceUnwrap(ov.lib_name)
|
||||
else
|
||||
null;
|
||||
const sym_index = try macho_file.getGlobalSymbol(sym_name, lib_name);
|
||||
macho_file.getSymbol(sym_index).flags.needs_got = true;
|
||||
return GenResult.mcv(.{ .load_symbol = sym_index });
|
||||
}
|
||||
// const atom_index = try macho_file.getOrCreateAtomForDecl(decl_index);
|
||||
// const sym_index = macho_file.getAtom(atom_index).getSymbolIndex().?;
|
||||
// if (is_threadlocal) {
|
||||
// return GenResult.mcv(.{ .load_tlv = sym_index });
|
||||
// }
|
||||
// return GenResult.mcv(.{ .load_got = sym_index });
|
||||
@panic("TODO genDeclRef");
|
||||
const sym_index = try macho_file.getZigObject().?.getOrCreateMetadataForDecl(macho_file, decl_index);
|
||||
const sym = macho_file.getSymbol(sym_index);
|
||||
if (is_threadlocal) {
|
||||
return GenResult.mcv(.{ .load_tlv = sym.nlist_idx });
|
||||
}
|
||||
return GenResult.mcv(.{ .load_symbol = sym.nlist_idx });
|
||||
} else if (lf.cast(link.File.Coff)) |coff_file| {
|
||||
if (is_extern) {
|
||||
const name = zcu.intern_pool.stringToSlice(decl.name);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user