macho: remove unused fields from Atom

This commit is contained in:
Jakub Konka 2022-07-06 08:41:13 +02:00
parent 03feea0fb2
commit 843701d0fe
2 changed files with 7 additions and 41 deletions

View File

@ -2230,13 +2230,6 @@ fn allocateLocals(self: *MachO) !void {
base_vaddr,
});
// Update each alias (if any)
for (atom.aliases.items) |index| {
const alias_sym = &self.locals.items[index];
alias_sym.n_value = base_vaddr;
alias_sym.n_sect = n_sect;
}
// Update each symbol contained within the atom
for (atom.contained.items) |sym_at_off| {
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
const atom_sym = &self.locals.items[atom.local_sym_index];
atom_sym.n_value = @intCast(u64, @intCast(i64, atom_sym.n_value) + offset);
for (atom.aliases.items) |index| {
const alias_sym = &self.locals.items[index];
alias_sym.n_value = @intCast(u64, @intCast(i64, alias_sym.n_value) + offset);
}
for (atom.contained.items) |sym_at_off| {
const contained_sym = &self.locals.items[sym_at_off.local_sym_index];
contained_sym.n_value = @intCast(u64, @intCast(i64, contained_sym.n_value) + offset);
@ -3463,13 +3451,6 @@ fn parseObjectsIntoAtoms(self: *MachO) !void {
atom.alignment,
});
// Update each alias (if any)
for (atom.aliases.items) |index| {
const alias_sym = &self.locals.items[index];
alias_sym.n_value = base_vaddr;
alias_sym.n_sect = n_sect;
}
// Update each symbol contained within the atom
for (atom.contained.items) |sym_at_off| {
const contained_sym = &self.locals.items[sym_at_off.local_sym_index];
@ -6463,17 +6444,11 @@ fn writeSymbolTable(self: *MachO) !void {
});
for (object.contained_atoms.items) |atom| {
if (atom.stab) |stab| {
const nlists = try stab.asNlists(atom.local_sym_index, self);
for (atom.contained.items) |sym_at_off| {
const stab = sym_at_off.stab orelse continue;
const nlists = try stab.asNlists(sym_at_off.local_sym_index, self);
defer self.base.allocator.free(nlists);
try locals.appendSlice(nlists);
} else {
for (atom.contained.items) |sym_at_off| {
const stab = sym_at_off.stab orelse continue;
const nlists = try stab.asNlists(sym_at_off.local_sym_index, self);
defer self.base.allocator.free(nlists);
try locals.appendSlice(nlists);
}
}
}
@ -6929,8 +6904,10 @@ fn snapshotState(self: *MachO) !void {
};
var aliases = std.ArrayList([]const u8).init(arena);
for (atom.aliases.items) |loc| {
try aliases.append(self.getString(self.locals.items[loc].n_strx));
for (atom.contained.items) |sym_off| {
if (sym_off.offset == 0) {
try aliases.append(self.getString(self.locals.items[sym_off.local_sym_index].n_strx));
}
}
node.payload.aliases = aliases.toOwnedSlice();
try nodes.append(node);

View File

@ -26,9 +26,6 @@ const StringIndexAdapter = std.hash_map.StringIndexAdapter;
/// offset table entry.
local_sym_index: u32,
/// List of symbol aliases pointing to the same atom via different nlists
aliases: std.ArrayListUnmanaged(u32) = .{},
/// List of symbols contained within this atom
contained: std.ArrayListUnmanaged(SymbolAtOffset) = .{},
@ -62,12 +59,6 @@ lazy_bindings: std.ArrayListUnmanaged(Binding) = .{},
/// List of data-in-code entries. This is currently specific to x86_64 only.
dices: std.ArrayListUnmanaged(macho.data_in_code_entry) = .{},
/// Stab entry for this atom. This is currently specific to a binary created
/// by linking object files in a traditional sense - in incremental sense, we
/// bypass stabs altogether to produce dSYM bundle directly with fully relocated
/// DWARF sections.
stab: ?Stab = null,
/// Points to the previous and next neighbours
next: ?*Atom,
prev: ?*Atom,
@ -192,7 +183,6 @@ pub fn deinit(self: *Atom, allocator: Allocator) void {
self.rebases.deinit(allocator);
self.relocs.deinit(allocator);
self.contained.deinit(allocator);
self.aliases.deinit(allocator);
self.code.deinit(allocator);
}
@ -203,7 +193,6 @@ pub fn clearRetainingCapacity(self: *Atom) void {
self.rebases.clearRetainingCapacity();
self.relocs.clearRetainingCapacity();
self.contained.clearRetainingCapacity();
self.aliases.clearRetainingCapacity();
self.code.clearRetainingCapacity();
}