From 26183142b16795a6856b94d6797c49ffc424efcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Fri, 21 Aug 2020 12:16:06 +0200 Subject: [PATCH] Update instructions, fix diff settings and add asm-differ ...to simplify setup a bit --- .gitmodules | 3 +++ README.md | 11 +++++++++-- tools/asm-differ | 1 + tools/diff.py | 2 +- tools/diff_settings.py | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) create mode 160000 tools/asm-differ diff --git a/.gitmodules b/.gitmodules index 79e05b7b..918cb79e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "agl"] path = lib/agl url = https://github.com/open-ead/agl +[submodule "asm-differ"] + path = tools/asm-differ + url = https://github.com/simonlindholm/asm-differ diff --git a/README.md b/README.md index a36e0d90..c03b6c41 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ If you are on Ubuntu 18.04, you can [update CMake by using the official CMake AP ### Building a matching version for Switch +0. After cloning this repo, run: `git submodule update --init --recursive` 1. Download [Clang 4.0.1](https://releases.llvm.org/download.html#4.0.1) and extract the archive. 2. Set the UKING_CLANG environment variable to point to the extracted archive, such that `$UKING_CLANG/bin/clang` exists. 3. You'll also need devkitA64. Set the DEVKITA64 environment variable. For Linux, $DEVKITA64 is typically `/opt/devkitpro/devkitA64`. @@ -35,6 +36,12 @@ If you are using Visual Studio Code, installing the CMake Tools extension is rec Using a decompiler such as Hex-Rays or Ghidra is strongly recommended. +You'll also need: + +* pip (for the diff script) +* The original 1.5.0 `main` executable, converted to ELF format with [nx2elf](https://github.com/shuffle2/nx2elf). + * Copy it to data/main.elf -- it is used for the diff script and other tools. + ### Resources * The [ZeldaMods](https://zeldamods.org/wiki/Main_Page) wiki @@ -44,8 +51,8 @@ Using a decompiler such as Hex-Rays or Ghidra is strongly recommended. ### Project tools * To compare assembly: `./diff.py ` - * The function must be listed in data/uking_functions.csv first. - * [asm-differ](https://github.com/simonlindholm/asm-differ) must be in your $PATH, such that running `asm-differ` works. + * The function **must be listed in data/uking_functions.csv first**. + * To do so, search for the name or the address of function you have decompiled, and add the mangled function name to the last column. * Pass the `--source` flag to show source code interleaved with assembly code. * Add the `--inlines` flag to show inline function calls. This is not enabled by default because it usually produces too much output to be useful. * For more options, see [asm-differ](https://github.com/simonlindholm/asm-differ). diff --git a/tools/asm-differ b/tools/asm-differ new file mode 160000 index 00000000..1cb24cfc --- /dev/null +++ b/tools/asm-differ @@ -0,0 +1 @@ +Subproject commit 1cb24cfc3ab8ec28ddab69719da28836592239b1 diff --git a/tools/diff.py b/tools/diff.py index 5a748a96..d59dcfdd 100755 --- a/tools/diff.py +++ b/tools/diff.py @@ -18,7 +18,7 @@ for info in utils.get_functions(): if not info.decomp_name: utils.fail(f"{args.function} has not been decompiled") - subprocess.call(["asm-differ", "-e", info.decomp_name, "0x%016x" % + subprocess.call(["tools/asm-differ/diff.py", "-e", info.decomp_name, "0x%016x" % info.addr, "0x%016x" % addr_end] + unknown) if info.status == utils.FunctionStatus.NonMatching: diff --git a/tools/diff_settings.py b/tools/diff_settings.py index 954a3f01..44e6cb46 100644 --- a/tools/diff_settings.py +++ b/tools/diff_settings.py @@ -3,6 +3,6 @@ def apply(config, args): config['arch'] = 'aarch64' config['baseimg'] = 'data/main.elf' - config['myimg'] = 'build/uking.elf' + config['myimg'] = 'build/uking' config['source_directories'] = ['src'] config['objdump_executable'] = 'aarch64-linux-gnu-objdump'