summaryrefslogtreecommitdiff
path: root/chromium/third_party/pyelftools/scripts/readelf.py
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/pyelftools/scripts/readelf.py')
-rwxr-xr-xchromium/third_party/pyelftools/scripts/readelf.py463
1 files changed, 73 insertions, 390 deletions
diff --git a/chromium/third_party/pyelftools/scripts/readelf.py b/chromium/third_party/pyelftools/scripts/readelf.py
index 8179c013a54..04c75bafca3 100755
--- a/chromium/third_party/pyelftools/scripts/readelf.py
+++ b/chromium/third_party/pyelftools/scripts/readelf.py
@@ -11,24 +11,20 @@ import os, sys
from optparse import OptionParser
import string
-# For running from development directory. It should take precedence over the
-# installed pyelftools.
-sys.path.insert(0, '.')
-
+# If elftools is not installed, maybe we're running from the root or scripts
+# dir of the source distribution
+try:
+ import elftools
+except ImportError:
+ sys.path.extend(['.', '..'])
from elftools import __version__
from elftools.common.exceptions import ELFError
from elftools.common.py3compat import (
ifilter, byte2int, bytes2str, itervalues, str2bytes)
from elftools.elf.elffile import ELFFile
-from elftools.elf.dynamic import DynamicSection, DynamicSegment
-from elftools.elf.enums import ENUM_D_TAG
from elftools.elf.segments import InterpSegment
from elftools.elf.sections import SymbolTableSection
-from elftools.elf.gnuversions import (
- GNUVerSymSection, GNUVerDefSection,
- GNUVerNeedSection,
- )
from elftools.elf.relocation import RelocationSection
from elftools.elf.descriptions import (
describe_ei_class, describe_ei_data, describe_ei_version,
@@ -36,10 +32,8 @@ from elftools.elf.descriptions import (
describe_e_version_numeric, describe_p_type, describe_p_flags,
describe_sh_type, describe_sh_flags,
describe_symbol_type, describe_symbol_bind, describe_symbol_visibility,
- describe_symbol_shndx, describe_reloc_type, describe_dyn_tag,
- describe_ver_flags,
+ describe_symbol_shndx, describe_reloc_type,
)
-from elftools.elf.constants import E_FLAGS
from elftools.dwarf.dwarfinfo import DWARFInfo
from elftools.dwarf.descriptions import (
describe_reg_name, describe_attr_value, set_global_machine_arch,
@@ -55,20 +49,18 @@ class ReadElf(object):
""" display_* methods are used to emit output into the output stream
"""
def __init__(self, file, output):
- """ file:
+ """ file:
stream object with the ELF file to read
-
+
output:
output stream to write to
"""
self.elffile = ELFFile(file)
self.output = output
-
+
# Lazily initialized if a debug dump is requested
self._dwarfinfo = None
- self._versioninfo = None
-
def display_file_header(self):
""" Display the ELF file header
"""
@@ -78,33 +70,32 @@ class ReadElf(object):
for b in self.elffile.e_ident_raw))
header = self.elffile.header
e_ident = header['e_ident']
- self._emitline(' Class: %s' %
+ self._emitline(' Class: %s' %
describe_ei_class(e_ident['EI_CLASS']))
- self._emitline(' Data: %s' %
+ self._emitline(' Data: %s' %
describe_ei_data(e_ident['EI_DATA']))
- self._emitline(' Version: %s' %
+ self._emitline(' Version: %s' %
describe_ei_version(e_ident['EI_VERSION']))
self._emitline(' OS/ABI: %s' %
describe_ei_osabi(e_ident['EI_OSABI']))
- self._emitline(' ABI Version: %d' %
+ self._emitline(' ABI Version: %d' %
e_ident['EI_ABIVERSION'])
self._emitline(' Type: %s' %
describe_e_type(header['e_type']))
- self._emitline(' Machine: %s' %
+ self._emitline(' Machine: %s' %
describe_e_machine(header['e_machine']))
self._emitline(' Version: %s' %
describe_e_version_numeric(header['e_version']))
- self._emitline(' Entry point address: %s' %
+ self._emitline(' Entry point address: %s' %
self._format_hex(header['e_entry']))
- self._emit(' Start of program headers: %s' %
+ self._emit(' Start of program headers: %s' %
header['e_phoff'])
self._emitline(' (bytes into file)')
- self._emit(' Start of section headers: %s' %
+ self._emit(' Start of section headers: %s' %
header['e_shoff'])
self._emitline(' (bytes into file)')
- self._emitline(' Flags: %s%s' %
- (self._format_hex(header['e_flags']),
- self.decode_flags(header['e_flags'])))
+ self._emitline(' Flags: %s' %
+ self._format_hex(header['e_flags']))
self._emitline(' Size of this header: %s (bytes)' %
header['e_ehsize'])
self._emitline(' Size of program headers: %s (bytes)' %
@@ -118,17 +109,6 @@ class ReadElf(object):
self._emitline(' Section header string table index: %s' %
header['e_shstrndx'])
- def decode_flags(self, flags):
- description = ""
- if self.elffile['e_machine'] == "EM_ARM":
- if flags & E_FLAGS.EF_ARM_HASENTRY:
- description += ", has entry point"
-
- version = flags & E_FLAGS.EF_ARM_EABIMASK
- if version == E_FLAGS.EF_ARM_EABI_VER5:
- description += ", Version5 EABI"
- return description
-
def display_program_headers(self, show_heading=True):
""" Display the ELF program headers.
If show_heading is True, displays the heading for this information
@@ -193,14 +173,14 @@ class ReadElf(object):
self._format_hex(segment['p_align'], lead0x=False)))
if isinstance(segment, InterpSegment):
- self._emitline(' [Requesting program interpreter: %s]' %
+ self._emitline(' [Requesting program interpreter: %s]' %
bytes2str(segment.get_interp_name()))
# Sections to segments mapping
#
if self.elffile.num_sections() == 0:
# No sections? We're done
- return
+ return
self._emitline('\n Section to Segment mapping:')
self._emitline(' Segment Sections...')
@@ -209,7 +189,7 @@ class ReadElf(object):
self._emit(' %2.2d ' % nseg)
for section in self.elffile.iter_sections():
- if ( not section.is_null() and
+ if ( not section.is_null() and
segment.section_in_segment(section)):
self._emit('%s ' % bytes2str(section.name))
@@ -274,8 +254,6 @@ class ReadElf(object):
def display_symbol_tables(self):
""" Display the symbol tables contained in the file
"""
- self._init_versioninfo()
-
for section in self.elffile.iter_sections():
if not isinstance(section, SymbolTableSection):
continue
@@ -294,85 +272,17 @@ class ReadElf(object):
self._emitline(' Num: Value Size Type Bind Vis Ndx Name')
for nsym, symbol in enumerate(section.iter_symbols()):
-
- version_info = ''
- # readelf doesn't display version info for Solaris versioning
- if (section['sh_type'] == 'SHT_DYNSYM' and
- self._versioninfo['type'] == 'GNU'):
- version = self._symbol_version(nsym)
- if (version['name'] != bytes2str(symbol.name) and
- version['index'] not in ('VER_NDX_LOCAL',
- 'VER_NDX_GLOBAL')):
- if version['filename']:
- # external symbol
- version_info = '@%(name)s (%(index)i)' % version
- else:
- # internal symbol
- if version['hidden']:
- version_info = '@%(name)s' % version
- else:
- version_info = '@@%(name)s' % version
-
# symbol names are truncated to 25 chars, similarly to readelf
- self._emitline('%6d: %s %5d %-7s %-6s %-7s %4s %.25s%s' % (
+ self._emitline('%6d: %s %5d %-7s %-6s %-7s %4s %.25s' % (
nsym,
- self._format_hex(
- symbol['st_value'], fullhex=True, lead0x=False),
+ self._format_hex(symbol['st_value'], fullhex=True, lead0x=False),
symbol['st_size'],
describe_symbol_type(symbol['st_info']['type']),
describe_symbol_bind(symbol['st_info']['bind']),
describe_symbol_visibility(symbol['st_other']['visibility']),
describe_symbol_shndx(symbol['st_shndx']),
- bytes2str(symbol.name),
- version_info))
-
- def display_dynamic_tags(self):
- """ Display the dynamic tags contained in the file
- """
- has_dynamic_sections = False
- for section in self.elffile.iter_sections():
- if not isinstance(section, DynamicSection):
- continue
-
- has_dynamic_sections = True
- self._emitline("\nDynamic section at offset %s contains %s entries:" % (
- self._format_hex(section['sh_offset']),
- section.num_tags()))
- self._emitline(" Tag Type Name/Value")
-
- padding = 20 + (8 if self.elffile.elfclass == 32 else 0)
- for tag in section.iter_tags():
- if tag.entry.d_tag == 'DT_NEEDED':
- parsed = 'Shared library: [%s]' % bytes2str(tag.needed)
- elif tag.entry.d_tag == 'DT_RPATH':
- parsed = 'Library rpath: [%s]' % bytes2str(tag.rpath)
- elif tag.entry.d_tag == 'DT_RUNPATH':
- parsed = 'Library runpath: [%s]' % bytes2str(tag.runpath)
- elif tag.entry.d_tag == 'DT_SONAME':
- parsed = 'Library soname: [%s]' % bytes2str(tag.soname)
- elif tag.entry.d_tag.endswith(('SZ', 'ENT')):
- parsed = '%i (bytes)' % tag['d_val']
- elif tag.entry.d_tag.endswith(('NUM', 'COUNT')):
- parsed = '%i' % tag['d_val']
- elif tag.entry.d_tag == 'DT_PLTREL':
- s = describe_dyn_tag(tag.entry.d_val)
- if s.startswith('DT_'):
- s = s[3:]
- parsed = '%s' % s
- else:
- parsed = '%#x' % tag['d_val']
-
- self._emitline(" %s %-*s %s" % (
- self._format_hex(ENUM_D_TAG.get(tag.entry.d_tag, tag.entry.d_tag),
- fullhex=True, lead0x=True),
- padding,
- '(%s)' % (tag.entry.d_tag[3:],),
- parsed))
- if not has_dynamic_sections:
- # readelf only prints this if there is at least one segment
- if self.elffile.num_segments():
- self._emitline("\nThere is no dynamic section in this file.")
-
+ bytes2str(symbol.name)))
+
def display_relocations(self):
""" Display the relocations contained in the file
"""
@@ -397,9 +307,9 @@ class ReadElf(object):
for rel in section.iter_relocations():
hexwidth = 8 if self.elffile.elfclass == 32 else 12
self._emit('%s %s %-17.17s' % (
- self._format_hex(rel['r_offset'],
+ self._format_hex(rel['r_offset'],
fieldsize=hexwidth, lead0x=False),
- self._format_hex(rel['r_info'],
+ self._format_hex(rel['r_info'],
fieldsize=hexwidth, lead0x=False),
describe_reloc_type(
rel['r_info_type'], self.elffile)))
@@ -430,112 +340,7 @@ class ReadElf(object):
if not has_relocation_sections:
self._emitline('\nThere are no relocations in this file.')
-
- def display_version_info(self):
- """ Display the version info contained in the file
- """
- self._init_versioninfo()
-
- if not self._versioninfo['type']:
- self._emitline("\nNo version information found in this file.")
- return
-
- for section in self.elffile.iter_sections():
- if isinstance(section, GNUVerSymSection):
- self._print_version_section_header(
- section, 'Version symbols', lead0x=False)
-
- num_symbols = section.num_symbols()
-
- # Symbol version info are printed four by four entries
- for idx_by_4 in range(0, num_symbols, 4):
-
- self._emit(' %03x:' % idx_by_4)
-
- for idx in range(idx_by_4, min(idx_by_4 + 4, num_symbols)):
-
- symbol_version = self._symbol_version(idx)
- if symbol_version['index'] == 'VER_NDX_LOCAL':
- version_index = 0
- version_name = '(*local*)'
- elif symbol_version['index'] == 'VER_NDX_GLOBAL':
- version_index = 1
- version_name = '(*global*)'
- else:
- version_index = symbol_version['index']
- version_name = '(%(name)s)' % symbol_version
-
- visibility = 'h' if symbol_version['hidden'] else ' '
-
- self._emit('%4x%s%-13s' % (
- version_index, visibility, version_name))
-
- self._emitline()
-
- elif isinstance(section, GNUVerDefSection):
- self._print_version_section_header(
- section, 'Version definition', indent=2)
-
- offset = 0
- for verdef, verdaux_iter in section.iter_versions():
- verdaux = next(verdaux_iter)
-
- name = verdaux.name
- if verdef['vd_flags']:
- flags = describe_ver_flags(verdef['vd_flags'])
- # Mimic exactly the readelf output
- flags += ' '
- else:
- flags = 'none'
-
- self._emitline(' %s: Rev: %i Flags: %s Index: %i'
- ' Cnt: %i Name: %s' % (
- self._format_hex(offset, fieldsize=6,
- alternate=True),
- verdef['vd_version'], flags, verdef['vd_ndx'],
- verdef['vd_cnt'], bytes2str(name)))
-
- verdaux_offset = (
- offset + verdef['vd_aux'] + verdaux['vda_next'])
- for idx, verdaux in enumerate(verdaux_iter, start=1):
- self._emitline(' %s: Parent %i: %s' %
- (self._format_hex(verdaux_offset, fieldsize=4),
- idx, bytes2str(verdaux.name)))
- verdaux_offset += verdaux['vda_next']
-
- offset += verdef['vd_next']
-
- elif isinstance(section, GNUVerNeedSection):
- self._print_version_section_header(section, 'Version needs')
-
- offset = 0
- for verneed, verneed_iter in section.iter_versions():
-
- self._emitline(' %s: Version: %i File: %s Cnt: %i' % (
- self._format_hex(offset, fieldsize=6,
- alternate=True),
- verneed['vn_version'], bytes2str(verneed.name),
- verneed['vn_cnt']))
-
- vernaux_offset = offset + verneed['vn_aux']
- for idx, vernaux in enumerate(verneed_iter, start=1):
- if vernaux['vna_flags']:
- flags = describe_ver_flags(vernaux['vna_flags'])
- # Mimic exactly the readelf output
- flags += ' '
- else:
- flags = 'none'
-
- self._emitline(
- ' %s: Name: %s Flags: %s Version: %i' % (
- self._format_hex(vernaux_offset, fieldsize=4),
- bytes2str(vernaux.name), flags,
- vernaux['vna_other']))
-
- vernaux_offset += vernaux['vna_next']
-
- offset += verneed['vn_next']
-
+
def display_hex_dump(self, section_spec):
""" Display a hex dump of a section. section_spec is either a section
number or a name.
@@ -596,7 +401,7 @@ class ReadElf(object):
dataptr = 0
while dataptr < len(data):
- while ( dataptr < len(data) and
+ while ( dataptr < len(data) and
not (32 <= byte2int(data[dataptr]) <= 127)):
dataptr += 1
@@ -624,7 +429,7 @@ class ReadElf(object):
self._init_dwarfinfo()
if self._dwarfinfo is None:
return
-
+
set_global_machine_arch(self.elffile.get_machine_arch())
if dump_what == 'info':
@@ -638,8 +443,7 @@ class ReadElf(object):
else:
self._emitline('debug dump not yet supported for "%s"' % dump_what)
- def _format_hex(self, addr, fieldsize=None, fullhex=False, lead0x=True,
- alternate=False):
+ def _format_hex(self, addr, fieldsize=None, fullhex=False, lead0x=True):
""" Format an address into a hexadecimal string.
fieldsize:
@@ -649,25 +453,12 @@ class ReadElf(object):
If None, the minimal required field size will be used.
fullhex:
- If True, override fieldsize to set it to the maximal size
+ If True, override fieldsize to set it to the maximal size
needed for the elfclass
lead0x:
If True, leading 0x is added
-
- alternate:
- If True, override lead0x to emulate the alternate
- hexadecimal form specified in format string with the #
- character: only non-zero values are prefixed with 0x.
- This form is used by readelf.
"""
- if alternate:
- if addr == 0:
- lead0x = False
- else:
- lead0x = True
- fieldsize -= 2
-
s = '0x' if lead0x else ''
if fullhex:
fieldsize = 8 if self.elffile.elfclass == 32 else 16
@@ -676,98 +467,7 @@ class ReadElf(object):
else:
field = '%' + '0%sx' % fieldsize
return s + field % addr
-
- def _print_version_section_header(self, version_section, name, lead0x=True,
- indent=1):
- """ Print a section header of one version related section (versym,
- verneed or verdef) with some options to accomodate readelf
- little differences between each header (e.g. indentation
- and 0x prefixing).
- """
- if hasattr(version_section, 'num_versions'):
- num_entries = version_section.num_versions()
- else:
- num_entries = version_section.num_symbols()
-
- self._emitline("\n%s section '%s' contains %s entries:" %
- (name, bytes2str(version_section.name), num_entries))
- self._emitline('%sAddr: %s Offset: %s Link: %i (%s)' % (
- ' ' * indent,
- self._format_hex(
- version_section['sh_addr'], fieldsize=16, lead0x=lead0x),
- self._format_hex(
- version_section['sh_offset'], fieldsize=6, lead0x=True),
- version_section['sh_link'],
- bytes2str(
- self.elffile.get_section(version_section['sh_link']).name)
- )
- )
-
- def _init_versioninfo(self):
- """ Search and initialize informations about version related sections
- and the kind of versioning used (GNU or Solaris).
- """
- if self._versioninfo is not None:
- return
-
- self._versioninfo = {'versym': None, 'verdef': None,
- 'verneed': None, 'type': None}
-
- for section in self.elffile.iter_sections():
- if isinstance(section, GNUVerSymSection):
- self._versioninfo['versym'] = section
- elif isinstance(section, GNUVerDefSection):
- self._versioninfo['verdef'] = section
- elif isinstance(section, GNUVerNeedSection):
- self._versioninfo['verneed'] = section
- elif isinstance(section, DynamicSection):
- for tag in section.iter_tags():
- if tag['d_tag'] == 'DT_VERSYM':
- self._versioninfo['type'] = 'GNU'
- break
-
- if not self._versioninfo['type'] and (
- self._versioninfo['verneed'] or self._versioninfo['verdef']):
- self._versioninfo['type'] = 'Solaris'
-
- def _symbol_version(self, nsym):
- """ Return a dict containing information on the
- or None if no version information is available
- """
- self._init_versioninfo()
-
- symbol_version = dict.fromkeys(('index', 'name', 'filename', 'hidden'))
-
- if (not self._versioninfo['versym'] or
- nsym >= self._versioninfo['versym'].num_symbols()):
- return None
-
- symbol = self._versioninfo['versym'].get_symbol(nsym)
- index = symbol.entry['ndx']
- if not index in ('VER_NDX_LOCAL', 'VER_NDX_GLOBAL'):
- index = int(index)
-
- if self._versioninfo['type'] == 'GNU':
- # In GNU versioning mode, the highest bit is used to
- # store wether the symbol is hidden or not
- if index & 0x8000:
- index &= ~0x8000
- symbol_version['hidden'] = True
-
- if (self._versioninfo['verdef'] and
- index <= self._versioninfo['verdef'].num_versions()):
- _, verdaux_iter = \
- self._versioninfo['verdef'].get_version(index)
- symbol_version['name'] = bytes2str(next(verdaux_iter).name)
- else:
- verneed, vernaux = \
- self._versioninfo['verneed'].get_version(index)
- symbol_version['name'] = bytes2str(vernaux.name)
- symbol_version['filename'] = bytes2str(verneed.name)
-
- symbol_version['index'] = index
- return symbol_version
-
+
def _section_from_spec(self, spec):
""" Retrieve a section given a "spec" (either number or name).
Return None if no such section exists in the file.
@@ -775,7 +475,7 @@ class ReadElf(object):
try:
num = int(spec)
if num < self.elffile.num_sections():
- return self.elffile.get_section(num)
+ return self.elffile.get_section(num)
else:
return None
except ValueError:
@@ -800,7 +500,7 @@ class ReadElf(object):
"""
if self._dwarfinfo is not None:
return
-
+
if self.elffile.has_dwarf_info():
self._dwarfinfo = self.elffile.get_dwarf_info()
else:
@@ -810,7 +510,7 @@ class ReadElf(object):
""" Dump the debugging info section.
"""
self._emitline('Contents of the .debug_info section:\n')
-
+
# Offset of the .debug_info section in the stream
section_offset = self._dwarfinfo.debug_info_sec.global_offset
@@ -821,11 +521,10 @@ class ReadElf(object):
self._format_hex(cu['unit_length']),
'%s-bit' % cu.dwarf_format()))
self._emitline(' Version: %s' % cu['version']),
- self._emitline(' Abbrev Offset: %s' % (
- self._format_hex(cu['debug_abbrev_offset']))),
+ self._emitline(' Abbrev Offset: %s' % cu['debug_abbrev_offset']),
self._emitline(' Pointer Size: %s' % cu['address_size'])
-
- # The nesting depth of each DIE within the tree of DIEs must be
+
+ # The nesting depth of each DIE within the tree of DIEs must be
# displayed. To implement this, a counter is incremented each time
# the current DIE has children, and decremented when a null die is
# encountered. Due to the way the DIE tree is serialized, this will
@@ -833,15 +532,15 @@ class ReadElf(object):
#
die_depth = 0
for die in cu.iter_DIEs():
- self._emitline(' <%s><%x>: Abbrev Number: %s%s' % (
- die_depth,
- die.offset,
- die.abbrev_code,
- (' (%s)' % die.tag) if not die.is_null() else ''))
if die.is_null():
die_depth -= 1
continue
-
+ self._emitline(' <%s><%x>: Abbrev Number: %s (%s)' % (
+ die_depth,
+ die.offset,
+ die.abbrev_code,
+ die.tag))
+
for attr in itervalues(die.attributes):
name = attr.name
# Unknown attribute values are passed-through as integers
@@ -852,10 +551,10 @@ class ReadElf(object):
name,
describe_attr_value(
attr, die, section_offset)))
-
+
if die.has_children:
die_depth += 1
-
+
self._emitline()
def _dump_debug_line_programs(self):
@@ -867,14 +566,13 @@ class ReadElf(object):
for cu in self._dwarfinfo.iter_CUs():
lineprogram = self._dwarfinfo.line_program_for_CU(cu)
- cu_filename = bytes2str(lineprogram['file_entry'][0].name)
+ cu_filename = ''
if len(lineprogram['include_directory']) > 0:
- dir_index = lineprogram['file_entry'][0].dir_index
- if dir_index > 0:
- dir = lineprogram['include_directory'][dir_index - 1]
- else:
- dir = b'.'
- cu_filename = '%s/%s' % (bytes2str(dir), cu_filename)
+ cu_filename = '%s/%s' % (
+ bytes2str(lineprogram['include_directory'][0]),
+ bytes2str(lineprogram['file_entry'][0].name))
+ else:
+ cu_filename = bytes2str(lineprogram['file_entry'][0].name)
self._emitline('CU: %s:' % cu_filename)
self._emitline('File name Line number Starting address')
@@ -906,7 +604,7 @@ class ReadElf(object):
self._emitline('%-35s %11d %18s' % (
bytes2str(lineprogram['file_entry'][state.file - 1].name),
state.line,
- '0' if state.address == 0 else
+ '0' if state.address == 0 else
self._format_hex(state.address)))
if entry.command == DW_LNS_copy:
# Another readelf oddity...
@@ -921,10 +619,8 @@ class ReadElf(object):
for entry in self._dwarfinfo.CFI_entries():
if isinstance(entry, CIE):
- self._emitline('\n%08x %s %s CIE' % (
- entry.offset,
- self._format_hex(entry['length'], fullhex=True, lead0x=False),
- self._format_hex(entry['CIE_id'], fullhex=True, lead0x=False)))
+ self._emitline('\n%08x %08x %08x CIE' % (
+ entry.offset, entry['length'], entry['CIE_id']))
self._emitline(' Version: %d' % entry['version'])
self._emitline(' Augmentation: "%s"' % bytes2str(entry['augmentation']))
self._emitline(' Code alignment factor: %u' % entry['code_alignment_factor'])
@@ -932,15 +628,13 @@ class ReadElf(object):
self._emitline(' Return address column: %d' % entry['return_address_register'])
self._emitline()
else: # FDE
- self._emitline('\n%08x %s %s FDE cie=%08x pc=%s..%s' % (
+ self._emitline('\n%08x %08x %08x FDE cie=%08x pc=%08x..%08x' % (
entry.offset,
- self._format_hex(entry['length'], fullhex=True, lead0x=False),
- self._format_hex(entry['CIE_pointer'], fullhex=True, lead0x=False),
+ entry['length'],
+ entry['CIE_pointer'],
entry.cie.offset,
- self._format_hex(entry['initial_location'], fullhex=True, lead0x=False),
- self._format_hex(
- entry['initial_location'] + entry['address_range'],
- fullhex=True, lead0x=False)))
+ entry['initial_location'],
+ entry['initial_location'] + entry['address_range']))
self._emit(describe_CFI_instructions(entry))
self._emitline()
@@ -955,24 +649,23 @@ class ReadElf(object):
for entry in self._dwarfinfo.CFI_entries():
if isinstance(entry, CIE):
- self._emitline('\n%08x %s %s CIE "%s" cf=%d df=%d ra=%d' % (
+ self._emitline('\n%08x %08x %08x CIE "%s" cf=%d df=%d ra=%d' % (
entry.offset,
- self._format_hex(entry['length'], fullhex=True, lead0x=False),
- self._format_hex(entry['CIE_id'], fullhex=True, lead0x=False),
+ entry['length'],
+ entry['CIE_id'],
bytes2str(entry['augmentation']),
entry['code_alignment_factor'],
entry['data_alignment_factor'],
entry['return_address_register']))
ra_regnum = entry['return_address_register']
else: # FDE
- self._emitline('\n%08x %s %s FDE cie=%08x pc=%s..%s' % (
+ self._emitline('\n%08x %08x %08x FDE cie=%08x pc=%08x..%08x' % (
entry.offset,
- self._format_hex(entry['length'], fullhex=True, lead0x=False),
- self._format_hex(entry['CIE_pointer'], fullhex=True, lead0x=False),
+ entry['length'],
+ entry['CIE_pointer'],
entry.cie.offset,
- self._format_hex(entry['initial_location'], fullhex=True, lead0x=False),
- self._format_hex(entry['initial_location'] + entry['address_range'],
- fullhex=True, lead0x=False)))
+ entry['initial_location'],
+ entry['initial_location'] + entry['address_range']))
ra_regnum = entry.cie['return_address_register']
# Print the heading row for the decoded table
@@ -986,14 +679,14 @@ class ReadElf(object):
# ra_regnum is always listed last with a special heading.
decoded_table = entry.get_decoded()
reg_order = sorted(ifilter(
- lambda r: r != ra_regnum,
+ lambda r: r != ra_regnum,
decoded_table.reg_order))
# Headings for the registers
for regnum in reg_order:
self._emit('%-6s' % describe_reg_name(regnum))
self._emitline('ra ')
-
+
# Now include ra_regnum in reg_order to print its values similarly
# to the other registers.
reg_order.append(ra_regnum)
@@ -1034,9 +727,6 @@ def main(stream=None):
add_help_option=False, # -h is a real option of readelf
prog='readelf.py',
version=VERSION_STRING)
- optparser.add_option('-d', '--dynamic',
- action='store_true', dest='show_dynamic_tags',
- help='Display the dynamic section')
optparser.add_option('-H', '--help',
action='store_true', dest='help',
help='Display this information')
@@ -1064,9 +754,6 @@ def main(stream=None):
optparser.add_option('-p', '--string-dump',
action='store', dest='show_string_dump', metavar='<number|name>',
help='Dump the contents of section <number|name> as strings')
- optparser.add_option('-V', '--version-info',
- action='store_true', dest='show_version_info',
- help='Display the version sections (if present)')
optparser.add_option('--debug-dump',
action='store', dest='debug_dump_what', metavar='<what>',
help=(
@@ -1097,14 +784,10 @@ def main(stream=None):
if do_program_header:
readelf.display_program_headers(
show_heading=not do_file_header)
- if options.show_dynamic_tags:
- readelf.display_dynamic_tags()
if options.show_symbols:
readelf.display_symbol_tables()
if options.show_relocs:
readelf.display_relocations()
- if options.show_version_info:
- readelf.display_version_info()
if options.show_hex_dump:
readelf.display_hex_dump(options.show_hex_dump)
if options.show_string_dump: