fix shell index offsets

This commit is contained in:
Motiejus Jakštys 2022-02-19 15:48:51 +02:00 committed by Motiejus Jakštys
parent 13b75e8046
commit fd1cab251d

View File

@ -17,7 +17,7 @@ pub const ShellReader = struct {
pub fn init(index: []const u8, blob: []const u8) ShellReader {
return ShellReader{
.sectionIndex = @bitCast([]const ShellIndex, index),
.sectionIndex = std.mem.bytesAsSlice(ShellIndex, index),
.sectionBlob = blob,
};
}
@ -78,7 +78,7 @@ pub const ShellWriter = struct {
}
pub fn sectionIndex(self: *const ShellSections) []const u8 {
return @bitCast([]const u8, self.index.constSlice());
return std.mem.sliceAsBytes(self.index.constSlice());
}
pub fn sectionBlob(self: *const ShellSections) []const u8 {
@ -176,7 +176,7 @@ inline fn roundUp4Padding(n: u12) u12 {
// to 4 bytes.
// The actual shell length is len+1: we don't allow empty shells, and the real
// length of the shell is 1-64 bytes.
const ShellIndex = struct {
const ShellIndex = packed struct {
offset: u10,
len: u6,
};