Skip to content

Commit

Permalink
analysis: fix the function owner computation by considering the next …
Browse files Browse the repository at this point in the history
…field as offset instead of address.

analysis: add off() in Unpacker to extract offsets (basically addr with sign conversion)
  • Loading branch information
invano authored and imbillow committed Aug 20, 2020
1 parent 9c55c12 commit 0973173
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion idb/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ def addr(self):
else:
raise RuntimeError("unexpected wordsize")

def off(self):
offset = self.addr()
mask = (2 ** (self.wordsize *8 )) - 1
if offset & (1 << ((self.wordsize * 8) - 1)):
return offset | ~mask
else:
return offset

Field = namedtuple("Field", ["name", "tag", "index", "cast", "minver"])
# namedtuple default args.
Expand Down Expand Up @@ -966,8 +973,10 @@ def __init__(self, buf, wordsize):
# eg. all of these, if high bit of flags not set.
pass
else:
# We are in a function tail. Chunks can be above or below the tail
# owner
try:
self.owner = self.startEA - u.addr()
self.owner = self.startEA - u.off()
self.refqty = u.dd()
except IndexError:
# see warning note above
Expand Down

0 comments on commit 0973173

Please sign in to comment.