authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-02-25 08:10:12+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-25 11:13:00-08:00
log743623bc5464b3d1008a97531affd4da029ca9cb
tree460c44bb40fd4dc82de0864aff32d9fdb5ea16ae
parentad5515bed8789cb7688b3bd6c098be3a16b16d47

link.MachO.UnwindInfo: Handle u24 overflow for CU records pointing to DWARF.

Closes #23010.

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

src/link/MachO/UnwindInfo.zig+7-1
...@@ -68,7 +68,13 @@ pub fn generate(info: *UnwindInfo, macho_file: *MachO) !void {...@@ -68,7 +68,13 @@ pub fn generate(info: *UnwindInfo, macho_file: *MachO) !void {
68 for (info.records.items) |ref| {68 for (info.records.items) |ref| {
69 const rec = ref.getUnwindRecord(macho_file);69 const rec = ref.getUnwindRecord(macho_file);
70 if (rec.getFde(macho_file)) |fde| {70 if (rec.getFde(macho_file)) |fde| {
71 rec.enc.setDwarfSectionOffset(@intCast(fde.out_offset));71 // The unwinder will start looking for a matching CFI at the offset we specify here; it
72 // isn't actually an offset to the exact CFI for this record. A consequence of this is
73 // that if the offset doesn't fit in 24 bits, we can just leave it as zero so the
74 // unwinder starts searching at the beginning of the section.
75 if (std.math.cast(u24, fde.out_offset)) |off| {
76 rec.enc.setDwarfSectionOffset(off);
77 }
72 if (fde.getLsdaAtom(macho_file)) |lsda| {78 if (fde.getLsdaAtom(macho_file)) |lsda| {
73 rec.lsda = lsda.atom_index;79 rec.lsda = lsda.atom_index;
74 rec.lsda_offset = fde.lsda_offset;80 rec.lsda_offset = fde.lsda_offset;