| ... | ... | @@ -568,7 +568,8 @@ pub fn write(info: *UnwindInfo, zld: *Zld) !void { |
| 568 | 568 | // Finalize missing address values |
| 569 | 569 | rec.rangeStart += text_sect.addr - seg.vmaddr; |
| 570 | 570 | if (rec.personalityFunction > 0) { |
| 571 | | rec.personalityFunction = personalities[rec.personalityFunction - 1]; |
| 571 | const index = math.cast(usize, rec.personalityFunction - 1) orelse return error.Overflow; |
| 572 | rec.personalityFunction = personalities[index]; |
| 572 | 573 | } |
| 573 | 574 | |
| 574 | 575 | if (rec.compactUnwindEncoding > 0 and !UnwindEncoding.isDwarf(rec.compactUnwindEncoding, cpu_arch)) { |
| ... | ... | @@ -653,13 +654,15 @@ pub fn write(info: *UnwindInfo, zld: *Zld) !void { |
| 653 | 654 | try page.write(info, writer); |
| 654 | 655 | const nwritten = cwriter.bytes_written - start; |
| 655 | 656 | if (nwritten < second_level_page_bytes) { |
| 656 | | try writer.writeByteNTimes(0, second_level_page_bytes - nwritten); |
| 657 | const offset = math.cast(usize, second_level_page_bytes - nwritten) orelse return error.Overflow; |
| 658 | try writer.writeByteNTimes(0, offset); |
| 657 | 659 | } |
| 658 | 660 | } |
| 659 | 661 | |
| 660 | 662 | const padding = buffer.items.len - cwriter.bytes_written; |
| 661 | 663 | if (padding > 0) { |
| 662 | | mem.set(u8, buffer.items[cwriter.bytes_written..], 0); |
| 664 | const offset = math.cast(usize, cwriter.bytes_written) orelse return error.Overflow; |
| 665 | mem.set(u8, buffer.items[offset..], 0); |
| 663 | 666 | } |
| 664 | 667 | |
| 665 | 668 | try zld.file.pwriteAll(buffer.items, sect.offset); |