Rizin
unix-like reverse engineering framework and cli tools
asm_gas.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2010-2019 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 
9 static int assemble(RzAsm *a, RzAsmOp *op, const char *buf) {
10  int len = 0;
11  ut8 *out;
12  char *cmd = rz_str_newf(
13  "gas /dev/stdin -o /dev/stdout <<__\n"
14  "BITS %i\nORG 0x%" PFMT64x "\n%s\n__",
15  a->bits, a->pc, buf);
16  ut8 *out = (ut8 *)rz_sys_cmd_str(cmd, "", &len);
17  if (out) {
19  free(out);
20  }
21  op->size = len;
22  free(cmd);
23  return len;
24 }
25 
27  .name = "x86.gas",
28  .license = "LGPL3",
29  .desc = "GNU Assembler (gas)",
30  .bits = 16 | 32 | 64,
31  .endian = RZ_SYS_ENDIAN_LITTLE,
32  .assemble = &assemble
33 };
34 
35 #ifndef RZ_PLUGIN_INCORE
38  .data = &rz_asm_plugin_x86_gas,
40 };
41 #endif
size_t len
Definition: 6502dis.c:15
RZ_API void rz_asm_op_set_buf(RzAsmOp *op, const ut8 *buf, int len)
Definition: aop.c:83
RZ_API RzLibStruct rizin_plugin
Definition: asm_gas.c:36
RzAsmPlugin rz_asm_plugin_x86_gas
Definition: asm_gas.c:26
static int assemble(RzAsm *a, RzAsmOp *op, const char *buf)
Definition: asm_gas.c:9
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
#define RZ_API
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
Definition: sflib.h:79
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API int RZ_API char * rz_sys_cmd_str(const char *cmd, const char *input, int *len)
Definition: sys.c:669
#define RZ_SYS_ENDIAN_LITTLE
Definition: rz_types.h:526
#define PFMT64x
Definition: rz_types.h:393
#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