aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO
diff options
context:
space:
mode:
authorEric Joldasov <bratishkaerik@getgoogleoff.me>2023-06-15 13:14:16 +0600
committerAndrew Kelley <andrew@ziglang.org>2023-06-19 12:34:42 -0700
commit50339f595aa6ec96760b1cd9f8d0e0bfc3f167fc (patch)
tree9e2b95d8e111e905e00511962dfd32c8e5bb3245 /src/link/MachO
parenta6c8ee5231230947c928bbe1c6a39eb6e1bb9c5b (diff)
downloadzig-50339f595aa6ec96760b1cd9f8d0e0bfc3f167fc.tar.gz
zig-50339f595aa6ec96760b1cd9f8d0e0bfc3f167fc.zip
all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
Diffstat (limited to 'src/link/MachO')
-rw-r--r--src/link/MachO/UnwindInfo.zig8
-rw-r--r--src/link/MachO/ZldAtom.zig14
-rw-r--r--src/link/MachO/dead_strip.zig4
-rw-r--r--src/link/MachO/eh_frame.zig8
-rw-r--r--src/link/MachO/thunks.zig2
-rw-r--r--src/link/MachO/zld.zig8
6 files changed, 22 insertions, 22 deletions
diff --git a/src/link/MachO/UnwindInfo.zig b/src/link/MachO/UnwindInfo.zig
index 8d2a36be9d..3c9a438f92 100644
--- a/src/link/MachO/UnwindInfo.zig
+++ b/src/link/MachO/UnwindInfo.zig
@@ -760,14 +760,14 @@ pub const UnwindEncoding = struct {
pub fn isDwarf(enc: macho.compact_unwind_encoding_t, cpu_arch: std.Target.Cpu.Arch) bool {
const mode = getMode(enc);
return switch (cpu_arch) {
- .aarch64 => @intToEnum(macho.UNWIND_ARM64_MODE, mode) == .DWARF,
- .x86_64 => @intToEnum(macho.UNWIND_X86_64_MODE, mode) == .DWARF,
+ .aarch64 => @enumFromInt(macho.UNWIND_ARM64_MODE, mode) == .DWARF,
+ .x86_64 => @enumFromInt(macho.UNWIND_X86_64_MODE, mode) == .DWARF,
else => unreachable,
};
}
pub fn setMode(enc: *macho.compact_unwind_encoding_t, mode: anytype) void {
- enc.* |= @intCast(u32, @enumToInt(mode)) << 24;
+ enc.* |= @intCast(u32, @intFromEnum(mode)) << 24;
}
pub fn hasLsda(enc: macho.compact_unwind_encoding_t) bool {
@@ -776,7 +776,7 @@ pub const UnwindEncoding = struct {
}
pub fn setHasLsda(enc: *macho.compact_unwind_encoding_t, has_lsda: bool) void {
- const mask = @intCast(u32, @boolToInt(has_lsda)) << 31;
+ const mask = @intCast(u32, @intFromBool(has_lsda)) << 31;
enc.* |= mask;
}
diff --git a/src/link/MachO/ZldAtom.zig b/src/link/MachO/ZldAtom.zig
index baa6340a13..1252379aa7 100644
--- a/src/link/MachO/ZldAtom.zig
+++ b/src/link/MachO/ZldAtom.zig
@@ -214,7 +214,7 @@ pub fn parseRelocTarget(zld: *Zld, ctx: struct {
mem.readIntLittle(u32, ctx.code[rel_offset..][0..4]);
} else blk: {
assert(zld.options.target.cpu.arch == .x86_64);
- const correction: u3 = switch (@intToEnum(macho.reloc_type_x86_64, ctx.rel.r_type)) {
+ const correction: u3 = switch (@enumFromInt(macho.reloc_type_x86_64, ctx.rel.r_type)) {
.X86_64_RELOC_SIGNED => 0,
.X86_64_RELOC_SIGNED_1 => 1,
.X86_64_RELOC_SIGNED_2 => 2,
@@ -272,7 +272,7 @@ pub fn getRelocTargetAtomIndex(zld: *Zld, target: SymbolWithLoc, is_via_got: boo
fn scanAtomRelocsArm64(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) const macho.relocation_info) !void {
for (relocs) |rel| {
- const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
switch (rel_type) {
.ARM64_RELOC_ADDEND, .ARM64_RELOC_SUBTRACTOR => continue,
@@ -321,7 +321,7 @@ fn scanAtomRelocsArm64(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) cons
fn scanAtomRelocsX86(zld: *Zld, atom_index: AtomIndex, relocs: []align(1) const macho.relocation_info) !void {
for (relocs) |rel| {
- const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
switch (rel_type) {
.X86_64_RELOC_SUBTRACTOR => continue,
@@ -495,7 +495,7 @@ fn resolveRelocsArm64(
var subtractor: ?SymbolWithLoc = null;
for (atom_relocs) |rel| {
- const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
switch (rel_type) {
.ARM64_RELOC_ADDEND => {
@@ -797,7 +797,7 @@ fn resolveRelocsX86(
var subtractor: ?SymbolWithLoc = null;
for (atom_relocs) |rel| {
- const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
switch (rel_type) {
.X86_64_RELOC_SUBTRACTOR => {
@@ -1004,14 +1004,14 @@ pub fn getAtomRelocs(zld: *Zld, atom_index: AtomIndex) []const macho.relocation_
pub fn relocRequiresGot(zld: *Zld, rel: macho.relocation_info) bool {
switch (zld.options.target.cpu.arch) {
- .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) {
+ .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) {
.ARM64_RELOC_GOT_LOAD_PAGE21,
.ARM64_RELOC_GOT_LOAD_PAGEOFF12,
.ARM64_RELOC_POINTER_TO_GOT,
=> return true,
else => return false,
},
- .x86_64 => switch (@intToEnum(macho.reloc_type_x86_64, rel.r_type)) {
+ .x86_64 => switch (@enumFromInt(macho.reloc_type_x86_64, rel.r_type)) {
.X86_64_RELOC_GOT,
.X86_64_RELOC_GOT_LOAD,
=> return true,
diff --git a/src/link/MachO/dead_strip.zig b/src/link/MachO/dead_strip.zig
index ca0d961e2d..b2c569447d 100644
--- a/src/link/MachO/dead_strip.zig
+++ b/src/link/MachO/dead_strip.zig
@@ -148,7 +148,7 @@ fn markLive(zld: *Zld, atom_index: AtomIndex, alive: *AtomTable) void {
for (relocs) |rel| {
const target = switch (cpu_arch) {
- .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) {
+ .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) {
.ARM64_RELOC_ADDEND => continue,
else => Atom.parseRelocTarget(zld, .{
.object_id = atom.getFile().?,
@@ -208,7 +208,7 @@ fn refersLive(zld: *Zld, atom_index: AtomIndex, alive: AtomTable) bool {
for (relocs) |rel| {
const target = switch (cpu_arch) {
- .aarch64 => switch (@intToEnum(macho.reloc_type_arm64, rel.r_type)) {
+ .aarch64 => switch (@enumFromInt(macho.reloc_type_arm64, rel.r_type)) {
.ARM64_RELOC_ADDEND => continue,
else => Atom.parseRelocTarget(zld, .{
.object_id = atom.getFile().?,
diff --git a/src/link/MachO/eh_frame.zig b/src/link/MachO/eh_frame.zig
index ea8d4128c2..1672e37229 100644
--- a/src/link/MachO/eh_frame.zig
+++ b/src/link/MachO/eh_frame.zig
@@ -291,7 +291,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type {
for (relocs) |rel| {
switch (cpu_arch) {
.aarch64 => {
- const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
switch (rel_type) {
.ARM64_RELOC_SUBTRACTOR,
.ARM64_RELOC_UNSIGNED,
@@ -301,7 +301,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type {
}
},
.x86_64 => {
- const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
switch (rel_type) {
.X86_64_RELOC_GOT => {},
else => unreachable,
@@ -342,7 +342,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type {
switch (cpu_arch) {
.aarch64 => {
- const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
switch (rel_type) {
.ARM64_RELOC_SUBTRACTOR => {
// Address of the __eh_frame in the source object file
@@ -363,7 +363,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type {
}
},
.x86_64 => {
- const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
switch (rel_type) {
.X86_64_RELOC_GOT => {
const target_addr = try Atom.getRelocTargetAddress(zld, target, true, false);
diff --git a/src/link/MachO/thunks.zig b/src/link/MachO/thunks.zig
index 7895190005..f3289e544b 100644
--- a/src/link/MachO/thunks.zig
+++ b/src/link/MachO/thunks.zig
@@ -289,7 +289,7 @@ fn scanRelocs(
}
inline fn relocNeedsThunk(rel: macho.relocation_info) bool {
- const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
return rel_type == .ARM64_RELOC_BRANCH26;
}
diff --git a/src/link/MachO/zld.zig b/src/link/MachO/zld.zig
index 7902d67d87..be283900f5 100644
--- a/src/link/MachO/zld.zig
+++ b/src/link/MachO/zld.zig
@@ -1819,12 +1819,12 @@ pub const Zld = struct {
for (relocs) |rel| {
switch (cpu_arch) {
.aarch64 => {
- const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
if (rel_type != .ARM64_RELOC_UNSIGNED) continue;
if (rel.r_length != 3) continue;
},
.x86_64 => {
- const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
if (rel_type != .X86_64_RELOC_UNSIGNED) continue;
if (rel.r_length != 3) continue;
},
@@ -1958,12 +1958,12 @@ pub const Zld = struct {
for (relocs) |rel| {
switch (cpu_arch) {
.aarch64 => {
- const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_arm64, rel.r_type);
if (rel_type != .ARM64_RELOC_UNSIGNED) continue;
if (rel.r_length != 3) continue;
},
.x86_64 => {
- const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
+ const rel_type = @enumFromInt(macho.reloc_type_x86_64, rel.r_type);
if (rel_type != .X86_64_RELOC_UNSIGNED) continue;
if (rel.r_length != 3) continue;
},