macho: document more code + add test case
This commit is contained in:
@@ -1865,19 +1865,16 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
|
||||
// If it doesn't, it will get autofreed when we clean up the extern symbol table.
|
||||
const decl_name = try std.fmt.allocPrint(self.bin_file.allocator, "_{s}", .{decl.name});
|
||||
const already_defined = macho_file.extern_lazy_symbols.contains(decl_name);
|
||||
const symbol: u32 = blk: {
|
||||
if (macho_file.extern_lazy_symbols.get(decl_name)) |sym| {
|
||||
self.bin_file.allocator.free(decl_name);
|
||||
break :blk sym.index;
|
||||
} else {
|
||||
const index = @intCast(u32, macho_file.extern_lazy_symbols.items().len);
|
||||
try macho_file.extern_lazy_symbols.putNoClobber(self.bin_file.allocator, decl_name, .{
|
||||
.name = decl_name,
|
||||
.dylib_ordinal = 1, // TODO this is now hardcoded, since we only support libSystem.
|
||||
.index = index,
|
||||
});
|
||||
break :blk index;
|
||||
}
|
||||
const symbol: u32 = if (macho_file.extern_lazy_symbols.getIndex(decl_name)) |index| blk: {
|
||||
self.bin_file.allocator.free(decl_name);
|
||||
break :blk @intCast(u32, index);
|
||||
} else blk: {
|
||||
const index = @intCast(u32, macho_file.extern_lazy_symbols.items().len);
|
||||
try macho_file.extern_lazy_symbols.putNoClobber(self.bin_file.allocator, decl_name, .{
|
||||
.name = decl_name,
|
||||
.dylib_ordinal = 1, // TODO this is now hardcoded, since we only support libSystem.
|
||||
});
|
||||
break :blk index;
|
||||
};
|
||||
try macho_file.stub_fixups.append(self.bin_file.allocator, .{
|
||||
.symbol = symbol,
|
||||
|
||||
Reference in New Issue
Block a user