| ... | @@ -40,8 +40,8 @@ alignment: u32, | ... | @@ -40,8 +40,8 @@ alignment: u32, |
| 40 | | 40 | |
| 41 | /// Points to the previous and next neighbours | 41 | /// Points to the previous and next neighbours |
| 42 | /// TODO use the same trick as with symbols: reserve index 0 as null atom | 42 | /// TODO use the same trick as with symbols: reserve index 0 as null atom |
| 43 | next_index: ?Atom.Index, | 43 | next_index: ?Index, |
| 44 | prev_index: ?Atom.Index, | 44 | prev_index: ?Index, |
| 45 | | 45 | |
| 46 | dbg_info_atom: Dwarf.Atom, | 46 | dbg_info_atom: Dwarf.Atom, |
| 47 | | 47 | |
| ... | @@ -119,13 +119,13 @@ pub fn freeListEligible(self: Atom, macho_file: *MachO) bool { | ... | @@ -119,13 +119,13 @@ pub fn freeListEligible(self: Atom, macho_file: *MachO) bool { |
| 119 | return surplus >= MachO.min_text_capacity; | 119 | return surplus >= MachO.min_text_capacity; |
| 120 | } | 120 | } |
| 121 | | 121 | |
| 122 | pub fn addRelocation(macho_file: *MachO, atom_index: Atom.Index, reloc: Relocation) !void { | 122 | pub fn addRelocation(macho_file: *MachO, atom_index: Index, reloc: Relocation) !void { |
| 123 | return addRelocations(macho_file, atom_index, 1, .{reloc}); | 123 | return addRelocations(macho_file, atom_index, 1, .{reloc}); |
| 124 | } | 124 | } |
| 125 | | 125 | |
| 126 | pub fn addRelocations( | 126 | pub fn addRelocations( |
| 127 | macho_file: *MachO, | 127 | macho_file: *MachO, |
| 128 | atom_index: Atom.Index, | 128 | atom_index: Index, |
| 129 | comptime count: comptime_int, | 129 | comptime count: comptime_int, |
| 130 | relocs: [count]Relocation, | 130 | relocs: [count]Relocation, |
| 131 | ) !void { | 131 | ) !void { |
| ... | @@ -145,7 +145,7 @@ pub fn addRelocations( | ... | @@ -145,7 +145,7 @@ pub fn addRelocations( |
| 145 | } | 145 | } |
| 146 | } | 146 | } |
| 147 | | 147 | |
| 148 | pub fn addRebase(macho_file: *MachO, atom_index: Atom.Index, offset: u32) !void { | 148 | pub fn addRebase(macho_file: *MachO, atom_index: Index, offset: u32) !void { |
| 149 | const gpa = macho_file.base.allocator; | 149 | const gpa = macho_file.base.allocator; |
| 150 | const atom = macho_file.getAtom(atom_index); | 150 | const atom = macho_file.getAtom(atom_index); |
| 151 | log.debug(" (adding rebase at offset 0x{x} in %{?d})", .{ offset, atom.getSymbolIndex() }); | 151 | 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 | ... | @@ -156,7 +156,7 @@ pub fn addRebase(macho_file: *MachO, atom_index: Atom.Index, offset: u32) !void |
| 156 | try gop.value_ptr.append(gpa, offset); | 156 | try gop.value_ptr.append(gpa, offset); |
| 157 | } | 157 | } |
| 158 | | 158 | |
| 159 | pub fn addBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Binding) !void { | 159 | pub fn addBinding(macho_file: *MachO, atom_index: Index, binding: Binding) !void { |
| 160 | const gpa = macho_file.base.allocator; | 160 | const gpa = macho_file.base.allocator; |
| 161 | const atom = macho_file.getAtom(atom_index); | 161 | const atom = macho_file.getAtom(atom_index); |
| 162 | log.debug(" (adding binding to symbol {s} at offset 0x{x} in %{?d})", .{ | 162 | 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) | ... | @@ -171,7 +171,7 @@ pub fn addBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Binding) |
| 171 | try gop.value_ptr.append(gpa, binding); | 171 | try gop.value_ptr.append(gpa, binding); |
| 172 | } | 172 | } |
| 173 | | 173 | |
| 174 | pub fn addLazyBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Binding) !void { | 174 | pub fn addLazyBinding(macho_file: *MachO, atom_index: Index, binding: Binding) !void { |
| 175 | const gpa = macho_file.base.allocator; | 175 | const gpa = macho_file.base.allocator; |
| 176 | const atom = macho_file.getAtom(atom_index); | 176 | const atom = macho_file.getAtom(atom_index); |
| 177 | log.debug(" (adding lazy binding to symbol {s} at offset 0x{x} in %{?d})", .{ | 177 | 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 | ... | @@ -186,7 +186,7 @@ pub fn addLazyBinding(macho_file: *MachO, atom_index: Atom.Index, binding: Bindi |
| 186 | try gop.value_ptr.append(gpa, binding); | 186 | try gop.value_ptr.append(gpa, binding); |
| 187 | } | 187 | } |
| 188 | | 188 | |
| 189 | pub fn resolveRelocations(macho_file: *MachO, atom_index: Atom.Index) !void { | 189 | pub fn resolveRelocations(macho_file: *MachO, atom_index: Index) !void { |
| 190 | const atom = macho_file.getAtom(atom_index); | 190 | const atom = macho_file.getAtom(atom_index); |
| 191 | const relocs = macho_file.relocs.get(atom_index) orelse return; | 191 | const relocs = macho_file.relocs.get(atom_index) orelse return; |
| 192 | const source_sym = atom.getSymbol(macho_file); | 192 | const source_sym = atom.getSymbol(macho_file); |
| ... | @@ -203,7 +203,7 @@ pub fn resolveRelocations(macho_file: *MachO, atom_index: Atom.Index) !void { | ... | @@ -203,7 +203,7 @@ pub fn resolveRelocations(macho_file: *MachO, atom_index: Atom.Index) !void { |
| 203 | } | 203 | } |
| 204 | } | 204 | } |
| 205 | | 205 | |
| 206 | pub fn freeRelocations(macho_file: *MachO, atom_index: Atom.Index) void { | 206 | pub fn freeRelocations(macho_file: *MachO, atom_index: Index) void { |
| 207 | const gpa = macho_file.base.allocator; | 207 | const gpa = macho_file.base.allocator; |
| 208 | var removed_relocs = macho_file.relocs.fetchOrderedRemove(atom_index); | 208 | var removed_relocs = macho_file.relocs.fetchOrderedRemove(atom_index); |
| 209 | if (removed_relocs) |*relocs| relocs.value.deinit(gpa); | 209 | if (removed_relocs) |*relocs| relocs.value.deinit(gpa); |