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) {
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 
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
47  .data = &rz_asm_plugin_x86_as,
49 };
50 #endif
RzAsmPlugin rz_asm_plugin_x86_as
Definition: asm_x86_as.c:33
RZ_API RzLibStruct rizin_plugin
Definition: asm_x86_as.c:45
#define ASSEMBLER
Definition: asm_x86_as.c:8
static int assemble(RzAsm *a, RzAsmOp *op, const char *buf)
Definition: asm_x86_as.c:10
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
#define RZ_API
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
#define header(is_bt, len_min, ret_op)
@ RZ_ASM_SYNTAX_ATT
Definition: rz_asm.h:51
@ RZ_ASM_SYNTAX_INTEL
Definition: rz_asm.h:50
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
#define RZ_SYS_ENDIAN_LITTLE
Definition: rz_types.h:526
#define RZ_VERSION
Definition: rz_version.h:8
#define a(i)
Definition: sha256.c:41
const char * name
Definition: rz_asm.h:130
const char * version
Definition: rz_asm.h:133
Definition: dis.c:32