Skip to content

Commit 61c160d

Browse files
committed
Make some effort to deal with "signed" PC register for ARM
Just mask off the top 16 bits of the instruction pointer, and add definitions for the RA signed state.
1 parent 1e72e48 commit 61c160d

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

dump.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@ dumpCFAInsn(std::ostream &os, Dwarf::DWARFReader *r)
191191
jo.field("size", r->getuleb128());
192192
break;
193193

194-
case DW_CFA_GNU_window_save:
195-
break;
196-
197194
case DW_CFA_GNU_negative_offset_extended:
198195
case DW_CFA_offset_extended_sf: {
199196
auto reg = r->getuleb128();
@@ -209,6 +206,14 @@ dumpCFAInsn(std::ostream &os, Dwarf::DWARFReader *r)
209206
case DW_CFA_restore_state:
210207
break;
211208

209+
#ifndef __aarch64__
210+
case DW_CFA_GNU_window_save:
211+
break;
212+
#else
213+
case DW_CFA_AARCH64_negate_ra_state:
214+
break;
215+
#endif
216+
212217
default:
213218
throw (Exception() << "unknown CFA op " << std::hex << int(op)) << std::dec;
214219
}

dwarfproc.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ StackFrame::getCoreRegs(Elf::CoreRegisters &core) const
2626
Elf::Addr
2727
StackFrame::rawIP() const
2828
{
29+
#ifdef __aarch64__
30+
// remove RA signing artefacts.
31+
return 0xffffffffffff & Elf::getReg(regs, IPREG);
32+
#else
2933
return Elf::getReg(regs, IPREG);
34+
#endif
3035
}
3136

3237
ProcessLocation

libpstack/dwarf.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,14 @@ CIE::execInsns(const CallFrame &dframe, uintptr_t start, uintptr_t end, uintmax_
11681168
}
11691169

11701170
// Can't deal with anything else yet.
1171+
#ifdef __aarch64__
1172+
case DW_CFA_AARCH64_negate_ra_state:
1173+
break;
1174+
1175+
#else
1176+
// systems with register windows, i.e., sparc
11711177
case DW_CFA_GNU_window_save:
1178+
#endif
11721179
case DW_CFA_GNU_negative_offset_extended:
11731180
default:
11741181
throw (Exception() << "unhandled secondary CFA instruction " << op);

libpstack/dwarf/cfainsns.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ DWARF_CFA_INSN(DW_CFA_val_expression, 0x16)
2929
// }
3030

3131
DWARF_CFA_INSN(DW_CFA_lo_user, 0x1c)
32+
#ifdef __aarch64__
33+
DWARF_CFA_INSN(DW_CFA_AARCH64_negate_ra_state, 0x2d)
34+
#else
3235
DWARF_CFA_INSN(DW_CFA_GNU_window_save, 0x2d)
36+
#endif
37+
3338
DWARF_CFA_INSN(DW_CFA_GNU_args_size, 0x2e)
3439
DWARF_CFA_INSN(DW_CFA_GNU_negative_offset_extended, 0x2f)
3540
DWARF_CFA_INSN(DW_CFA_hi_user, 0x3f)

0 commit comments

Comments
 (0)