authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-01-06 17:36:31+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-01-13 23:54:11+01:00
log6d2a6513f963780fe88235218213dee4b1a0a7dd
tree5ec0e90c4ac130dbf06052bcca158532c4241d3e
parent5ae82956aac029fb45c09e5da2db8d86b9fa0157

macho: write out binding info


1 files changed, 23 insertions(+), 0 deletions(-)

src/link/MachO.zig+23
...@@ -1305,6 +1305,18 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void {...@@ -1305,6 +1305,18 @@ pub fn updateDecl(self: *MachO, module: *Module, decl: *Module.Decl) !void {
1305 .offset = 0,1305 .offset = 0,
1306 });1306 });
1307 self.rebase_info_dirty = true;1307 self.rebase_info_dirty = true;
1308
1309 const sym = self.undef_symbols.items[fixup.symbol];
1310 const name_str = self.getString(sym.n_strx);
1311 var name = try self.base.allocator.alloc(u8, name_str.len);
1312 mem.copy(u8, name, name_str);
1313 try self.lazy_binding_info_table.symbols.append(self.base.allocator, .{
1314 .segment = 3,
1315 .offset = 0,
1316 .dylib_ordinal = 1,
1317 .name = name,
1318 });
1319 self.lazy_binding_info_dirty = true;
1308 }1320 }
13091321
1310 const text_section = text_segment.sections.items[self.text_section_index.?];1322 const text_section = text_segment.sections.items[self.text_section_index.?];
...@@ -2078,6 +2090,17 @@ pub fn populateMissingMetadata(self: *MachO) !void {...@@ -2078,6 +2090,17 @@ pub fn populateMissingMetadata(self: *MachO) !void {
2078 .n_desc = macho.REFERENCE_FLAG_UNDEFINED_NON_LAZY | macho.N_SYMBOL_RESOLVER,2090 .n_desc = macho.REFERENCE_FLAG_UNDEFINED_NON_LAZY | macho.N_SYMBOL_RESOLVER,
2079 .n_value = 0,2091 .n_value = 0,
2080 });2092 });
2093
2094 self.binding_info_table.dylib_ordinal = 1;
2095 const nn = self.getString(name);
2096 var n = try self.base.allocator.alloc(u8, nn.len);
2097 mem.copy(u8, n, nn);
2098 try self.binding_info_table.symbols.append(self.base.allocator, .{
2099 .name = n,
2100 .segment = 2,
2101 .offset = 0,
2102 });
2103 self.binding_info_dirty = true;
2081 }2104 }
2082 if (self.next_stub_helper_off == null) {2105 if (self.next_stub_helper_off == null) {
2083 const text = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;2106 const text = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;