| ... | ... | @@ -55,8 +55,6 @@ pub const SearchStrategy = enum { |
| 55 | 55 | dylibs_first, |
| 56 | 56 | }; |
| 57 | 57 | |
| 58 | | pub const N_DESC_GCED: u16 = @bitCast(u16, @as(i16, -1)); |
| 59 | | |
| 60 | 58 | const Section = struct { |
| 61 | 59 | header: macho.section_64, |
| 62 | 60 | segment_index: u8, |
| ... | ... | @@ -3602,7 +3600,6 @@ fn collectExportData(self: *MachO, trie: *Trie) !void { |
| 3602 | 3600 | |
| 3603 | 3601 | if (sym.undf()) continue; |
| 3604 | 3602 | if (!sym.ext()) continue; |
| 3605 | | if (sym.n_desc == N_DESC_GCED) continue; |
| 3606 | 3603 | |
| 3607 | 3604 | const sym_name = self.getSymbolName(global); |
| 3608 | 3605 | log.debug(" (putting '{s}' defined at 0x{x})", .{ sym_name, sym.n_value }); |
| ... | ... | @@ -3850,7 +3847,6 @@ fn writeSymtab(self: *MachO, lc: *macho.symtab_command) !SymtabCtx { |
| 3850 | 3847 | |
| 3851 | 3848 | for (self.locals.items) |sym, sym_id| { |
| 3852 | 3849 | if (sym.n_strx == 0) continue; // no name, skip |
| 3853 | | if (sym.n_desc == N_DESC_GCED) continue; // GCed, skip |
| 3854 | 3850 | const sym_loc = SymbolWithLoc{ .sym_index = @intCast(u32, sym_id), .file = null }; |
| 3855 | 3851 | if (self.symbolIsTemp(sym_loc)) continue; // local temp symbol, skip |
| 3856 | 3852 | if (self.getGlobal(self.getSymbolName(sym_loc)) != null) continue; // global symbol is either an export or import, skip |
| ... | ... | @@ -3863,7 +3859,6 @@ fn writeSymtab(self: *MachO, lc: *macho.symtab_command) !SymtabCtx { |
| 3863 | 3859 | for (self.globals.items) |global| { |
| 3864 | 3860 | const sym = self.getSymbol(global); |
| 3865 | 3861 | if (sym.undf()) continue; // import, skip |
| 3866 | | if (sym.n_desc == N_DESC_GCED) continue; // GCed, skip |
| 3867 | 3862 | var out_sym = sym; |
| 3868 | 3863 | out_sym.n_strx = try self.strtab.insert(gpa, self.getSymbolName(global)); |
| 3869 | 3864 | try exports.append(out_sym); |
| ... | ... | @@ -3966,8 +3961,6 @@ fn writeDysymtab(self: *MachO, ctx: SymtabCtx, lc: *macho.dysymtab_command) !voi |
| 3966 | 3961 | stubs.reserved1 = 0; |
| 3967 | 3962 | for (self.stubs.items) |entry| { |
| 3968 | 3963 | if (entry.sym_index == 0) continue; |
| 3969 | | const atom_sym = entry.getSymbol(self); |
| 3970 | | if (atom_sym.n_desc == N_DESC_GCED) continue; |
| 3971 | 3964 | const target_sym = self.getSymbol(entry.target); |
| 3972 | 3965 | assert(target_sym.undf()); |
| 3973 | 3966 | try writer.writeIntLittle(u32, iundefsym + ctx.imports_table.get(entry.target).?); |
| ... | ... | @@ -3979,8 +3972,6 @@ fn writeDysymtab(self: *MachO, ctx: SymtabCtx, lc: *macho.dysymtab_command) !voi |
| 3979 | 3972 | got.reserved1 = nstubs; |
| 3980 | 3973 | for (self.got_entries.items) |entry| { |
| 3981 | 3974 | if (entry.sym_index == 0) continue; |
| 3982 | | const atom_sym = entry.getSymbol(self); |
| 3983 | | if (atom_sym.n_desc == N_DESC_GCED) continue; |
| 3984 | 3975 | const target_sym = self.getSymbol(entry.target); |
| 3985 | 3976 | if (target_sym.undf()) { |
| 3986 | 3977 | try writer.writeIntLittle(u32, iundefsym + ctx.imports_table.get(entry.target).?); |
| ... | ... | @@ -3995,8 +3986,6 @@ fn writeDysymtab(self: *MachO, ctx: SymtabCtx, lc: *macho.dysymtab_command) !voi |
| 3995 | 3986 | la_symbol_ptr.reserved1 = nstubs + ngot_entries; |
| 3996 | 3987 | for (self.stubs.items) |entry| { |
| 3997 | 3988 | if (entry.sym_index == 0) continue; |
| 3998 | | const atom_sym = entry.getSymbol(self); |
| 3999 | | if (atom_sym.n_desc == N_DESC_GCED) continue; |
| 4000 | 3989 | const target_sym = self.getSymbol(entry.target); |
| 4001 | 3990 | assert(target_sym.undf()); |
| 4002 | 3991 | try writer.writeIntLittle(u32, iundefsym + ctx.imports_table.get(entry.target).?); |
| ... | ... | @@ -4594,7 +4583,7 @@ pub fn logSections(self: *MachO) void { |
| 4594 | 4583 | } |
| 4595 | 4584 | } |
| 4596 | 4585 | |
| 4597 | | fn logSymAttributes(sym: macho.nlist_64, buf: *[9]u8) []const u8 { |
| 4586 | fn logSymAttributes(sym: macho.nlist_64, buf: *[4]u8) []const u8 { |
| 4598 | 4587 | mem.set(u8, buf[0..4], '_'); |
| 4599 | 4588 | mem.set(u8, buf[4..], ' '); |
| 4600 | 4589 | if (sym.sect()) { |
| ... | ... | @@ -4613,14 +4602,11 @@ fn logSymAttributes(sym: macho.nlist_64, buf: *[9]u8) []const u8 { |
| 4613 | 4602 | if (sym.undf()) { |
| 4614 | 4603 | buf[3] = 'u'; |
| 4615 | 4604 | } |
| 4616 | | if (sym.n_desc == N_DESC_GCED) { |
| 4617 | | mem.copy(u8, buf[5..], "DEAD"); |
| 4618 | | } |
| 4619 | 4605 | return buf[0..]; |
| 4620 | 4606 | } |
| 4621 | 4607 | |
| 4622 | 4608 | pub fn logSymtab(self: *MachO) void { |
| 4623 | | var buf: [9]u8 = undefined; |
| 4609 | var buf: [4]u8 = undefined; |
| 4624 | 4610 | |
| 4625 | 4611 | log.debug("symtab:", .{}); |
| 4626 | 4612 | for (self.locals.items) |sym, sym_id| { |
| ... | ... | @@ -4648,7 +4634,6 @@ pub fn logSymtab(self: *MachO) void { |
| 4648 | 4634 | log.debug("GOT entries:", .{}); |
| 4649 | 4635 | for (self.got_entries.items) |entry, i| { |
| 4650 | 4636 | const atom_sym = entry.getSymbol(self); |
| 4651 | | if (atom_sym.n_desc == N_DESC_GCED) continue; |
| 4652 | 4637 | const target_sym = self.getSymbol(entry.target); |
| 4653 | 4638 | if (target_sym.undf()) { |
| 4654 | 4639 | log.debug(" {d}@{x} => import('{s}')", .{ |