summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2023-03-22 11:18:07 -0400
committerdusoleil <howcansocksbereal@gmail.com>2023-03-22 11:18:07 -0400
commit6c36678e2f75c3cf33bc48fa93ebdd577fc5c3d7 (patch)
tree98d7672e857f88ee2887d660f437998e5e4f30d7
parent5ccb346982bca593f83034b4862043401c4dcaa4 (diff)
downloadsploit-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.py4
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