File: p9bin.c

package info (click to toggle)
radare2 0.9.6-3.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 17,496 kB
  • ctags: 45,959
  • sloc: ansic: 240,999; sh: 3,645; makefile: 2,520; python: 1,212; asm: 312; ruby: 214; awk: 209; perl: 188; lisp: 169; java: 23; xml: 17; php: 6
file content (36 lines) | stat: -rw-r--r-- 775 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */

#include "p9bin.h"
#include <r_asm.h>

int r_bin_p9_get_arch(const ut8 *b, int *bits, int *big_endian) {
	unsigned int a = b[0]<<24 | b[1]<<16 | b[2]<<8 | b[3];
	if (bits) *bits = 32;
	if (big_endian) *big_endian = 0;
	switch (a) {
	case I_MAGIC:
		return R_ASM_ARCH_X86;
	case T_MAGIC:
		if (bits) *bits = 64;
		return R_ASM_ARCH_PPC;
	case S_MAGIC:
		if (bits) *bits = 64;
		return R_ASM_ARCH_X86;
	case K_MAGIC:
		return R_ASM_ARCH_SPARC;
	case U_MAGIC:
		if (bits) *bits = 64;
		return R_ASM_ARCH_SPARC;
	case V_MAGIC:
	case M_MAGIC:
	case N_MAGIC:
	case P_MAGIC:
		return R_ASM_ARCH_MIPS;
	case E_MAGIC:
		return R_ASM_ARCH_ARM;
	case Q_MAGIC:
		return R_ASM_ARCH_PPC;
	//case A_MAGIC: // 68020
	}
	return 0;
}