Skip to content

Commit cd7246f

Browse files
committed
sh: Add support for DWARF GNU extensions
Also, remove the "fix" to DW_CFA_def_cfa_register where we reset the frame's cfa_offset to 0. This action is incorrect when handling DW_CFA_def_cfa_register as the DWARF spec specifically states that the previous contents of cfa_offset should be used with the new register. The reason that I thought cfa_offset should be reset to 0 was because it was being assigned a bogus value prior to executing the DW_CFA_def_cfa_register op. It turns out that the bogus cfa_offset value came from interpreting .cfi_escape pseudo-ops (those used by the GNU extensions) as CFA_DW_def_cfa ops. Signed-off-by: Matt Fleming <matt@console-pimps.org>
1 parent b955873 commit cd7246f

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎arch/sh/include/asm/dwarf.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ struct dwarf_stack {
340340
#define DW_CFA_lo_user 0x1c
341341
#define DW_CFA_hi_user 0x3f
342342

343+
/* GNU extension opcodes */
344+
#define DW_CFA_GNU_args_size 0x2e
345+
#define DW_CFA_GNU_negative_offset_extended 0x2f
346+
343347
/*
344348
* Some call frame instructions encode their operands in the opcode. We
345349
* need some helper functions to extract both the opcode and operands

‎arch/sh/kernel/dwarf.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ static int dwarf_cfa_execute_insns(unsigned char *insn_start,
429429
count = dwarf_read_uleb128(current_insn,
430430
&frame->cfa_register);
431431
current_insn += count;
432-
frame->cfa_offset = 0;
433432
frame->flags |= DWARF_FRAME_CFA_REG_OFFSET;
434433
break;
435434
case DW_CFA_def_cfa_offset:
@@ -465,6 +464,19 @@ static int dwarf_cfa_execute_insns(unsigned char *insn_start,
465464
frame->regs[reg].flags |= DWARF_REG_OFFSET;
466465
frame->regs[reg].addr = offset;
467466
break;
467+
case DW_CFA_GNU_args_size:
468+
count = dwarf_read_uleb128(current_insn, &offset);
469+
current_insn += count;
470+
break;
471+
case DW_CFA_GNU_negative_offset_extended:
472+
count = dwarf_read_uleb128(current_insn, &reg);
473+
current_insn += count;
474+
count = dwarf_read_uleb128(current_insn, &offset);
475+
offset *= cie->data_alignment_factor;
476+
dwarf_frame_alloc_regs(frame, reg);
477+
frame->regs[reg].flags |= DWARF_REG_OFFSET;
478+
frame->regs[reg].addr = -offset;
479+
break;
468480
default:
469481
pr_debug("unhandled DWARF instruction 0x%x\n", insn);
470482
break;

0 commit comments

Comments
 (0)