diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2023-03-22 11:18:07 -0400 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2023-03-22 11:18:07 -0400 |
commit | 6c36678e2f75c3cf33bc48fa93ebdd577fc5c3d7 (patch) | |
tree | 98d7672e857f88ee2887d660f437998e5e4f30d7 | |
parent | 5ccb346982bca593f83034b4862043401c4dcaa4 (diff) | |
download | sploit-6c36678e2f75c3cf33bc48fa93ebdd577fc5c3d7.tar.gz sploit-6c36678e2f75c3cf33bc48fa93ebdd577fc5c3d7.zip |
symtbl: order symtbl iteration by offset
When iterating over a symtbl, the returned tuples should be sorted by
offset.
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
-rw-r--r-- | sploit/symtbl.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sploit/symtbl.py b/sploit/symtbl.py index 9412a47..be33dcb 100644 --- a/sploit/symtbl.py +++ b/sploit/symtbl.py @@ -166,7 +166,7 @@ class SymtblImpl: def __iter__(self): """Iterate over table entries as key:value tuples, like dict.items()""" - return iter({ k: self[k] for k in self.__entries__ }.items()) + return iter(sorted({ k: self[k] for k in self.__entries__ }.items(), key=lambda v: int(v[1]))) def __contains__(self, symbol): """Test symbol name membership in table""" @@ -178,7 +178,7 @@ class SymtblImpl: s = f"{len(self)} symbols @ {hex(self)}" if len(self) > 0: s += FMT.format("ADDRESS", "SYMBOL") - for symbol, offset in sorted(self, key=lambda v: int(v[1])): + for symbol, offset in self: disp = f"[{symbol}]" if type(offset) is not int else symbol s += FMT.format(hex(offset), disp) return s |