mirror of
https://github.com/ziglang/zig.git
synced 2026-02-03 13:13:40 +00:00
macho: fill the rest of ZigObject
This commit is contained in:
parent
ee463efdf2
commit
82e92fe5f6
@ -383,6 +383,15 @@ pub fn free(self: *Atom, macho_file: *MachO) void {
|
||||
self.* = .{};
|
||||
}
|
||||
|
||||
pub fn addReloc(self: *Atom, macho_file: *MachO, reloc: Relocation) !void {
|
||||
const gpa = macho_file.base.comp.gpa;
|
||||
const file = self.getFile(macho_file);
|
||||
assert(file == .zig_object);
|
||||
const rels = &file.zig_object.relocs.items[self.relocs.pos];
|
||||
try rels.append(gpa, reloc);
|
||||
self.relocs.len += 1;
|
||||
}
|
||||
|
||||
pub fn freeRelocs(self: *Atom, macho_file: *MachO) void {
|
||||
self.getFile(macho_file).zig_object.freeAtomRelocs(self.*);
|
||||
self.relocs.len = 0;
|
||||
|
||||
@ -234,11 +234,24 @@ pub fn getDeclVAddr(
|
||||
decl_index: InternPool.DeclIndex,
|
||||
reloc_info: link.File.RelocInfo,
|
||||
) !u64 {
|
||||
_ = self;
|
||||
_ = macho_file;
|
||||
_ = decl_index;
|
||||
_ = reloc_info;
|
||||
@panic("TODO getDeclVAddr");
|
||||
const sym_index = try self.getOrCreateMetadataForDecl(macho_file, decl_index);
|
||||
const sym = macho_file.getSymbol(sym_index);
|
||||
const vaddr = sym.getAddress(.{}, macho_file);
|
||||
const parent_atom = macho_file.getSymbol(reloc_info.parent_atom_index).getAtom(macho_file).?;
|
||||
try parent_atom.addReloc(macho_file, .{
|
||||
.tag = .@"extern",
|
||||
.offset = @intCast(reloc_info.offset),
|
||||
.target = sym.nlist_idx,
|
||||
.addend = reloc_info.addend,
|
||||
.type = .unsigned,
|
||||
.meta = .{
|
||||
.pcrel = false,
|
||||
.has_subtractor = false,
|
||||
.length = 3,
|
||||
.symbolnum = @intCast(sym.nlist_idx),
|
||||
},
|
||||
});
|
||||
return vaddr;
|
||||
}
|
||||
|
||||
pub fn getAnonDeclVAddr(
|
||||
@ -247,11 +260,24 @@ pub fn getAnonDeclVAddr(
|
||||
decl_val: InternPool.Index,
|
||||
reloc_info: link.File.RelocInfo,
|
||||
) !u64 {
|
||||
_ = self;
|
||||
_ = macho_file;
|
||||
_ = decl_val;
|
||||
_ = reloc_info;
|
||||
@panic("TODO getAnonDeclVAddr");
|
||||
const sym_index = self.anon_decls.get(decl_val).?.symbol_index;
|
||||
const sym = macho_file.getSymbol(sym_index);
|
||||
const vaddr = sym.getAddress(.{}, macho_file);
|
||||
const parent_atom = macho_file.getSymbol(reloc_info.parent_atom_index).getAtom(macho_file).?;
|
||||
try parent_atom.addReloc(macho_file, .{
|
||||
.tag = .@"extern",
|
||||
.offset = @intCast(reloc_info.offset),
|
||||
.target = sym.nlist_idx,
|
||||
.addend = reloc_info.addend,
|
||||
.type = .unsigned,
|
||||
.meta = .{
|
||||
.pcrel = false,
|
||||
.has_subtractor = false,
|
||||
.length = 3,
|
||||
.symbolnum = @intCast(sym.nlist_idx),
|
||||
},
|
||||
});
|
||||
return vaddr;
|
||||
}
|
||||
|
||||
pub fn lowerAnonDecl(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user