| ... | ... | @@ -44,6 +44,9 @@ lsdas_lookup: std.AutoHashMapUnmanaged(RecordIndex, u32) = .{}, |
| 44 | 44 | /// List of second level pages. |
| 45 | 45 | pages: std.ArrayListUnmanaged(Page) = .{}, |
| 46 | 46 | |
| 47 | /// Upper bound (exclusive) of all the record ranges |
| 48 | end_boundary: u64 = 0, |
| 49 | |
| 47 | 50 | const RecordIndex = u32; |
| 48 | 51 | |
| 49 | 52 | const max_personalities = 3; |
| ... | ... | @@ -327,6 +330,13 @@ pub fn collect(info: *UnwindInfo, zld: *Zld) !void { |
| 327 | 330 | } |
| 328 | 331 | } |
| 329 | 332 | |
| 333 | // Record the ending boundary before folding. |
| 334 | assert(records.items.len > 0); |
| 335 | info.end_boundary = blk: { |
| 336 | const last_record = records.items[records.items.len - 1]; |
| 337 | break :blk last_record.rangeStart + last_record.rangeLength; |
| 338 | }; |
| 339 | |
| 330 | 340 | // Fold records |
| 331 | 341 | try info.records.ensureTotalCapacity(info.gpa, records.items.len); |
| 332 | 342 | try info.records_lookup.ensureTotalCapacity(info.gpa, @as(u32, @intCast(atom_indexes.items.len))); |
| ... | ... | @@ -629,10 +639,10 @@ pub fn write(info: *UnwindInfo, zld: *Zld) !void { |
| 629 | 639 | }); |
| 630 | 640 | } |
| 631 | 641 | |
| 632 | | const last_entry = info.records.items[info.records.items.len - 1]; |
| 633 | | const sentinel_address = @as(u32, @intCast(last_entry.rangeStart + last_entry.rangeLength)); |
| 642 | // Relocate end boundary address |
| 643 | const end_boundary = @as(u32, @intCast(info.end_boundary + text_sect.addr - seg.vmaddr)); |
| 634 | 644 | try writer.writeStruct(macho.unwind_info_section_header_index_entry{ |
| 635 | | .functionOffset = sentinel_address, |
| 645 | .functionOffset = end_boundary, |
| 636 | 646 | .secondLevelPagesSectionOffset = 0, |
| 637 | 647 | .lsdaIndexArraySectionOffset = lsda_base_offset + |
| 638 | 648 | @as(u32, @intCast(info.lsdas.items.len)) * @sizeOf(macho.unwind_info_section_header_lsda_index_entry), |