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
}
bits
int bits(struct state *s, int need)
Definition:
blast.c:72
ut32
uint32_t ut32
Definition:
demangler_util.h:31
rz_bin_p9_get_arch
int rz_bin_p9_get_arch(RzBuffer *b, int *bits, int *big_endian)
Definition:
p9bin.c:7
p9bin.h
Q_MAGIC
#define Q_MAGIC
Definition:
p9bin.h:37
S_MAGIC
#define S_MAGIC
Definition:
p9bin.h:42
I_MAGIC
#define I_MAGIC
Definition:
p9bin.h:29
K_MAGIC
#define K_MAGIC
Definition:
p9bin.h:31
N_MAGIC
#define N_MAGIC
Definition:
p9bin.h:38
M_MAGIC
#define M_MAGIC
Definition:
p9bin.h:34
E_MAGIC
#define E_MAGIC
Definition:
p9bin.h:36
P_MAGIC
#define P_MAGIC
Definition:
p9bin.h:40
T_MAGIC
#define T_MAGIC
Definition:
p9bin.h:43
V_MAGIC
#define V_MAGIC
Definition:
p9bin.h:32
U_MAGIC
#define U_MAGIC
Definition:
p9bin.h:41
rz_asm.h
RZ_ASM_ARCH_PPC
#define RZ_ASM_ARCH_PPC
Definition:
rz_asm.h:26
RZ_ASM_ARCH_X86
#define RZ_ASM_ARCH_X86
Definition:
rz_asm.h:24
RZ_ASM_ARCH_SPARC
#define RZ_ASM_ARCH_SPARC
Definition:
rz_asm.h:31
RZ_ASM_ARCH_ARM
#define RZ_ASM_ARCH_ARM
Definition:
rz_asm.h:25
RZ_ASM_ARCH_MIPS
#define RZ_ASM_ARCH_MIPS
Definition:
rz_asm.h:30
rz_buf_read_be32_at
#define rz_buf_read_be32_at(b, addr, result)
Definition:
rz_buf.h:285
b
#define b(i)
Definition:
sha256.c:42
a
#define a(i)
Definition:
sha256.c:41
rz_buf_t
Definition:
rz_buf.h:43
librz
bin
format
p9
p9bin.c
Generated by
1.9.1