authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-02-07 19:27:11+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-02-08 05:03:14+01:00
log94c68c1f9ed74cd5e2b4ab4329166ba5e5d7abc3
treecc12e73c93487f40db91f1f2ecfdb2d303460bd7
parent9ccd8ed0ad4cc9e68c2a2e0c9b1e32d50259357e

macho: fix incorrect representation of encodings count per page

There can be a maximum of 256 compact encodings per page in compact unwind info, and we were using `u8` to represent the count which is insufficient. This commit bumps it to `u9`.

1 files changed, 3 insertions(+), 3 deletions(-)

src/link/MachO/UnwindInfo.zig+3-3
......@@ -68,7 +68,7 @@ const Page = struct {
6868 start: RecordIndex,
6969 count: u16,
7070 page_encodings: [max_compact_encodings]RecordIndex = undefined,
71 page_encodings_count: u8 = 0,
71 page_encodings_count: u9 = 0,
7272
7373 fn appendPageEncoding(page: *Page, record_id: RecordIndex) void {
7474 assert(page.page_encodings_count <= max_compact_encodings);
......@@ -81,13 +81,13 @@ const Page = struct {
8181 info: *const UnwindInfo,
8282 enc: macho.compact_unwind_encoding_t,
8383 ) ?u8 {
84 comptime var index: u8 = 0;
84 comptime var index: u9 = 0;
8585 inline while (index < max_compact_encodings) : (index += 1) {
8686 if (index >= page.page_encodings_count) return null;
8787 const record_id = page.page_encodings[index];
8888 const record = info.records.items[record_id];
8989 if (record.compactUnwindEncoding == enc) {
90 return index;
90 return @intCast(u8, index);
9191 }
9292 }
9393 return null;