Skip to content

Commit a4d0877

Browse files
aykevldeadprogram
authored andcommitted
stacksize: add support for DW_CFA_offset_extended
It should be possible to ignore this directive, but we still have to consume the two operands.
1 parent 6ec8687 commit a4d0877

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

stacksize/dwarf.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ func (fi *frameInfo) exec(bytecode []byte) ([]frameInfoLine, error) {
190190
}
191191
return nil, err
192192
}
193+
// For details on the various opcodes, see:
194+
// http://dwarfstd.org/doc/DWARF5.pdf (page 239)
193195
highBits := op >> 6 // high order 2 bits
194196
lowBits := op & 0x1f
195197
switch highBits {
@@ -217,6 +219,17 @@ func (fi *frameInfo) exec(bytecode []byte) ([]frameInfoLine, error) {
217219
fi.loc += uint64(offset) * fi.cie.codeAlignmentFactor
218220
entries = append(entries, fi.newLine())
219221
// TODO: DW_CFA_advance_loc2 etc
222+
case 0x05: // DW_CFA_offset_extended
223+
// Semantics are the same as DW_CFA_offset, but the encoding is
224+
// different. Ignore it just like DW_CFA_offset.
225+
_, err := readULEB128(r) // ULEB128 register
226+
if err != nil {
227+
return nil, err
228+
}
229+
_, err = readULEB128(r) // ULEB128 offset
230+
if err != nil {
231+
return nil, err
232+
}
220233
case 0x07: // DW_CFA_undefined
221234
// Marks a single register as undefined. This is used to stop
222235
// unwinding in tinygo_startTask using:

0 commit comments

Comments
 (0)