From 17ec2cea6455148526f56fa17cb704fd1d656b06 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 28 Mar 2023 21:52:44 +0200 Subject: [PATCH] macho: remove error_union return from resolveRelocations() --- src/link/MachO.zig | 2 +- src/link/MachO/Atom.zig | 4 ++-- src/link/MachO/Relocation.zig | 20 +++++--------------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 885afd37c3..3206b63fa3 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -1091,7 +1091,7 @@ pub fn writeAtom(self: *MachO, atom_index: Atom.Index, code: []u8) !void { log.debug("writing atom for symbol {s} at file offset 0x{x}", .{ atom.getName(self), file_offset }); if (self.relocs.get(atom_index)) |relocs| { - try Atom.resolveRelocations(self, atom_index, relocs.items, code); + Atom.resolveRelocations(self, atom_index, relocs.items, code); } if (is_hot_update_compatible) { diff --git a/src/link/MachO/Atom.zig b/src/link/MachO/Atom.zig index 36511dfd78..698e961db4 100644 --- a/src/link/MachO/Atom.zig +++ b/src/link/MachO/Atom.zig @@ -183,11 +183,11 @@ pub fn addLazyBinding(macho_file: *MachO, atom_index: Index, binding: Binding) ! try gop.value_ptr.append(gpa, binding); } -pub fn resolveRelocations(macho_file: *MachO, atom_index: Index, relocs: []Relocation, code: []u8) !void { +pub fn resolveRelocations(macho_file: *MachO, atom_index: Index, relocs: []Relocation, code: []u8) void { log.debug("relocating '{s}'", .{macho_file.getAtom(atom_index).getName(macho_file)}); for (relocs) |*reloc| { if (!reloc.dirty) continue; - try reloc.resolve(macho_file, atom_index, code); + reloc.resolve(macho_file, atom_index, code); reloc.dirty = false; } } diff --git a/src/link/MachO/Relocation.zig b/src/link/MachO/Relocation.zig index 6beae8e8ea..cc565742d1 100644 --- a/src/link/MachO/Relocation.zig +++ b/src/link/MachO/Relocation.zig @@ -50,7 +50,7 @@ pub fn getTargetAtomIndex(self: Relocation, macho_file: *MachO) ?Atom.Index { return macho_file.getAtomIndexForSymbol(self.target); } -pub fn resolve(self: Relocation, macho_file: *MachO, atom_index: Atom.Index, code: []u8) !void { +pub fn resolve(self: Relocation, macho_file: *MachO, atom_index: Atom.Index, code: []u8) void { const arch = macho_file.base.options.target.cpu.arch; const atom = macho_file.getAtom(atom_index); const source_sym = atom.getSymbol(macho_file); @@ -68,18 +68,13 @@ pub fn resolve(self: Relocation, macho_file: *MachO, atom_index: Atom.Index, cod }); switch (arch) { - .aarch64 => return self.resolveAarch64(source_addr, target_addr, code), - .x86_64 => return self.resolveX8664(source_addr, target_addr, code), + .aarch64 => self.resolveAarch64(source_addr, target_addr, code), + .x86_64 => self.resolveX8664(source_addr, target_addr, code), else => unreachable, } } -fn resolveAarch64( - self: Relocation, - source_addr: u64, - target_addr: i64, - code: []u8, -) !void { +fn resolveAarch64(self: Relocation, source_addr: u64, target_addr: i64, code: []u8) void { const rel_type = @intToEnum(macho.reloc_type_arm64, self.type); if (rel_type == .ARM64_RELOC_UNSIGNED) { return switch (self.length) { @@ -212,12 +207,7 @@ fn resolveAarch64( } } -fn resolveX8664( - self: Relocation, - source_addr: u64, - target_addr: i64, - code: []u8, -) !void { +fn resolveX8664(self: Relocation, source_addr: u64, target_addr: i64, code: []u8) void { const rel_type = @intToEnum(macho.reloc_type_x86_64, self.type); switch (rel_type) { .X86_64_RELOC_BRANCH,