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 {...@@ -2230,13 +2230,6 @@ fn allocateLocals(self: *MachO) !void {
2230 base_vaddr,2230 base_vaddr,
2231 });2231 });
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
2240 // Update each symbol contained within the atom2233 // Update each symbol contained within the atom
2241 for (atom.contained.items) |sym_at_off| {2234 for (atom.contained.items) |sym_at_off| {
2242 const contained_sym = &self.locals.items[sym_at_off.local_sym_index];2235 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...@@ -2260,11 +2253,6 @@ fn shiftLocalsByOffset(self: *MachO, match: MatchingSection, offset: i64) !void
2260 const atom_sym = &self.locals.items[atom.local_sym_index];2253 const atom_sym = &self.locals.items[atom.local_sym_index];
2261 atom_sym.n_value = @intCast(u64, @intCast(i64, atom_sym.n_value) + offset);2254 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
2268 for (atom.contained.items) |sym_at_off| {2256 for (atom.contained.items) |sym_at_off| {
2269 const contained_sym = &self.locals.items[sym_at_off.local_sym_index];2257 const contained_sym = &self.locals.items[sym_at_off.local_sym_index];
2270 contained_sym.n_value = @intCast(u64, @intCast(i64, contained_sym.n_value) + offset);2258 contained_sym.n_value = @intCast(u64, @intCast(i64, contained_sym.n_value) + offset);
...@@ -3463,13 +3451,6 @@ fn parseObjectsIntoAtoms(self: *MachO) !void {...@@ -3463,13 +3451,6 @@ fn parseObjectsIntoAtoms(self: *MachO) !void {
3463 atom.alignment,3451 atom.alignment,
3464 });3452 });
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
3473 // Update each symbol contained within the atom3454 // Update each symbol contained within the atom
3474 for (atom.contained.items) |sym_at_off| {3455 for (atom.contained.items) |sym_at_off| {
3475 const contained_sym = &self.locals.items[sym_at_off.local_sym_index];3456 const contained_sym = &self.locals.items[sym_at_off.local_sym_index];
...@@ -6463,17 +6444,11 @@ fn writeSymbolTable(self: *MachO) !void {...@@ -6463,17 +6444,11 @@ fn writeSymbolTable(self: *MachO) !void {
6463 });6444 });
64646445
6465 for (object.contained_atoms.items) |atom| {6446 for (object.contained_atoms.items) |atom| {
6466 if (atom.stab) |stab| {6447 for (atom.contained.items) |sym_at_off| {
6467 const nlists = try stab.asNlists(atom.local_sym_index, self);6448 const stab = sym_at_off.stab orelse continue;
6449 const nlists = try stab.asNlists(sym_at_off.local_sym_index, self);
6468 defer self.base.allocator.free(nlists);6450 defer self.base.allocator.free(nlists);
6469 try locals.appendSlice(nlists);6451 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 }
6477 }6452 }
6478 }6453 }
64796454
...@@ -6929,8 +6904,10 @@ fn snapshotState(self: *MachO) !void {...@@ -6929,8 +6904,10 @@ fn snapshotState(self: *MachO) !void {
6929 };6904 };
69306905
6931 var aliases = std.ArrayList([]const u8).init(arena);6906 var aliases = std.ArrayList([]const u8).init(arena);
6932 for (atom.aliases.items) |loc| {6907 for (atom.contained.items) |sym_off| {
6933 try aliases.append(self.getString(self.locals.items[loc].n_strx));6908 if (sym_off.offset == 0) {
6909 try aliases.append(self.getString(self.locals.items[sym_off.local_sym_index].n_strx));
6910 }
6934 }6911 }
6935 node.payload.aliases = aliases.toOwnedSlice();6912 node.payload.aliases = aliases.toOwnedSlice();
6936 try nodes.append(node);6913 try nodes.append(node);
src/link/MachO/Atom.zig-11
...@@ -26,9 +26,6 @@ const StringIndexAdapter = std.hash_map.StringIndexAdapter;...@@ -26,9 +26,6 @@ const StringIndexAdapter = std.hash_map.StringIndexAdapter;
26/// offset table entry.26/// offset table entry.
27local_sym_index: u32,27local_sym_index: u32,
2828
29/// List of symbol aliases pointing to the same atom via different nlists
30aliases: std.ArrayListUnmanaged(u32) = .{},
31
32/// List of symbols contained within this atom29/// List of symbols contained within this atom
33contained: std.ArrayListUnmanaged(SymbolAtOffset) = .{},30contained: std.ArrayListUnmanaged(SymbolAtOffset) = .{},
3431
...@@ -62,12 +59,6 @@ lazy_bindings: std.ArrayListUnmanaged(Binding) = .{},...@@ -62,12 +59,6 @@ lazy_bindings: std.ArrayListUnmanaged(Binding) = .{},
62/// List of data-in-code entries. This is currently specific to x86_64 only.59/// List of data-in-code entries. This is currently specific to x86_64 only.
63dices: std.ArrayListUnmanaged(macho.data_in_code_entry) = .{},60dices: 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
71/// Points to the previous and next neighbours62/// Points to the previous and next neighbours
72next: ?*Atom,63next: ?*Atom,
73prev: ?*Atom,64prev: ?*Atom,
...@@ -192,7 +183,6 @@ pub fn deinit(self: *Atom, allocator: Allocator) void {...@@ -192,7 +183,6 @@ pub fn deinit(self: *Atom, allocator: Allocator) void {
192 self.rebases.deinit(allocator);183 self.rebases.deinit(allocator);
193 self.relocs.deinit(allocator);184 self.relocs.deinit(allocator);
194 self.contained.deinit(allocator);185 self.contained.deinit(allocator);
195 self.aliases.deinit(allocator);
196 self.code.deinit(allocator);186 self.code.deinit(allocator);
197}187}
198188
...@@ -203,7 +193,6 @@ pub fn clearRetainingCapacity(self: *Atom) void {...@@ -203,7 +193,6 @@ pub fn clearRetainingCapacity(self: *Atom) void {
203 self.rebases.clearRetainingCapacity();193 self.rebases.clearRetainingCapacity();
204 self.relocs.clearRetainingCapacity();194 self.relocs.clearRetainingCapacity();
205 self.contained.clearRetainingCapacity();195 self.contained.clearRetainingCapacity();
206 self.aliases.clearRetainingCapacity();
207 self.code.clearRetainingCapacity();196 self.code.clearRetainingCapacity();
208}197}
209198