Rizin
unix-like reverse engineering framework and cli tools
p9bin.h File Reference
#include <rz_util.h>

Go to the source code of this file.

Classes

struct  plan9_exec
 

Macros

#define HDR_MAGIC   0x00008000 /* header expansion */
 
#define _MAGIC(f, b)   ((f) | ((((4 * (b)) + 0) * (b)) + 7))
 
#define A_MAGIC   _MAGIC(0, 8) /* 68020 */
 
#define I_MAGIC   _MAGIC(0, 11) /* intel 386 */
 
#define J_MAGIC   _MAGIC(0, 12) /* intel 960 (retired) */
 
#define K_MAGIC   _MAGIC(0, 13) /* sparc */
 
#define V_MAGIC   _MAGIC(0, 16) /* mips 3000 BE */
 
#define X_MAGIC   _MAGIC(0, 17) /* att dsp 3210 (retired) */
 
#define M_MAGIC   _MAGIC(0, 18) /* mips 4000 BE */
 
#define D_MAGIC   _MAGIC(0, 19) /* amd 29000 (retired) */
 
#define E_MAGIC   _MAGIC(0, 20) /* arm */
 
#define Q_MAGIC   _MAGIC(0, 21) /* powerpc */
 
#define N_MAGIC   _MAGIC(0, 22) /* mips 4000 LE */
 
#define L_MAGIC   _MAGIC(0, 23) /* dec alpha */
 
#define P_MAGIC   _MAGIC(0, 24) /* mips 3000 LE */
 
#define U_MAGIC   _MAGIC(0, 25) /* sparc64 */
 
#define S_MAGIC   _MAGIC(HDR_MAGIC, 26) /* amd64 */
 
#define T_MAGIC   _MAGIC(HDR_MAGIC, 27) /* powerpc64 */
 
#define TOS_SIZE   14 /* Size of Top of Stack: 56 / 4 */
 
#define HDR_SIZE   0x20
 
#define STR_ADDR   0x1000 /* Start Address */
 
#define TXT_ADDR   HDR_SIZE + ex.text /* TEXT Address */
 
#define DAT_ADDR   STR_ADDR + PAGE_ALIGN(TXT_ADDR) /* DATA&BSS Address */
 
#define p9bin_open(x)   fopen(x, "r")
 
#define p9bin_close(x)   fclose(x)
 

Functions

int rz_bin_p9_get_arch (RzBuffer *b, int *bits, int *big_endian)
 

Macro Definition Documentation

◆ _MAGIC

#define _MAGIC (   f,
  b 
)    ((f) | ((((4 * (b)) + 0) * (b)) + 7))

Definition at line 27 of file p9bin.h.

◆ A_MAGIC

#define A_MAGIC   _MAGIC(0, 8) /* 68020 */

Definition at line 28 of file p9bin.h.

◆ D_MAGIC

#define D_MAGIC   _MAGIC(0, 19) /* amd 29000 (retired) */

Definition at line 35 of file p9bin.h.

◆ DAT_ADDR

#define DAT_ADDR   STR_ADDR + PAGE_ALIGN(TXT_ADDR) /* DATA&BSS Address */

Definition at line 49 of file p9bin.h.

◆ E_MAGIC

#define E_MAGIC   _MAGIC(0, 20) /* arm */

Definition at line 36 of file p9bin.h.

◆ HDR_MAGIC

#define HDR_MAGIC   0x00008000 /* header expansion */

Definition at line 25 of file p9bin.h.

◆ HDR_SIZE

#define HDR_SIZE   0x20

Definition at line 46 of file p9bin.h.

◆ I_MAGIC

#define I_MAGIC   _MAGIC(0, 11) /* intel 386 */

Definition at line 29 of file p9bin.h.

◆ J_MAGIC

#define J_MAGIC   _MAGIC(0, 12) /* intel 960 (retired) */

Definition at line 30 of file p9bin.h.

◆ K_MAGIC

#define K_MAGIC   _MAGIC(0, 13) /* sparc */

Definition at line 31 of file p9bin.h.

◆ L_MAGIC

#define L_MAGIC   _MAGIC(0, 23) /* dec alpha */

Definition at line 39 of file p9bin.h.

◆ M_MAGIC

#define M_MAGIC   _MAGIC(0, 18) /* mips 4000 BE */

Definition at line 34 of file p9bin.h.

◆ N_MAGIC

#define N_MAGIC   _MAGIC(0, 22) /* mips 4000 LE */

Definition at line 38 of file p9bin.h.

◆ p9bin_close

#define p9bin_close (   x)    fclose(x)

Definition at line 54 of file p9bin.h.

◆ p9bin_open

#define p9bin_open (   x)    fopen(x, "r")

Definition at line 53 of file p9bin.h.

◆ P_MAGIC

#define P_MAGIC   _MAGIC(0, 24) /* mips 3000 LE */

Definition at line 40 of file p9bin.h.

◆ Q_MAGIC

#define Q_MAGIC   _MAGIC(0, 21) /* powerpc */

Definition at line 37 of file p9bin.h.

◆ S_MAGIC

#define S_MAGIC   _MAGIC(HDR_MAGIC, 26) /* amd64 */

Definition at line 42 of file p9bin.h.

◆ STR_ADDR

#define STR_ADDR   0x1000 /* Start Address */

Definition at line 47 of file p9bin.h.

◆ T_MAGIC

#define T_MAGIC   _MAGIC(HDR_MAGIC, 27) /* powerpc64 */

Definition at line 43 of file p9bin.h.

◆ TOS_SIZE

#define TOS_SIZE   14 /* Size of Top of Stack: 56 / 4 */

Definition at line 45 of file p9bin.h.

◆ TXT_ADDR

#define TXT_ADDR   HDR_SIZE + ex.text /* TEXT Address */

Definition at line 48 of file p9bin.h.

◆ U_MAGIC

#define U_MAGIC   _MAGIC(0, 25) /* sparc64 */

Definition at line 41 of file p9bin.h.

◆ V_MAGIC

#define V_MAGIC   _MAGIC(0, 16) /* mips 3000 BE */

Definition at line 32 of file p9bin.h.

◆ X_MAGIC

#define X_MAGIC   _MAGIC(0, 17) /* att dsp 3210 (retired) */

Definition at line 33 of file p9bin.h.

Function Documentation

◆ rz_bin_p9_get_arch()

int rz_bin_p9_get_arch ( RzBuffer b,
int bits,
int big_endian 
)

Definition at line 7 of file p9bin.c.

7  {
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
#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

References a, b, bits(), E_MAGIC, I_MAGIC, K_MAGIC, M_MAGIC, N_MAGIC, P_MAGIC, Q_MAGIC, RZ_ASM_ARCH_ARM, RZ_ASM_ARCH_MIPS, RZ_ASM_ARCH_PPC, RZ_ASM_ARCH_SPARC, RZ_ASM_ARCH_X86, rz_buf_read_be32_at, S_MAGIC, T_MAGIC, U_MAGIC, and V_MAGIC.

Referenced by check_buffer(), and info().