I want to disassemble Wii game executable binaries in C, which use the broadway microprocessor and unfortunately the only disassembler I am aware that I can use is libopcodes.
I am following this respository https://github.com/antonblanchard/qtrace-tools/blob/3a83cc095de6fb6726c7c969ba8bbeaec75b62c9/qtdis/qtdis.c#L221 as a reference, which uses Ubuntu's binutils-multiarch-dev
package. However, my calls to disassembler
always returns a NULL pointer (even when using exactly the same arguments he uses). I only get a valid disassembler with disassembler(bfd_arch_i386, false, bfd_mach_x86_64, NULL)
.
Here's a minimum failing example (test.c
):
#include <stdio.h>
// including BFD stuff requires this stuff apparently...
// https://stackoverflow.com/questions/11748035/binutils-bfd-h-wants-config-h-now
#define PACKAGE "pkg-name"
#define PACKAGE_VERSION "1.0.0"
#include <dis-asm.h>
int main(int argc, char const *argv[]) {
disassembler_ftype disasm = disassembler(bfd_arch_powerpc, true, bfd_mach_ppc_750, NULL);
if (!disasm) {
printf("wth no disasm\n");
} else {
printf("ok disasm\n");
}
return 0;
}
Install binutils multiarch sudo apt-get install binutils-multiarch-dev
.
Build with gcc -o test test.c -lopcodes-multiarch
and run ./test
It seems that my libopcodes
does not support any PowerPC architectures I tried. I would try to build from source but binutils' README https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/README;h=42f494800c0b93b1188857bdeaa6ae48843aca24;hb=cd919f5533cc8aa495acd75a6f059e5fcf2e6af9 only mentions flags for supporting specific binary formats, not architectures/machines. Any suggestions?