# line that serves as the base (first) line in the FDE's table.
cie = self.cie
cie_decoded_table = cie.get_decoded()
- last_line_in_CIE = copy.copy(cie_decoded_table.table[-1])
- cur_line = copy.copy(last_line_in_CIE)
+ if len(cie_decoded_table.table) > 0:
+ last_line_in_CIE = copy.copy(cie_decoded_table.table[-1])
+ cur_line = copy.copy(last_line_in_CIE)
+ else:
+ cur_line = dict(cfa=None)
cur_line['pc'] = self['initial_location']
reg_order = copy.copy(cie_decoded_table.reg_order)
cur_line = line_stack.pop()
# The current line is appended to the table after all instructions
- # have ended, in any case (even if there were no instructions).
- table.append(cur_line)
+ # have ended, if there were instructions.
+ if cur_line['cfa'] is not None or len(cur_line) > 2:
+ table.append(cur_line)
+
return DecodedCallFrameTable(table=table, reg_order=reg_order)
for name in list(iterkeys(globals())):
if name.startswith('DW_CFA'):
_OPCODE_NAME_MAP[globals()[name]] = name
-
-
-
-
self._emitline('\n%08x ZERO terminator' % entry.offset)
continue
+ # Decode the table.
+ decoded_table = entry.get_decoded()
+ if len(decoded_table.table) == 0:
+ continue
# Print the heading row for the decoded table
self._emit(' LOC')
self._emit(' ' if entry.structs.address_size == 4 else ' ')
self._emit(' CFA ')
- # Decode the table and look at the registers it describes.
+ # Look at the registers the decoded table describes.
# We build reg_order here to match readelf's order. In particular,
# registers are sorted by their number, and the register matching
# ra_regnum is always listed last with a special heading.
for line in decoded_table.table:
self._emit(self._format_hex(
line['pc'], fullhex=True, lead0x=False))
- self._emit(' %-9s' % describe_CFI_CFA_rule(line['cfa']))
+
+ if line['cfa'] is not None:
+ s = describe_CFI_CFA_rule(line['cfa'])
+ else:
+ s = 'u'
+ self._emit(' %-9s' % s)
for regnum in reg_order:
if regnum in line: