-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbinarydiff.py
29 lines (23 loc) · 977 Bytes
/
binarydiff.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
Diffs the sections and relocations (where possible) of a dol/rel file
"""
from argparse import ArgumentParser
import colorama as col
from ppcdis import diff_secs, diff_relocs, load_binary_yml, RelReader
if __name__ == "__main__":
hex_int = lambda s: int(s, 16)
parser = ArgumentParser(description="Diff the sections and relocations of dol/rel files")
parser.add_argument("good", type=str, help="Path to good binary yml")
parser.add_argument("test", type=str, help="Path to test binary")
parser.add_argument("-n", "--max-reloc-diffs", type=int, default=-1,
help="Maximum number of rel relocation diffs to print")
args = parser.parse_args()
# Init colorama
col.init()
# Load binaries
good = load_binary_yml(args.good)
test = good.load_other(args.test)
# Do diff
ret = diff_secs(good, test)
if not ret and isinstance(good, RelReader):
diff_relocs(good, test, args.max_reloc_diffs)