Permalink
Browse files

Fix #7636 - Add hack for PS2 binaries

  • Loading branch information...
radare committed Jul 10, 2017
1 parent 1b6cfb6 commit 3c25b9830e1c14da27f08ecadab70dd6b40d08eb
Showing with 35 additions and 0 deletions.
  1. +35 −0 libr/bin/format/elf/elf.c
@@ -1987,6 +1987,41 @@ int Elf_(r_bin_elf_get_bits)(ELFOBJ *bin) {
if (bin->ehdr.e_machine == EM_ARC_A5) {
return 16;
}
/* Hack for Ps2 */
if (bin->ehdr.e_machine == EM_MIPS) {
const ut32 mipsType = bin->ehdr.e_flags & EF_MIPS_ARCH;
if (bin->ehdr.e_type == ET_EXEC) {
int i;
bool haveInterp = false;
for (i = 0; i < bin->ehdr.e_phnum; i++) {
if (bin->phdr[i].p_type == PT_INTERP) {
haveInterp = true;
}
}
if (!haveInterp && mipsType == EF_MIPS_ARCH_3) {
// Playstation2 Hack
return 64;
}
}
// TODO: show this specific asm.cpu somewhere in bininfo (mips1, mips2, mips3, mips32r2, ...)
switch (mipsType) {
case EF_MIPS_ARCH_1:
case EF_MIPS_ARCH_2:
case EF_MIPS_ARCH_3:
case EF_MIPS_ARCH_4:
case EF_MIPS_ARCH_5:
case EF_MIPS_ARCH_32:
return 32;
case EF_MIPS_ARCH_64:
return 64;
case EF_MIPS_ARCH_32R2:
return 32;
case EF_MIPS_ARCH_64R2:
return 64;
break;
}
return 32;
}
/* Hack for Thumb */
if (bin->ehdr.e_machine == EM_ARM) {
if (bin->ehdr.e_type != ET_EXEC) {

0 comments on commit 3c25b98

Please sign in to comment.