2023-05-04 11:03:02 +02:00
|
|
|
#!/usr/bin/env python3
|
2021-01-10 12:57:43 +01:00
|
|
|
|
|
|
|
import glob
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
2022-01-02 13:10:49 +01:00
|
|
|
root_dir = os.path.abspath(os.path.join(script_dir, "../.."))
|
2021-01-10 12:57:43 +01:00
|
|
|
|
|
|
|
import glob, os
|
2023-07-29 19:03:17 +02:00
|
|
|
|
2021-01-10 12:57:43 +01:00
|
|
|
os.chdir(root_dir)
|
|
|
|
|
|
|
|
for f in Path(root_dir).rglob("*.bin"):
|
|
|
|
if "papermario" in f.name:
|
|
|
|
continue
|
2021-01-10 16:30:41 +01:00
|
|
|
if f.name in ["bin_11A440.bin", "code_71430.bin", "bootcode_font.bin"]:
|
2021-01-10 13:11:39 +01:00
|
|
|
continue
|
2021-01-10 12:57:43 +01:00
|
|
|
|
|
|
|
ras = []
|
2023-07-29 19:03:17 +02:00
|
|
|
result = subprocess.run(
|
|
|
|
["mips-linux-gnu-objdump", "-Dz", "-bbinary", "-mmips", "-EB", f],
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
)
|
2021-01-10 12:57:43 +01:00
|
|
|
output = result.stdout.decode().split("\n")
|
|
|
|
|
|
|
|
for line in output:
|
|
|
|
if re.match(r".*jr.*ra.*", line):
|
|
|
|
ras.append(line)
|
|
|
|
|
|
|
|
if len(ras) > 0:
|
2021-01-10 13:11:39 +01:00
|
|
|
print(f"{f.name} : {len(ras)}")
|
2021-01-10 12:57:43 +01:00
|
|
|
for line in ras:
|
|
|
|
print(line)
|
|
|
|
print("")
|