authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-02 03:05:33+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-02 15:27:35+02:00
loga4f95b1e619656b0306744177dc4f8662ae4879b
tree36e29ba95c8ff1f92442f2f2b2a30d882233b467
parent97de46dc16b584f5bd7aa2ae9afb2bb77970cd22
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.debug.Dwarf.Unwind: deal with invalid def_cfa_reg by GNU toolchains


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

lib/std/debug/Dwarf/Unwind/VirtualMachine.zig+12-1
...@@ -256,7 +256,18 @@ fn evalInstructions(...@@ -256,7 +256,18 @@ fn evalInstructions(
256 .offset = cfa.offset_sf * cie.data_alignment_factor,256 .offset = cfa.offset_sf * cie.data_alignment_factor,
257 } },257 } },
258 .def_cfa_reg => |register| switch (vm.current_row.cfa) {258 .def_cfa_reg => |register| switch (vm.current_row.cfa) {
259 .none, .expression => return error.InvalidOperation,259 .none => {
260 // According to the DWARF specification, this is not valid, because this
261 // instruction can only be used to replace the register if the rule is already a
262 // `.reg_off`. However, this is emitted in practice by GNU toolchains for some
263 // targets, and so by convention is interpreted as equivalent to `.def_cfa` with
264 // an offset of 0.
265 vm.current_row.cfa = .{ .reg_off = .{
266 .register = register,
267 .offset = 0,
268 } };
269 },
270 .expression => return error.InvalidOperation,
260 .reg_off => |*ro| ro.register = register,271 .reg_off => |*ro| ro.register = register,
261 },272 },
262 .def_cfa_offset => |offset| switch (vm.current_row.cfa) {273 .def_cfa_offset => |offset| switch (vm.current_row.cfa) {