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