From 6a12cde058e1bc0da3617bfaf6e608d0772fddfe Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Fri, 9 Sep 2011 10:23:16 +0300 Subject: [PATCH] some cleanup --- scripts/readelf.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/readelf.py b/scripts/readelf.py index 44b7798..427ee8f 100644 --- a/scripts/readelf.py +++ b/scripts/readelf.py @@ -87,11 +87,24 @@ class ReadElf(object): self._emitline(' Section header string table index: %s' % header['e_shstrndx']) + def _format_addr(self, addr, fullhex=False, lead0x=True): + """ Format an address into a hexadecimal string. - def _format_addr(self, addr): - """ Format an address into a string + fullhex: + If True, include leading zeros in the address, adjusted for + the elfclass. + + lead0x: + If True, leading 0x is added """ - return '0x%x' % addr + s = '0x' if lead0x else '' + if fullhex: + if self.elffile.elfclass == 32: + return s + '%08x' % addr + else: + return s + '%016x' % addr + else: + return s + '%x' % addr def _emit(self, s): """ Emit an object to output -- 2.30.2