1
Fork 0

fix shell index offsets

main
Motiejus Jakštys 2022-02-19 15:48:51 +02:00 committed by Motiejus Jakštys
parent 13b75e8046
commit fd1cab251d
1 changed files with 3 additions and 3 deletions

View File

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