authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-02-01 09:13:49+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-02-01 09:13:49+01:00
log9fdc32c96e3961ae2f5287483c9638051df34180
tree6e6d6ca89cf83d91e46f16da58fc92d1a315aca1
parentc430e9afa7b050400b9703360a0af4ab824335ce

link: clean up type resolution in Elf.Atom and MachO.Atom


3 files changed, 12 insertions(+), 12 deletions(-)

src/link/Coff/Atom.zig+1-1
......@@ -119,7 +119,7 @@ pub fn addBaseRelocation(coff_file: *Coff, atom_index: Index, offset: u32) !void
119119 try gop.value_ptr.append(gpa, offset);
120120}
121121
122pub fn freeRelocations(coff_file: *Coff, atom_index: Atom.Index) void {
122pub fn freeRelocations(coff_file: *Coff, atom_index: Index) void {
123123 const gpa = coff_file.base.allocator;
124124 var removed_relocs = coff_file.relocs.fetchRemove(atom_index);
125125 if (removed_relocs) |*relocs| relocs.value.deinit(gpa);
src/link/Elf/Atom.zig+2-2
......@@ -20,8 +20,8 @@ offset_table_index: u32,
2020
2121/// Points to the previous and next neighbors, based on the `text_offset`.
2222/// This can be used to find, for example, the capacity of this `TextBlock`.
23prev_index: ?Atom.Index,
24next_index: ?Atom.Index,
23prev_index: ?Index,
24next_index: ?Index,
2525
2626dbg_info_atom: Dwarf.Atom,
2727
src/link/MachO/Atom.zig+9-9
......@@ -40,8 +40,8 @@ alignment: u32,
4040
4141/// Points to the previous and next neighbours
4242/// TODO use the same trick as with symbols: reserve index 0 as null atom
43next_index: ?Atom.Index,
44prev_index: ?Atom.Index,
43next_index: ?Index,
44prev_index: ?Index,
4545
4646dbg_info_atom: Dwarf.Atom,
4747
......@@ -119,13 +119,13 @@ pub fn freeListEligible(self: Atom, macho_file: *MachO) bool {
119119 return surplus >= MachO.min_text_capacity;
120120}
121121
122pub fn addRelocation(macho_file: *MachO, atom_index: Atom.Index, reloc: Relocation) !void {
122pub fn addRelocation(macho_file: *MachO, atom_index: Index, reloc: Relocation) !void {
123123 return addRelocations(macho_file, atom_index, 1, .{reloc});
124124}
125125
126126pub fn addRelocations(
127127 macho_file: *MachO,
128 atom_index: Atom.Index,
128 atom_index: Index,
129129 comptime count: comptime_int,
130130 relocs: [count]Relocation,
131131) !void {
......@@ -145,7 +145,7 @@ pub fn addRelocations(
145145 }
146146}
147147
148pub fn addRebase(macho_file: *MachO, atom_index: Atom.Index, offset: u32) !void {
148pub fn addRebase(macho_file: *MachO, atom_index: Index, offset: u32) !void {
149149 const gpa = macho_file.base.allocator;
150150 const atom = macho_file.getAtom(atom_index);
151151 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
156156 try gop.value_ptr.append(gpa, offset);
157157}
158158
159pub fn addBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Binding) !void {
159pub fn addBinding(macho_file: *MachO, atom_index: Index, binding: Binding) !void {
160160 const gpa = macho_file.base.allocator;
161161 const atom = macho_file.getAtom(atom_index);
162162 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)
171171 try gop.value_ptr.append(gpa, binding);
172172}
173173
174pub fn addLazyBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Binding) !void {
174pub fn addLazyBinding(macho_file: *MachO, atom_index: Index, binding: Binding) !void {
175175 const gpa = macho_file.base.allocator;
176176 const atom = macho_file.getAtom(atom_index);
177177 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
186186 try gop.value_ptr.append(gpa, binding);
187187}
188188
189pub fn resolveRelocations(macho_file: *MachO, atom_index: Atom.Index) !void {
189pub fn resolveRelocations(macho_file: *MachO, atom_index: Index) !void {
190190 const atom = macho_file.getAtom(atom_index);
191191 const relocs = macho_file.relocs.get(atom_index) orelse return;
192192 const source_sym = atom.getSymbol(macho_file);
......@@ -203,7 +203,7 @@ pub fn resolveRelocations(macho_file: *MachO, atom_index: Atom.Index) !void {
203203 }
204204}
205205
206pub fn freeRelocations(macho_file: *MachO, atom_index: Atom.Index) void {
206pub fn freeRelocations(macho_file: *MachO, atom_index: Index) void {
207207 const gpa = macho_file.base.allocator;
208208 var removed_relocs = macho_file.relocs.fetchOrderedRemove(atom_index);
209209 if (removed_relocs) |*relocs| relocs.value.deinit(gpa);