| ... | ... | @@ -506,6 +506,7 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | self.markImportsAndExports(); |
| 509 | self.deadStripDylibs(); |
| 509 | 510 | |
| 510 | 511 | state_log.debug("{}", .{self.dumpState()}); |
| 511 | 512 | |
| ... | ... | @@ -1385,6 +1386,33 @@ fn markImportsAndExports(self: *MachO) void { |
| 1385 | 1386 | } |
| 1386 | 1387 | } |
| 1387 | 1388 | |
| 1389 | fn deadStripDylibs(self: *MachO) void { |
| 1390 | for (&[_]?Symbol.Index{ |
| 1391 | self.entry_index, |
| 1392 | self.dyld_stub_binder_index, |
| 1393 | self.objc_msg_send_index, |
| 1394 | }) |index| { |
| 1395 | if (index) |idx| { |
| 1396 | const sym = self.getSymbol(idx); |
| 1397 | if (sym.getFile(self)) |file| { |
| 1398 | if (file == .dylib) file.dylib.referenced = true; |
| 1399 | } |
| 1400 | } |
| 1401 | } |
| 1402 | |
| 1403 | for (self.dylibs.items) |index| { |
| 1404 | self.getFile(index).?.dylib.markReferenced(self); |
| 1405 | } |
| 1406 | |
| 1407 | var i: usize = 0; |
| 1408 | while (i < self.dylibs.items.len) { |
| 1409 | const index = self.dylibs.items[i]; |
| 1410 | if (!self.getFile(index).?.dylib.isAlive(self)) { |
| 1411 | _ = self.dylibs.orderedRemove(i); |
| 1412 | } else i += 1; |
| 1413 | } |
| 1414 | } |
| 1415 | |
| 1388 | 1416 | fn shrinkAtom(self: *MachO, atom_index: Atom.Index, new_block_size: u64) void { |
| 1389 | 1417 | _ = self; |
| 1390 | 1418 | _ = atom_index; |