| ... | ... | @@ -4108,27 +4108,31 @@ fn targetEndian(elf: *const Elf) std.lang.Endian { |
| 4108 | 4108 | }; |
| 4109 | 4109 | } |
| 4110 | 4110 | fn targetLoad(elf: *const Elf, ptr: anytype) @typeInfo(@TypeOf(ptr)).pointer.child { |
| 4111 | | const Child = @typeInfo(@TypeOf(ptr)).pointer.child; |
| 4111 | const pointer_ty = @typeInfo(@TypeOf(ptr)).pointer; |
| 4112 | const Child = pointer_ty.child; |
| 4113 | const alignment = pointer_ty.attrs.@"align" orelse @alignOf(Child); |
| 4112 | 4114 | return switch (@typeInfo(Child)) { |
| 4113 | 4115 | else => @compileError(@typeName(Child)), |
| 4114 | 4116 | .int => std.mem.toNative(Child, ptr.*, elf.targetEndian()), |
| 4115 | | .@"enum" => |@"enum"| @enumFromInt(elf.targetLoad(@as(*@"enum".tag_type, @ptrCast(ptr)))), |
| 4117 | .@"enum" => |@"enum"| @enumFromInt(elf.targetLoad(@as(*align(alignment) @"enum".tag_type, @ptrCast(ptr)))), |
| 4116 | 4118 | .@"struct" => |@"struct"| @bitCast( |
| 4117 | | elf.targetLoad(@as(*@"struct".backing_integer.?, @ptrCast(ptr))), |
| 4119 | elf.targetLoad(@as(*align(alignment) @"struct".backing_integer.?, @ptrCast(ptr))), |
| 4118 | 4120 | ), |
| 4119 | 4121 | }; |
| 4120 | 4122 | } |
| 4121 | 4123 | fn targetStore(elf: *const Elf, ptr: anytype, val: @typeInfo(@TypeOf(ptr)).pointer.child) void { |
| 4122 | | const Child = @typeInfo(@TypeOf(ptr)).pointer.child; |
| 4124 | const pointer_ty = @typeInfo(@TypeOf(ptr)).pointer; |
| 4125 | const Child = pointer_ty.child; |
| 4126 | const alignment = pointer_ty.attrs.@"align" orelse @alignOf(Child); |
| 4123 | 4127 | return switch (@typeInfo(Child)) { |
| 4124 | 4128 | else => @compileError(@typeName(Child)), |
| 4125 | 4129 | .int => ptr.* = std.mem.nativeTo(Child, val, elf.targetEndian()), |
| 4126 | 4130 | .@"enum" => |@"enum"| elf.targetStore( |
| 4127 | | @as(*@"enum".tag_type, @ptrCast(ptr)), |
| 4131 | @as(*align(alignment) @"enum".tag_type, @ptrCast(ptr)), |
| 4128 | 4132 | @intFromEnum(val), |
| 4129 | 4133 | ), |
| 4130 | 4134 | .@"struct" => |@"struct"| elf.targetStore( |
| 4131 | | @as(*@"struct".backing_integer.?, @ptrCast(ptr)), |
| 4135 | @as(*align(alignment) @"struct".backing_integer.?, @ptrCast(ptr)), |
| 4132 | 4136 | @bitCast(val), |
| 4133 | 4137 | ), |
| 4134 | 4138 | }; |