2019-02-01 22:33:43 -06:00
|
|
|
/* radare - LGPL - Copyright 2010-2019 - pancake */
|
2010-02-05 12:21:37 +01:00
|
|
|
|
|
|
|
#include <r_types.h>
|
|
|
|
#include <r_util.h>
|
|
|
|
#include <r_lib.h>
|
|
|
|
#include <r_asm.h>
|
|
|
|
|
2013-04-09 22:54:04 +02:00
|
|
|
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
|
2010-02-05 12:21:37 +01:00
|
|
|
int len = 0;
|
|
|
|
ut8 *out;
|
2019-02-01 22:33:43 -06:00
|
|
|
char *cmd = r_str_newf (
|
2013-04-09 22:54:04 +02:00
|
|
|
"gas /dev/stdin -o /dev/stdout <<__\n"
|
|
|
|
"BITS %i\nORG 0x%"PFMT64x"\n%s\n__",
|
|
|
|
a->bits, a->pc, buf);
|
2019-02-01 22:33:43 -06:00
|
|
|
ut8 *out = (ut8 *)r_sys_cmd_str (cmd, "", &len);
|
2010-02-05 12:21:37 +01:00
|
|
|
if (out) {
|
2019-02-01 22:33:43 -06:00
|
|
|
r_asm_op_set_buf (op, out, len);
|
2013-12-02 04:44:26 +01:00
|
|
|
free (out);
|
2010-02-05 12:21:37 +01:00
|
|
|
}
|
2013-12-06 05:04:17 +01:00
|
|
|
op->size = len;
|
2019-02-01 22:33:43 -06:00
|
|
|
free (cmd);
|
2010-02-05 12:21:37 +01:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2014-01-03 00:13:46 +01:00
|
|
|
RAsmPlugin r_asm_plugin_x86_gas = {
|
2015-08-24 15:43:13 +02:00
|
|
|
.name = "x86.gas",
|
2013-12-02 04:44:26 +01:00
|
|
|
.license = "LGPL3",
|
2014-02-25 17:03:12 +01:00
|
|
|
.desc = "GNU Assembler (gas)",
|
2013-12-05 18:41:13 +01:00
|
|
|
.bits = 16|32|64,
|
2016-04-26 19:09:15 +10:00
|
|
|
.endian = R_SYS_ENDIAN_LITTLE,
|
|
|
|
.assemble = &assemble
|
2010-02-05 12:21:37 +01:00
|
|
|
};
|
|
|
|
|
2019-06-13 19:12:51 +02:00
|
|
|
#ifndef R2_PLUGIN_INCORE
|
2018-09-15 23:52:12 +03:00
|
|
|
R_API RLibStruct radare_plugin = {
|
2010-02-05 12:21:37 +01:00
|
|
|
.type = R_LIB_TYPE_ASM,
|
2015-07-12 16:04:10 +02:00
|
|
|
.data = &r_asm_plugin_x86_gas,
|
|
|
|
.version = R2_VERSION
|
2010-02-05 12:21:37 +01:00
|
|
|
};
|
|
|
|
#endif
|