Rizin
unix-like reverse engineering framework and cli tools
asm_arm_as.c
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2015-2020 pancake <pancake@nopcode.org>
2
// SPDX-License-Identifier: LGPL-3.0-only
3
4
#include <
rz_types.h
>
5
#include <
rz_util.h
>
6
#include <
rz_lib.h
>
7
#include <
rz_asm.h
>
8
#include "../binutils_as.h"
9
10
#define ASSEMBLER32 "RZ_ARM32_AS"
11
#define ASSEMBLER64 "RZ_ARM64_AS"
12
13
static
int
assemble
(
RzAsm
*
a
,
RzAsmOp
*
op
,
const
char
*
buf
) {
14
int
bits
=
a
->bits;
15
char
*as =
""
;
16
#if __arm__
17
if
(
bits
<= 32) {
18
as =
"as"
;
19
}
20
#elif __aarch64__
21
if
(
bits
== 64) {
22
as =
"as"
;
23
}
24
#endif
25
char
cmd_opt[4096];
26
snprintf
(cmd_opt,
sizeof
(cmd_opt),
"%s %s"
,
27
bits
== 16 ?
"-mthumb"
:
""
,
28
a
->big_endian ?
"-EB"
:
"-EL"
);
29
return
binutils_assemble
(
a
,
op
,
buf
, as,
30
bits
== 64 ?
ASSEMBLER64
:
ASSEMBLER32
,
31
bits
<= 32 ?
".syntax unified\n"
:
""
, cmd_opt);
32
}
33
34
RzAsmPlugin
rz_asm_plugin_arm_as
= {
35
.
name
=
"arm.as"
,
36
.desc =
"as ARM Assembler (use "
ASSEMBLER32
" and "
ASSEMBLER64
" environment)"
,
37
.arch =
"arm"
,
38
.author =
"pancake"
,
39
.license =
"LGPL3"
,
40
.bits = 16 | 32 | 64,
41
.endian =
RZ_SYS_ENDIAN_LITTLE
|
RZ_SYS_ENDIAN_BIG
,
42
.assemble = &
assemble
,
43
};
44
45
#ifndef RZ_PLUGIN_INCORE
46
RZ_API
RzLibStruct
rizin_plugin
= {
47
.
type
=
RZ_LIB_TYPE_ASM
,
48
.data = &
rz_asm_plugin_arm_as
,
49
.
version
=
RZ_VERSION
50
};
51
#endif
ASSEMBLER64
#define ASSEMBLER64
Definition:
asm_arm_as.c:11
rizin_plugin
RZ_API RzLibStruct rizin_plugin
Definition:
asm_arm_as.c:46
ASSEMBLER32
#define ASSEMBLER32
Definition:
asm_arm_as.c:10
rz_asm_plugin_arm_as
RzAsmPlugin rz_asm_plugin_arm_as
Definition:
asm_arm_as.c:34
assemble
static int assemble(RzAsm *a, RzAsmOp *op, const char *buf)
Definition:
asm_arm_as.c:13
binutils_assemble
int binutils_assemble(RzAsm *a, RzAsmOp *op, const char *buf, const char *as, const char *env, const char *header, const char *cmd_opt)
Definition:
binutils_as.c:7
bits
int bits(struct state *s, int need)
Definition:
blast.c:72
RZ_API
#define RZ_API
Definition:
core_plugin_example.c:36
buf
voidpf void * buf
Definition:
ioapi.h:138
snprintf
snprintf
Definition:
kernel.h:364
rz_asm.h
rz_lib.h
RZ_LIB_TYPE_ASM
@ RZ_LIB_TYPE_ASM
Definition:
rz_lib.h:72
rz_types.h
RZ_SYS_ENDIAN_BIG
#define RZ_SYS_ENDIAN_BIG
Definition:
rz_types.h:527
RZ_SYS_ENDIAN_LITTLE
#define RZ_SYS_ENDIAN_LITTLE
Definition:
rz_types.h:526
rz_util.h
RZ_VERSION
#define RZ_VERSION
Definition:
rz_version.h:8
a
#define a(i)
Definition:
sha256.c:41
rz_asm_op_t
Definition:
rz_asm.h:66
rz_asm_plugin_t
Definition:
rz_asm.h:129
rz_asm_plugin_t::name
const char * name
Definition:
rz_asm.h:130
rz_asm_plugin_t::version
const char * version
Definition:
rz_asm.h:133
rz_asm_t
Definition:
rz_asm.h:98
rz_lib_struct_t
Definition:
rz_lib.h:57
rz_lib_struct_t::type
int type
Definition:
rz_lib.h:58
op
Definition:
dis.c:32
librz
asm
p
asm_arm_as.c
Generated by
1.9.1