Rizin
unix-like reverse engineering framework and cli tools
asm_x86_as.c
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2011-2020 pancake <pancake@nopcode.org>
2
// SPDX-License-Identifier: LGPL-3.0-only
3
4
#include <
rz_lib.h
>
5
#include <
rz_asm.h
>
6
#include "../binutils_as.h"
7
8
#define ASSEMBLER "RZ_X86_AS"
9
10
static
int
assemble
(
RzAsm
*
a
,
RzAsmOp
*
op
,
const
char
*
buf
) {
11
#if __i386__ || __x86_64__
12
const
char
*as =
"as"
;
13
#else
14
const
char
*as =
""
;
15
#endif
16
const
char
*syntaxstr =
""
;
17
18
switch
(
a
->syntax) {
19
case
RZ_ASM_SYNTAX_INTEL
:
20
syntaxstr =
".intel_syntax noprefix\n"
;
21
break
;
22
case
RZ_ASM_SYNTAX_ATT
:
23
syntaxstr =
".att_syntax\n"
;
24
break
;
25
}
26
27
char
header
[4096];
28
snprintf
(
header
,
sizeof
(
header
),
"%s.code%i\n"
,
// .org 0x%"PFMT64x"\n"
29
syntaxstr,
a
->bits);
30
return
binutils_assemble
(
a
,
op
,
buf
, as,
ASSEMBLER
,
header
,
""
);
31
}
32
33
RzAsmPlugin
rz_asm_plugin_x86_as
= {
34
.
name
=
"x86.as"
,
35
.desc =
"Intel X86 GNU Assembler (Use "
ASSEMBLER
" env)"
,
36
.arch =
"x86"
,
37
.license =
"LGPL3"
,
38
// NOTE: 64bits is not supported on OSX's nasm :(
39
.bits = 16 | 32 | 64,
40
.endian =
RZ_SYS_ENDIAN_LITTLE
,
41
.assemble = &
assemble
,
42
};
43
44
#ifndef RZ_PLUGIN_INCORE
45
RZ_API
RzLibStruct
rizin_plugin
= {
46
.
type
=
RZ_LIB_TYPE_ASM
,
47
.data = &
rz_asm_plugin_x86_as
,
48
.
version
=
RZ_VERSION
49
};
50
#endif
rz_asm_plugin_x86_as
RzAsmPlugin rz_asm_plugin_x86_as
Definition:
asm_x86_as.c:33
rizin_plugin
RZ_API RzLibStruct rizin_plugin
Definition:
asm_x86_as.c:45
ASSEMBLER
#define ASSEMBLER
Definition:
asm_x86_as.c:8
assemble
static int assemble(RzAsm *a, RzAsmOp *op, const char *buf)
Definition:
asm_x86_as.c:10
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
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
header
#define header(is_bt, len_min, ret_op)
Definition:
lz_encoder_mf.c:191
rz_asm.h
RZ_ASM_SYNTAX_ATT
@ RZ_ASM_SYNTAX_ATT
Definition:
rz_asm.h:51
RZ_ASM_SYNTAX_INTEL
@ RZ_ASM_SYNTAX_INTEL
Definition:
rz_asm.h:50
rz_lib.h
RZ_LIB_TYPE_ASM
@ RZ_LIB_TYPE_ASM
Definition:
rz_lib.h:72
RZ_SYS_ENDIAN_LITTLE
#define RZ_SYS_ENDIAN_LITTLE
Definition:
rz_types.h:526
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_x86_as.c
Generated by
1.9.1