Skip to content

Commit

Permalink
fix for aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
yapengye committed Aug 29, 2023
1 parent 0238ef5 commit 7738e90
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Detailed requirements will be provided later.
## Usage
Run D-ARM with the following command:
```bash
$ python main.py -i PATH_TO_BINARY -a ARCH[Other Options]
$ python darm.py -i PATH_TO_BINARY -a ARCH [Other Options]
```
e.g.:
```bash
$ python darm.py -i utils/test/spec2000_gcc5.5_O0_marm_v5t_bzip2 -a 32
$ python darm.py -i test/binary/spec2000_gcc5.5_O0_marm_v5t_bzip2 -a 32
```
Arguments:
- `-i`, `--input`: the filepath of input binary (required)
Expand Down
4 changes: 2 additions & 2 deletions binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def read_symbols_32(self):
self.mappings = sorted(self.arm_code_bound + self.thumb_code_bound + self.data)

def read_sections_64(self):
cmd = "utils/arm-linux-gnueabihf-readelf -S " + self.path
cmd = "utils/aarch64-linux-gnu-readelf -S " + self.path
output = subprocess.check_output(cmd, shell=True)
output = output.decode("ISO-8859-1")
line_list = output.split("\n")
Expand Down Expand Up @@ -186,7 +186,7 @@ def read_sections_64(self):
)

def read_symbols_64(self):
cmd = "utils/arm-linux-gnueabihf-readelf -s " + self.path
cmd = "utils/aarch64-linux-gnu-readelf -s " + self.path
output = subprocess.check_output(cmd, shell=True)
output = output.decode("ISO-8859-1")
for line in output.split("\n"):
Expand Down
7 changes: 6 additions & 1 deletion darm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import argparse
from disassembler import ARMDisassembler
from binary import ARMBinary

import resource
import sys

def get_parser():
parser = argparse.ArgumentParser(description="Disassemble ARM binary")
Expand All @@ -17,6 +18,7 @@ def get_parser():
"--arch",
dest="arch",
default=32,
type=int,
help="architecture of input binary (32 or 64)",
)
parser.add_argument(
Expand Down Expand Up @@ -63,4 +65,7 @@ def main():


if __name__ == "__main__":
resource.setrlimit(resource.RLIMIT_STACK, (2**29,-1))
sys.setrecursionlimit(10**6)

main()
7 changes: 4 additions & 3 deletions disassembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,10 +1524,11 @@ def slove_graph(self, ss):
)
self.data_selected = set(self.data.keys()) - self.data_todo

# TODO: check if it is necessary
## Initial update
data_new = self.data_selected.copy()
if not self.greedy_add(set(), data_new, ss, addr):
logging.error("Initial greedy fail")
# data_new = self.data_selected.copy()
# if not self.greedy_add(set(), data_new, ss, addr):
# logging.error("Initial greedy fail")
# logging.debug("{} {} {}".format(hex(addr), t, s))

entry_data = [[-self.data[addr].hint, addr, "D"] for addr in self.data_todo]
Expand Down
Binary file added utils/aarch64-linux-gnu-readelf
Binary file not shown.

0 comments on commit 7738e90

Please sign in to comment.