aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO/thunks.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-06-22 18:46:56 +0100
committerAndrew Kelley <andrew@ziglang.org>2023-06-24 16:56:39 -0700
commitf26dda21171e26f44aeec8c59a75bbb3331eeb2e (patch)
treec935248861ae2693b314f2c8bc78fe38d9961b6d /src/link/MachO/thunks.zig
parent447ca4e3fff021f471b748187b53f0a4744ad0bc (diff)
downloadzig-f26dda21171e26f44aeec8c59a75bbb3331eeb2e.tar.gz
zig-f26dda21171e26f44aeec8c59a75bbb3331eeb2e.zip
all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
Diffstat (limited to 'src/link/MachO/thunks.zig')
-rw-r--r--src/link/MachO/thunks.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/link/MachO/thunks.zig b/src/link/MachO/thunks.zig
index f3289e544b..82d0451225 100644
--- a/src/link/MachO/thunks.zig
+++ b/src/link/MachO/thunks.zig
@@ -131,7 +131,7 @@ pub fn createThunks(zld: *Zld, sect_id: u8) !void {
log.debug("GROUP END at {d}", .{group_end});
// Insert thunk at group_end
- const thunk_index = @intCast(u32, zld.thunks.items.len);
+ const thunk_index = @as(u32, @intCast(zld.thunks.items.len));
try zld.thunks.append(gpa, .{ .start_index = undefined, .len = 0 });
// Scan relocs in the group and create trampolines for any unreachable callsite.
@@ -174,7 +174,7 @@ pub fn createThunks(zld: *Zld, sect_id: u8) !void {
}
}
- header.size = @intCast(u32, offset);
+ header.size = @as(u32, @intCast(offset));
}
fn allocateThunk(
@@ -223,7 +223,7 @@ fn scanRelocs(
const base_offset = if (object.getSourceSymbol(atom.sym_index)) |source_sym| blk: {
const source_sect = object.getSourceSection(source_sym.n_sect - 1);
- break :blk @intCast(i32, source_sym.n_value - source_sect.addr);
+ break :blk @as(i32, @intCast(source_sym.n_value - source_sect.addr));
} else 0;
const code = Atom.getAtomCode(zld, atom_index);
@@ -289,7 +289,7 @@ fn scanRelocs(
}
inline fn relocNeedsThunk(rel: macho.relocation_info) bool {
- const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
+ const rel_type = @as(macho.reloc_type_arm64, @enumFromInt(rel.r_type));
return rel_type == .ARM64_RELOC_BRANCH26;
}
@@ -315,7 +315,7 @@ fn isReachable(
if (!allocated.contains(target_atom_index)) return false;
- const source_addr = source_sym.n_value + @intCast(u32, rel.r_address - base_offset);
+ const source_addr = source_sym.n_value + @as(u32, @intCast(rel.r_address - base_offset));
const is_via_got = Atom.relocRequiresGot(zld, rel);
const target_addr = Atom.getRelocTargetAddress(zld, target, is_via_got, false) catch unreachable;
_ = Relocation.calcPcRelativeDisplacementArm64(source_addr, target_addr) catch
@@ -349,7 +349,7 @@ fn getThunkIndex(zld: *Zld, atom_index: AtomIndex) ?ThunkIndex {
const end_addr = start_addr + thunk.getSize();
if (start_addr <= sym.n_value and sym.n_value < end_addr) {
- return @intCast(u32, i);
+ return @as(u32, @intCast(i));
}
}
return null;