authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-07-06 08:41:13+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-07-22 16:58:20+02:00
log843701d0feb683810f6be3cb5d6406eddb5539d0
treed99d6f6f9d765560e67064b76855abcd7face0b0
parent03feea0fb200f273dd74bf778997e6a6bead86cc

macho: remove unused fields from Atom


2 files changed, 7 insertions(+), 41 deletions(-)

src/link/MachO.zig+7-30
......@@ -2230,13 +2230,6 @@ fn allocateLocals(self: *MachO) !void {
22302230 base_vaddr,
22312231 });
22322232
2233 // Update each alias (if any)
2234 for (atom.aliases.items) |index| {
2235 const alias_sym = &self.locals.items[index];
2236 alias_sym.n_value = base_vaddr;
2237 alias_sym.n_sect = n_sect;
2238 }
2239
22402233 // Update each symbol contained within the atom
22412234 for (atom.contained.items) |sym_at_off| {
22422235 const contained_sym = &self.locals.items[sym_at_off.local_sym_index];
......@@ -2260,11 +2253,6 @@ fn shiftLocalsByOffset(self: *MachO, match: MatchingSection, offset: i64) !void
22602253 const atom_sym = &self.locals.items[atom.local_sym_index];
22612254 atom_sym.n_value = @intCast(u64, @intCast(i64, atom_sym.n_value) + offset);
22622255
2263 for (atom.aliases.items) |index| {
2264 const alias_sym = &self.locals.items[index];
2265 alias_sym.n_value = @intCast(u64, @intCast(i64, alias_sym.n_value) + offset);
2266 }
2267
22682256 for (atom.contained.items) |sym_at_off| {
22692257 const contained_sym = &self.locals.items[sym_at_off.local_sym_index];
22702258 contained_sym.n_value = @intCast(u64, @intCast(i64, contained_sym.n_value) + offset);
......@@ -3463,13 +3451,6 @@ fn parseObjectsIntoAtoms(self: *MachO) !void {
34633451 atom.alignment,
34643452 });
34653453
3466 // Update each alias (if any)
3467 for (atom.aliases.items) |index| {
3468 const alias_sym = &self.locals.items[index];
3469 alias_sym.n_value = base_vaddr;
3470 alias_sym.n_sect = n_sect;
3471 }
3472
34733454 // Update each symbol contained within the atom
34743455 for (atom.contained.items) |sym_at_off| {
34753456 const contained_sym = &self.locals.items[sym_at_off.local_sym_index];
......@@ -6463,17 +6444,11 @@ fn writeSymbolTable(self: *MachO) !void {
64636444 });
64646445
64656446 for (object.contained_atoms.items) |atom| {
6466 if (atom.stab) |stab| {
6467 const nlists = try stab.asNlists(atom.local_sym_index, self);
6447 for (atom.contained.items) |sym_at_off| {
6448 const stab = sym_at_off.stab orelse continue;
6449 const nlists = try stab.asNlists(sym_at_off.local_sym_index, self);
64686450 defer self.base.allocator.free(nlists);
64696451 try locals.appendSlice(nlists);
6470 } else {
6471 for (atom.contained.items) |sym_at_off| {
6472 const stab = sym_at_off.stab orelse continue;
6473 const nlists = try stab.asNlists(sym_at_off.local_sym_index, self);
6474 defer self.base.allocator.free(nlists);
6475 try locals.appendSlice(nlists);
6476 }
64776452 }
64786453 }
64796454
......@@ -6929,8 +6904,10 @@ fn snapshotState(self: *MachO) !void {
69296904 };
69306905
69316906 var aliases = std.ArrayList([]const u8).init(arena);
6932 for (atom.aliases.items) |loc| {
6933 try aliases.append(self.getString(self.locals.items[loc].n_strx));
6907 for (atom.contained.items) |sym_off| {
6908 if (sym_off.offset == 0) {
6909 try aliases.append(self.getString(self.locals.items[sym_off.local_sym_index].n_strx));
6910 }
69346911 }
69356912 node.payload.aliases = aliases.toOwnedSlice();
69366913 try nodes.append(node);
src/link/MachO/Atom.zig-11
......@@ -26,9 +26,6 @@ const StringIndexAdapter = std.hash_map.StringIndexAdapter;
2626/// offset table entry.
2727local_sym_index: u32,
2828
29/// List of symbol aliases pointing to the same atom via different nlists
30aliases: std.ArrayListUnmanaged(u32) = .{},
31
3229/// List of symbols contained within this atom
3330contained: std.ArrayListUnmanaged(SymbolAtOffset) = .{},
3431
......@@ -62,12 +59,6 @@ lazy_bindings: std.ArrayListUnmanaged(Binding) = .{},
6259/// List of data-in-code entries. This is currently specific to x86_64 only.
6360dices: std.ArrayListUnmanaged(macho.data_in_code_entry) = .{},
6461
65/// Stab entry for this atom. This is currently specific to a binary created
66/// by linking object files in a traditional sense - in incremental sense, we
67/// bypass stabs altogether to produce dSYM bundle directly with fully relocated
68/// DWARF sections.
69stab: ?Stab = null,
70
7162/// Points to the previous and next neighbours
7263next: ?*Atom,
7364prev: ?*Atom,
......@@ -192,7 +183,6 @@ pub fn deinit(self: *Atom, allocator: Allocator) void {
192183 self.rebases.deinit(allocator);
193184 self.relocs.deinit(allocator);
194185 self.contained.deinit(allocator);
195 self.aliases.deinit(allocator);
196186 self.code.deinit(allocator);
197187}
198188
......@@ -203,7 +193,6 @@ pub fn clearRetainingCapacity(self: *Atom) void {
203193 self.rebases.clearRetainingCapacity();
204194 self.relocs.clearRetainingCapacity();
205195 self.contained.clearRetainingCapacity();
206 self.aliases.clearRetainingCapacity();
207196 self.code.clearRetainingCapacity();
208197}
209198