mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-07 06:14:33 +00:00
macho: remove error_union return from resolveRelocations()
This commit is contained in:
parent
cde722a711
commit
17ec2cea64
3 changed files with 8 additions and 18 deletions
|
|
@ -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 });
|
log.debug("writing atom for symbol {s} at file offset 0x{x}", .{ atom.getName(self), file_offset });
|
||||||
|
|
||||||
if (self.relocs.get(atom_index)) |relocs| {
|
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) {
|
if (is_hot_update_compatible) {
|
||||||
|
|
|
||||||
|
|
@ -183,11 +183,11 @@ pub fn addLazyBinding(macho_file: *MachO, atom_index: Index, binding: Binding) !
|
||||||
try gop.value_ptr.append(gpa, 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)});
|
log.debug("relocating '{s}'", .{macho_file.getAtom(atom_index).getName(macho_file)});
|
||||||
for (relocs) |*reloc| {
|
for (relocs) |*reloc| {
|
||||||
if (!reloc.dirty) continue;
|
if (!reloc.dirty) continue;
|
||||||
try reloc.resolve(macho_file, atom_index, code);
|
reloc.resolve(macho_file, atom_index, code);
|
||||||
reloc.dirty = false;
|
reloc.dirty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ pub fn getTargetAtomIndex(self: Relocation, macho_file: *MachO) ?Atom.Index {
|
||||||
return macho_file.getAtomIndexForSymbol(self.target);
|
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 arch = macho_file.base.options.target.cpu.arch;
|
||||||
const atom = macho_file.getAtom(atom_index);
|
const atom = macho_file.getAtom(atom_index);
|
||||||
const source_sym = atom.getSymbol(macho_file);
|
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) {
|
switch (arch) {
|
||||||
.aarch64 => return self.resolveAarch64(source_addr, target_addr, code),
|
.aarch64 => self.resolveAarch64(source_addr, target_addr, code),
|
||||||
.x86_64 => return self.resolveX8664(source_addr, target_addr, code),
|
.x86_64 => self.resolveX8664(source_addr, target_addr, code),
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolveAarch64(
|
fn resolveAarch64(self: Relocation, source_addr: u64, target_addr: i64, code: []u8) void {
|
||||||
self: Relocation,
|
|
||||||
source_addr: u64,
|
|
||||||
target_addr: i64,
|
|
||||||
code: []u8,
|
|
||||||
) !void {
|
|
||||||
const rel_type = @intToEnum(macho.reloc_type_arm64, self.type);
|
const rel_type = @intToEnum(macho.reloc_type_arm64, self.type);
|
||||||
if (rel_type == .ARM64_RELOC_UNSIGNED) {
|
if (rel_type == .ARM64_RELOC_UNSIGNED) {
|
||||||
return switch (self.length) {
|
return switch (self.length) {
|
||||||
|
|
@ -212,12 +207,7 @@ fn resolveAarch64(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolveX8664(
|
fn resolveX8664(self: Relocation, source_addr: u64, target_addr: i64, code: []u8) void {
|
||||||
self: Relocation,
|
|
||||||
source_addr: u64,
|
|
||||||
target_addr: i64,
|
|
||||||
code: []u8,
|
|
||||||
) !void {
|
|
||||||
const rel_type = @intToEnum(macho.reloc_type_x86_64, self.type);
|
const rel_type = @intToEnum(macho.reloc_type_x86_64, self.type);
|
||||||
switch (rel_type) {
|
switch (rel_type) {
|
||||||
.X86_64_RELOC_BRANCH,
|
.X86_64_RELOC_BRANCH,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue