| ... | ... | @@ -48,6 +48,14 @@ eh_frame_sect_index: ?u8 = null, |
| 48 | 48 | unwind_info_sect_index: ?u8 = null, |
| 49 | 49 | objc_stubs_sect_index: ?u8 = null, |
| 50 | 50 | |
| 51 | mh_execute_header_index: ?Symbol.Index = null, |
| 52 | mh_dylib_header_index: ?Symbol.Index = null, |
| 53 | dyld_private_index: ?Symbol.Index = null, |
| 54 | dyld_stub_binder_index: ?Symbol.Index = null, |
| 55 | dso_handle_index: ?Symbol.Index = null, |
| 56 | objc_msg_send_index: ?Symbol.Index = null, |
| 57 | entry_index: ?Symbol.Index = null, |
| 58 | |
| 51 | 59 | /// List of atoms that are either synthetic or map directly to the Zig source program. |
| 52 | 60 | atoms: std.ArrayListUnmanaged(Atom) = .{}, |
| 53 | 61 | thunks: std.ArrayListUnmanaged(Thunk) = .{}, |
| ... | ... | @@ -482,6 +490,14 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node |
| 482 | 490 | try dylib.initSymbols(self); |
| 483 | 491 | } |
| 484 | 492 | |
| 493 | { |
| 494 | const index = @as(File.Index, @intCast(try self.files.addOne(gpa))); |
| 495 | self.files.set(index, .{ .internal = .{ .index = index } }); |
| 496 | self.internal_object = index; |
| 497 | } |
| 498 | |
| 499 | try self.addUndefinedGlobals(); |
| 500 | |
| 485 | 501 | state_log.debug("{}", .{self.dumpState()}); |
| 486 | 502 | |
| 487 | 503 | @panic("TODO"); |
| ... | ... | @@ -1112,6 +1128,35 @@ fn parseTbd(self: *MachO, lib: SystemLib, explicit: bool) ParseError!File.Index |
| 1112 | 1128 | // } |
| 1113 | 1129 | // } |
| 1114 | 1130 | |
| 1131 | fn addUndefinedGlobals(self: *MachO) !void { |
| 1132 | const gpa = self.base.comp.gpa; |
| 1133 | |
| 1134 | try self.undefined_symbols.ensureUnusedCapacity(gpa, self.base.comp.force_undefined_symbols.keys().len); |
| 1135 | for (self.base.comp.force_undefined_symbols.keys()) |name| { |
| 1136 | const off = try self.strings.insert(gpa, name); |
| 1137 | const gop = try self.getOrCreateGlobal(off); |
| 1138 | self.undefined_symbols.appendAssumeCapacity(gop.index); |
| 1139 | } |
| 1140 | |
| 1141 | if (!self.base.isDynLib() and self.entry_name != null) { |
| 1142 | const off = try self.strings.insert(gpa, self.entry_name.?); |
| 1143 | const gop = try self.getOrCreateGlobal(off); |
| 1144 | self.entry_index = gop.index; |
| 1145 | } |
| 1146 | |
| 1147 | { |
| 1148 | const off = try self.strings.insert(gpa, "dyld_stub_binder"); |
| 1149 | const gop = try self.getOrCreateGlobal(off); |
| 1150 | self.dyld_stub_binder_index = gop.index; |
| 1151 | } |
| 1152 | |
| 1153 | { |
| 1154 | const off = try self.strings.insert(gpa, "_objc_msgSend"); |
| 1155 | const gop = try self.getOrCreateGlobal(off); |
| 1156 | self.objc_msg_send_index = gop.index; |
| 1157 | } |
| 1158 | } |
| 1159 | |
| 1115 | 1160 | fn shrinkAtom(self: *MachO, atom_index: Atom.Index, new_block_size: u64) void { |
| 1116 | 1161 | _ = self; |
| 1117 | 1162 | _ = atom_index; |