| ... | @@ -505,6 +505,8 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node | ... | @@ -505,6 +505,8 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node |
| 505 | try dead_strip.gcAtoms(self); | 505 | try dead_strip.gcAtoms(self); |
| 506 | } | 506 | } |
| 507 | | 507 | |
| | 508 | self.markImportsAndExports(); |
| | 509 | |
| 508 | state_log.debug("{}", .{self.dumpState()}); | 510 | state_log.debug("{}", .{self.dumpState()}); |
| 509 | | 511 | |
| 510 | @panic("TODO"); | 512 | @panic("TODO"); |
| ... | @@ -1345,6 +1347,44 @@ fn claimUnresolved(self: *MachO) error{OutOfMemory}!void { | ... | @@ -1345,6 +1347,44 @@ fn claimUnresolved(self: *MachO) error{OutOfMemory}!void { |
| 1345 | } | 1347 | } |
| 1346 | } | 1348 | } |
| 1347 | | 1349 | |
| | 1350 | fn markImportsAndExports(self: *MachO) void { |
| | 1351 | for (self.objects.items) |index| { |
| | 1352 | for (self.getFile(index).?.getSymbols()) |sym_index| { |
| | 1353 | const sym = self.getSymbol(sym_index); |
| | 1354 | const file = sym.getFile(self) orelse continue; |
| | 1355 | if (sym.visibility != .global) continue; |
| | 1356 | if (file == .dylib and !sym.flags.abs) { |
| | 1357 | sym.flags.import = true; |
| | 1358 | continue; |
| | 1359 | } |
| | 1360 | if (file.getIndex() == index) { |
| | 1361 | sym.flags.@"export" = true; |
| | 1362 | } |
| | 1363 | } |
| | 1364 | } |
| | 1365 | |
| | 1366 | for (self.undefined_symbols.items) |index| { |
| | 1367 | const sym = self.getSymbol(index); |
| | 1368 | if (sym.getFile(self)) |file| { |
| | 1369 | if (sym.visibility != .global) continue; |
| | 1370 | if (file == .dylib and !sym.flags.abs) sym.flags.import = true; |
| | 1371 | } |
| | 1372 | } |
| | 1373 | |
| | 1374 | for (&[_]?Symbol.Index{ |
| | 1375 | self.entry_index, |
| | 1376 | self.dyld_stub_binder_index, |
| | 1377 | self.objc_msg_send_index, |
| | 1378 | }) |index| { |
| | 1379 | if (index) |idx| { |
| | 1380 | const sym = self.getSymbol(idx); |
| | 1381 | if (sym.getFile(self)) |file| { |
| | 1382 | if (file == .dylib) sym.flags.import = true; |
| | 1383 | } |
| | 1384 | } |
| | 1385 | } |
| | 1386 | } |
| | 1387 | |
| 1348 | fn shrinkAtom(self: *MachO, atom_index: Atom.Index, new_block_size: u64) void { | 1388 | fn shrinkAtom(self: *MachO, atom_index: Atom.Index, new_block_size: u64) void { |
| 1349 | _ = self; | 1389 | _ = self; |
| 1350 | _ = atom_index; | 1390 | _ = atom_index; |