From 9fdc32c96e3961ae2f5287483c9638051df34180 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 1 Feb 2023 09:13:49 +0100 Subject: [PATCH] link: clean up type resolution in Elf.Atom and MachO.Atom --- src/link/Coff/Atom.zig | 2 +- src/link/Elf/Atom.zig | 4 ++-- src/link/MachO/Atom.zig | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/link/Coff/Atom.zig b/src/link/Coff/Atom.zig index 1ee31cccaa..80c04a8fa1 100644 --- a/src/link/Coff/Atom.zig +++ b/src/link/Coff/Atom.zig @@ -119,7 +119,7 @@ pub fn addBaseRelocation(coff_file: *Coff, atom_index: Index, offset: u32) !void try gop.value_ptr.append(gpa, offset); } -pub fn freeRelocations(coff_file: *Coff, atom_index: Atom.Index) void { +pub fn freeRelocations(coff_file: *Coff, atom_index: Index) void { const gpa = coff_file.base.allocator; var removed_relocs = coff_file.relocs.fetchRemove(atom_index); if (removed_relocs) |*relocs| relocs.value.deinit(gpa); diff --git a/src/link/Elf/Atom.zig b/src/link/Elf/Atom.zig index 79b699636f..24cf19432c 100644 --- a/src/link/Elf/Atom.zig +++ b/src/link/Elf/Atom.zig @@ -20,8 +20,8 @@ offset_table_index: u32, /// Points to the previous and next neighbors, based on the `text_offset`. /// This can be used to find, for example, the capacity of this `TextBlock`. -prev_index: ?Atom.Index, -next_index: ?Atom.Index, +prev_index: ?Index, +next_index: ?Index, dbg_info_atom: Dwarf.Atom, diff --git a/src/link/MachO/Atom.zig b/src/link/MachO/Atom.zig index da0115d069..401d71813c 100644 --- a/src/link/MachO/Atom.zig +++ b/src/link/MachO/Atom.zig @@ -40,8 +40,8 @@ alignment: u32, /// Points to the previous and next neighbours /// TODO use the same trick as with symbols: reserve index 0 as null atom -next_index: ?Atom.Index, -prev_index: ?Atom.Index, +next_index: ?Index, +prev_index: ?Index, dbg_info_atom: Dwarf.Atom, @@ -119,13 +119,13 @@ pub fn freeListEligible(self: Atom, macho_file: *MachO) bool { return surplus >= MachO.min_text_capacity; } -pub fn addRelocation(macho_file: *MachO, atom_index: Atom.Index, reloc: Relocation) !void { +pub fn addRelocation(macho_file: *MachO, atom_index: Index, reloc: Relocation) !void { return addRelocations(macho_file, atom_index, 1, .{reloc}); } pub fn addRelocations( macho_file: *MachO, - atom_index: Atom.Index, + atom_index: Index, comptime count: comptime_int, relocs: [count]Relocation, ) !void { @@ -145,7 +145,7 @@ pub fn addRelocations( } } -pub fn addRebase(macho_file: *MachO, atom_index: Atom.Index, offset: u32) !void { +pub fn addRebase(macho_file: *MachO, atom_index: Index, offset: u32) !void { const gpa = macho_file.base.allocator; const atom = macho_file.getAtom(atom_index); log.debug(" (adding rebase at offset 0x{x} in %{?d})", .{ offset, atom.getSymbolIndex() }); @@ -156,7 +156,7 @@ pub fn addRebase(macho_file: *MachO, atom_index: Atom.Index, offset: u32) !void try gop.value_ptr.append(gpa, offset); } -pub fn addBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Binding) !void { +pub fn addBinding(macho_file: *MachO, atom_index: Index, binding: Binding) !void { const gpa = macho_file.base.allocator; const atom = macho_file.getAtom(atom_index); log.debug(" (adding binding to symbol {s} at offset 0x{x} in %{?d})", .{ @@ -171,7 +171,7 @@ pub fn addBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Binding) try gop.value_ptr.append(gpa, binding); } -pub fn addLazyBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Binding) !void { +pub fn addLazyBinding(macho_file: *MachO, atom_index: Index, binding: Binding) !void { const gpa = macho_file.base.allocator; const atom = macho_file.getAtom(atom_index); log.debug(" (adding lazy binding to symbol {s} at offset 0x{x} in %{?d})", .{ @@ -186,7 +186,7 @@ pub fn addLazyBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Bindi try gop.value_ptr.append(gpa, binding); } -pub fn resolveRelocations(macho_file: *MachO, atom_index: Atom.Index) !void { +pub fn resolveRelocations(macho_file: *MachO, atom_index: Index) !void { const atom = macho_file.getAtom(atom_index); const relocs = macho_file.relocs.get(atom_index) orelse return; const source_sym = atom.getSymbol(macho_file); @@ -203,7 +203,7 @@ pub fn resolveRelocations(macho_file: *MachO, atom_index: Atom.Index) !void { } } -pub fn freeRelocations(macho_file: *MachO, atom_index: Atom.Index) void { +pub fn freeRelocations(macho_file: *MachO, atom_index: Index) void { const gpa = macho_file.base.allocator; var removed_relocs = macho_file.relocs.fetchOrderedRemove(atom_index); if (removed_relocs) |*relocs| relocs.value.deinit(gpa);