Rizin
unix-like reverse engineering framework and cli tools
p9bin.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2011 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include "p9bin.h"
5 #include <rz_asm.h>
6 
7 int rz_bin_p9_get_arch(RzBuffer *b, int *bits, int *big_endian) {
8  ut32 a;
9  if (!rz_buf_read_be32_at(b, 0, &a)) {
10  return 0;
11  }
12 
13  if (bits) {
14  *bits = 32;
15  }
16  if (big_endian) {
17  *big_endian = 0;
18  }
19  switch (a) {
20  case I_MAGIC:
21  return RZ_ASM_ARCH_X86;
22  case T_MAGIC:
23  if (bits) {
24  *bits = 64;
25  }
26  return RZ_ASM_ARCH_PPC;
27  case S_MAGIC:
28  if (bits) {
29  *bits = 64;
30  }
31  return RZ_ASM_ARCH_X86;
32  case K_MAGIC:
33  return RZ_ASM_ARCH_SPARC;
34  case U_MAGIC:
35  if (bits) {
36  *bits = 64;
37  }
38  return RZ_ASM_ARCH_SPARC;
39  case V_MAGIC:
40  case M_MAGIC:
41  case N_MAGIC:
42  case P_MAGIC:
43  return RZ_ASM_ARCH_MIPS;
44  case E_MAGIC:
45  return RZ_ASM_ARCH_ARM;
46  case Q_MAGIC:
47  return RZ_ASM_ARCH_PPC;
48  // case A_MAGIC: // 68020
49  }
50  return 0;
51 }
int bits(struct state *s, int need)
Definition: blast.c:72
uint32_t ut32
int rz_bin_p9_get_arch(RzBuffer *b, int *bits, int *big_endian)
Definition: p9bin.c:7
#define Q_MAGIC
Definition: p9bin.h:37
#define S_MAGIC
Definition: p9bin.h:42
#define I_MAGIC
Definition: p9bin.h:29
#define K_MAGIC
Definition: p9bin.h:31
#define N_MAGIC
Definition: p9bin.h:38
#define M_MAGIC
Definition: p9bin.h:34
#define E_MAGIC
Definition: p9bin.h:36
#define P_MAGIC
Definition: p9bin.h:40
#define T_MAGIC
Definition: p9bin.h:43
#define V_MAGIC
Definition: p9bin.h:32
#define U_MAGIC
Definition: p9bin.h:41
#define RZ_ASM_ARCH_PPC
Definition: rz_asm.h:26
#define RZ_ASM_ARCH_X86
Definition: rz_asm.h:24
#define RZ_ASM_ARCH_SPARC
Definition: rz_asm.h:31
#define RZ_ASM_ARCH_ARM
Definition: rz_asm.h:25
#define RZ_ASM_ARCH_MIPS
Definition: rz_asm.h:30
#define rz_buf_read_be32_at(b, addr, result)
Definition: rz_buf.h:285
#define b(i)
Definition: sha256.c:42
#define a(i)
Definition: sha256.c:41