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 {...@@ -68,7 +68,7 @@ const Page = struct {
68 start: RecordIndex,68 start: RecordIndex,
69 count: u16,69 count: u16,
70 page_encodings: [max_compact_encodings]RecordIndex = undefined,70 page_encodings: [max_compact_encodings]RecordIndex = undefined,
71 page_encodings_count: u8 = 0,71 page_encodings_count: u9 = 0,
7272
73 fn appendPageEncoding(page: *Page, record_id: RecordIndex) void {73 fn appendPageEncoding(page: *Page, record_id: RecordIndex) void {
74 assert(page.page_encodings_count <= max_compact_encodings);74 assert(page.page_encodings_count <= max_compact_encodings);
...@@ -81,13 +81,13 @@ const Page = struct {...@@ -81,13 +81,13 @@ const Page = struct {
81 info: *const UnwindInfo,81 info: *const UnwindInfo,
82 enc: macho.compact_unwind_encoding_t,82 enc: macho.compact_unwind_encoding_t,
83 ) ?u8 {83 ) ?u8 {
84 comptime var index: u8 = 0;84 comptime var index: u9 = 0;
85 inline while (index < max_compact_encodings) : (index += 1) {85 inline while (index < max_compact_encodings) : (index += 1) {
86 if (index >= page.page_encodings_count) return null;86 if (index >= page.page_encodings_count) return null;
87 const record_id = page.page_encodings[index];87 const record_id = page.page_encodings[index];
88 const record = info.records.items[record_id];88 const record = info.records.items[record_id];
89 if (record.compactUnwindEncoding == enc) {89 if (record.compactUnwindEncoding == enc) {
90 return index;90 return @intCast(u8, index);
91 }91 }
92 }92 }
93 return null;93 return null;