authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-28 21:52:44+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-28 21:52:44+02:00
log17ec2cea6455148526f56fa17cb704fd1d656b06
tree5bb76051de4b95dd7cf2e651e981b75056b8e392
parentcde722a7117b6da129d3c49dabd445136ed5edb5

macho: remove error_union return from resolveRelocations()


3 files changed, 8 insertions(+), 18 deletions(-)

src/link/MachO.zig+1-1
......@@ -1091,7 +1091,7 @@ pub fn writeAtom(self: *MachO, atom_index: Atom.Index, code: []u8) !void {
10911091 log.debug("writing atom for symbol {s} at file offset 0x{x}", .{ atom.getName(self), file_offset });
10921092
10931093 if (self.relocs.get(atom_index)) |relocs| {
1094 try Atom.resolveRelocations(self, atom_index, relocs.items, code);
1094 Atom.resolveRelocations(self, atom_index, relocs.items, code);
10951095 }
10961096
10971097 if (is_hot_update_compatible) {
src/link/MachO/Atom.zig+2-2
......@@ -183,11 +183,11 @@ pub fn addLazyBinding(macho_file: *MachO, atom_index: Index, binding: Binding) !
183183 try gop.value_ptr.append(gpa, binding);
184184}
185185
186pub fn resolveRelocations(macho_file: *MachO, atom_index: Index, relocs: []Relocation, code: []u8) !void {
186pub fn resolveRelocations(macho_file: *MachO, atom_index: Index, relocs: []Relocation, code: []u8) void {
187187 log.debug("relocating '{s}'", .{macho_file.getAtom(atom_index).getName(macho_file)});
188188 for (relocs) |*reloc| {
189189 if (!reloc.dirty) continue;
190 try reloc.resolve(macho_file, atom_index, code);
190 reloc.resolve(macho_file, atom_index, code);
191191 reloc.dirty = false;
192192 }
193193}
src/link/MachO/Relocation.zig+5-15
......@@ -50,7 +50,7 @@ pub fn getTargetAtomIndex(self: Relocation, macho_file: *MachO) ?Atom.Index {
5050 return macho_file.getAtomIndexForSymbol(self.target);
5151}
5252
53pub fn resolve(self: Relocation, macho_file: *MachO, atom_index: Atom.Index, code: []u8) !void {
53pub fn resolve(self: Relocation, macho_file: *MachO, atom_index: Atom.Index, code: []u8) void {
5454 const arch = macho_file.base.options.target.cpu.arch;
5555 const atom = macho_file.getAtom(atom_index);
5656 const source_sym = atom.getSymbol(macho_file);
......@@ -68,18 +68,13 @@ pub fn resolve(self: Relocation, macho_file: *MachO, atom_index: Atom.Index, cod
6868 });
6969
7070 switch (arch) {
71 .aarch64 => return self.resolveAarch64(source_addr, target_addr, code),
72 .x86_64 => return self.resolveX8664(source_addr, target_addr, code),
71 .aarch64 => self.resolveAarch64(source_addr, target_addr, code),
72 .x86_64 => self.resolveX8664(source_addr, target_addr, code),
7373 else => unreachable,
7474 }
7575}
7676
77fn resolveAarch64(
78 self: Relocation,
79 source_addr: u64,
80 target_addr: i64,
81 code: []u8,
82) !void {
77fn resolveAarch64(self: Relocation, source_addr: u64, target_addr: i64, code: []u8) void {
8378 const rel_type = @intToEnum(macho.reloc_type_arm64, self.type);
8479 if (rel_type == .ARM64_RELOC_UNSIGNED) {
8580 return switch (self.length) {
......@@ -212,12 +207,7 @@ fn resolveAarch64(
212207 }
213208}
214209
215fn resolveX8664(
216 self: Relocation,
217 source_addr: u64,
218 target_addr: i64,
219 code: []u8,
220) !void {
210fn resolveX8664(self: Relocation, source_addr: u64, target_addr: i64, code: []u8) void {
221211 const rel_type = @intToEnum(macho.reloc_type_x86_64, self.type);
222212 switch (rel_type) {
223213 .X86_64_RELOC_BRANCH,