From 5e780e260a744250b2787f97bb2516a8121f3951 Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Mon, 1 Apr 2024 09:39:00 -0700 Subject: [PATCH] Object: use alignCast with fieldParentPtr when necessary --- src/backend/Object.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/Object.zig b/src/backend/Object.zig index b42ad4bd..98355e88 100644 --- a/src/backend/Object.zig +++ b/src/backend/Object.zig @@ -16,7 +16,7 @@ pub fn create(gpa: Allocator, target: std.Target) !*Object { pub fn deinit(obj: *Object) void { switch (obj.format) { - .elf => @as(*Elf, @fieldParentPtr("obj", obj)).deinit(), + .elf => @as(*Elf, @alignCast(@fieldParentPtr("obj", obj))).deinit(), else => unreachable, } } @@ -32,7 +32,7 @@ pub const Section = union(enum) { pub fn getSection(obj: *Object, section: Section) !*std.ArrayList(u8) { switch (obj.format) { - .elf => return @as(*Elf, @fieldParentPtr("obj", obj)).getSection(section), + .elf => return @as(*Elf, @alignCast(@fieldParentPtr("obj", obj))).getSection(section), else => unreachable, } } @@ -53,21 +53,21 @@ pub fn declareSymbol( size: u64, ) ![]const u8 { switch (obj.format) { - .elf => return @as(*Elf, @fieldParentPtr("obj", obj)).declareSymbol(section, name, linkage, @"type", offset, size), + .elf => return @as(*Elf, @alignCast(@fieldParentPtr("obj", obj))).declareSymbol(section, name, linkage, @"type", offset, size), else => unreachable, } } pub fn addRelocation(obj: *Object, name: []const u8, section: Section, address: u64, addend: i64) !void { switch (obj.format) { - .elf => return @as(*Elf, @fieldParentPtr("obj", obj)).addRelocation(name, section, address, addend), + .elf => return @as(*Elf, @alignCast(@fieldParentPtr("obj", obj))).addRelocation(name, section, address, addend), else => unreachable, } } pub fn finish(obj: *Object, file: std.fs.File) !void { switch (obj.format) { - .elf => return @as(*Elf, @fieldParentPtr("obj", obj)).finish(file), + .elf => return @as(*Elf, @alignCast(@fieldParentPtr("obj", obj))).finish(file), else => unreachable, } }