Rizin
unix-like reverse engineering framework and cli tools
emit_x86.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2010-2013 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 /* pancake // nopcode.org 2010-2013 -- emit module for rcc */
5 
6 #include <rz_egg.h>
7 #include <rz_types.h>
8 
9 /* hardcoded */
10 #define attsyntax 0
11 
12 #ifdef ARCH_X86_64
13 #define EMIT_NAME emit_x64
14 #define RZ_ARCH "x64"
15 #define RZ_SZ 8
16 #define RZ_SP "rsp"
17 #define RZ_BP "rbp"
18 #define RZ_AX "rax"
19 #define SYSCALL_ATT "syscall"
20 #define SYSCALL_INTEL "syscall"
21 #define RZ_REG_AR_OFF 1
22 static char *regs[] = { "rax", "rdi", "rsi", "rdx", "r10", "r8", "r9" };
23 #else
24 #define EMIT_NAME emit_x86
25 #define RZ_ARCH "x86"
26 #define RZ_SZ 4
27 #define RZ_SP "esp"
28 #define RZ_BP "ebp"
29 #define RZ_AX "eax"
30 #define SYSCALL_ATT "int $0x80"
31 #define SYSCALL_INTEL "int 0x80"
32 #define RZ_REG_AR_OFF 0
33 static char *regs[] = { "eax", "ebx", "ecx", "edx", "esi", "edi", "ebp" };
34 #endif
35 
36 #define RZ_NGP (sizeof(regs) / sizeof(char *))
37 
38 static void emit_init(RzEgg *egg) {
39  // TODO: add 'andb rsp, 0xf0'
40  if (attsyntax) {
41  rz_egg_printf(egg, "mov %%" RZ_SP ", %%" RZ_BP "\n");
42  } else {
43  rz_egg_printf(egg, "mov " RZ_BP ", " RZ_SP "\n");
44  }
45 }
46 
47 static char *emit_syscall(RzEgg *egg, int nargs) {
48  char p[512];
49  if (attsyntax) {
50  return strdup(": mov $`.arg`, %" RZ_AX "\n: " SYSCALL_ATT "\n");
51  }
52  switch (egg->os) {
53  case RZ_EGG_OS_LINUX:
54  strcpy(p, "\n : mov " RZ_AX ", `.arg`\n : " SYSCALL_INTEL "\n");
55  break;
56  case RZ_EGG_OS_OSX:
57  case RZ_EGG_OS_MACOS:
58  case RZ_EGG_OS_DARWIN:
59 #if ARCH_X86_64
60  snprintf(p, sizeof(p), "\n"
61  " : mov rax, `.arg`\n"
62  " : syscall\n");
63 #else
64  snprintf(p, sizeof(p), "\n"
65  " : mov eax, `.arg`\n"
66  " : push eax\n"
67  " : int 0x80\n"
68  " : add esp, %d\n",
69  4); //(nargs+2)*(egg->bits/8));
70 #endif
71  break;
72  default:
73  return NULL;
74  }
75  return strdup(p);
76 }
77 
78 static void emit_frame(RzEgg *egg, int sz) {
79  if (sz < 1) {
80  return;
81  }
82  if (attsyntax) {
83  rz_egg_printf(egg,
84  " push %%" RZ_BP "\n"
85  " mov %%" RZ_SP ", %%" RZ_BP "\n"
86  " sub $%d, %%" RZ_SP "\n",
87  sz);
88  } else {
89  rz_egg_printf(egg,
90  " push " RZ_BP "\n"
91  " mov " RZ_BP ", " RZ_SP "\n"
92  " sub " RZ_SP ", %d\n",
93  sz);
94  }
95 }
96 
97 static void emit_frame_end(RzEgg *egg, int sz, int ctx) {
98  if (sz > 0) {
99  if (attsyntax) {
100  rz_egg_printf(egg, " add $%d, %%" RZ_SP "\n", sz);
101  rz_egg_printf(egg, " pop %%" RZ_BP "\n");
102  } else {
103  rz_egg_printf(egg, " add " RZ_SP ", %d\n", sz);
104  rz_egg_printf(egg, " pop " RZ_BP "\n");
105  }
106  }
107  if (ctx > 0) {
108  rz_egg_printf(egg, " ret\n");
109  }
110 }
111 
112 static void emit_comment(RzEgg *egg, const char *fmt, ...) {
113  va_list ap;
114  char buf[1024];
115  va_start(ap, fmt);
116  vsnprintf(buf, sizeof(buf), fmt, ap);
117  if (attsyntax) {
118  rz_egg_printf(egg, " /* %s */\n", buf);
119  } else {
120  rz_egg_printf(egg, "# %s\n", buf);
121  }
122  va_end(ap);
123 }
124 
125 static void emit_equ(RzEgg *egg, const char *key, const char *value) {
126  rz_egg_printf(egg, ".equ %s,%s\n", key, value);
127 }
128 
129 static const char *getreg(int i) {
130  if (i < 0 || i >= RZ_NGP) {
131  return NULL;
132  }
133  return regs[i];
134 }
135 
136 static void emit_syscall_args(RzEgg *egg, int nargs) {
137  int j, k;
138  for (j = 0; j < nargs; j++) {
139  k = j * RZ_SZ;
140  const char *reg = getreg(j + 1);
141  if (!reg) {
142  eprintf("Cannot find gpr %d\n", j + 1);
143  break;
144  }
145  if (attsyntax) {
146  rz_egg_printf(egg, " mov %d(%%" RZ_SP "), %%%s\n", k, reg);
147  } else {
148  if (k > 0) {
149  rz_egg_printf(egg, " mov %s, [" RZ_SP "+%d]\n", reg, k);
150  } else if (k < 0) {
151  rz_egg_printf(egg, " mov %s, [" RZ_SP "%d]\n", reg, k);
152  } else {
153  rz_egg_printf(egg, " mov %s, [" RZ_SP "]\n", reg);
154  }
155  }
156  }
157 }
158 
159 static void emit_string(RzEgg *egg, const char *dstvar, const char *str, int j) {
160  char *p, str2[64];
161  int i, oj = j;
162 
163  int len = strlen(str);
164  char *s = calloc(1, len + 8);
165  if (!s) {
166  return;
167  }
168  memcpy(s, str, len);
169  memset(s + len, 0, 4);
170 
171  /* XXX: Hack: Adjust offset in RZ_BP correctly for 64b addresses */
172 #define BPOFF (RZ_SZ - 4)
173 #define M32(x) (unsigned int)((x)&0xffffffff)
174  /* XXX: Assumes sizeof(ut32) == 4 */
175  for (i = 4; i <= oj; i += 4) {
176  /* XXX endian issues (non-portable asm) */
177  ut32 *n = (ut32 *)(s + i - 4);
178  p = rz_egg_mkvar(egg, str2, dstvar, i + BPOFF);
179  if (attsyntax) {
180  rz_egg_printf(egg, " movl $0x%x, %s\n", M32(*n), p);
181  } else {
182  rz_egg_printf(egg, " mov dword %s, 0x%x\n", p, M32(*n));
183  }
184  free(p);
185  j -= 4;
186  }
187 #undef M32
188 
189  /* zero */
190  p = rz_egg_mkvar(egg, str2, dstvar, i + BPOFF);
191  if (attsyntax) {
192  rz_egg_printf(egg, " movl $0, %s\n", p);
193  } else {
194  rz_egg_printf(egg, " mov dword %s, 0\n", p);
195  }
196  free(p);
197 
198  /* store pointer */
199  p = rz_egg_mkvar(egg, str2, dstvar, j + 4 + BPOFF);
200  if (attsyntax) {
201  rz_egg_printf(egg, " lea %s, %%" RZ_AX "\n", p);
202  } else {
203  rz_egg_printf(egg, " lea " RZ_AX ", %s\n", p);
204  }
205  free(p);
206 
207  p = rz_egg_mkvar(egg, str2, dstvar, 0);
208  if (attsyntax) {
209  rz_egg_printf(egg, " mov %%" RZ_AX ", %s\n", p);
210  } else {
211  rz_egg_printf(egg, " mov %s, " RZ_AX "\n", p);
212  }
213  free(p);
214 
215 #undef BPOFF
216 #if 0
217  char *p, str2[64];
218  int i, oj = j;
219  for (i=0; i<oj; i+=4) {
220  /* XXX endian and 32/64bit issues */
221  int *n = (int *)(str+i);
222  p = rz_egg_mkvar (egg, str2, dstvar, j);
223  if (attsyntax) rz_egg_printf (egg, " movl $0x%x, %s\n", *n, p);
224  else rz_egg_printf (egg, " mov %s, 0x%x\n", p, *n);
225  j -= 4;
226  }
227  p = rz_egg_mkvar (egg, str2, dstvar, oj);
228  if (attsyntax) rz_egg_printf (egg, " lea %s, %%"RZ_AX"\n", p);
229  else rz_egg_printf (egg, " lea "RZ_AX", %s\n", p);
230  p = rz_egg_mkvar (egg, str2, dstvar, 0);
231  if (attsyntax) rz_egg_printf (egg, " mov %%"RZ_AX", %s\n", p);
232  else rz_egg_printf (egg, " mov %s, "RZ_AX"\n", p);
233 #endif
234  free(s);
235 }
236 
237 static void emit_call(RzEgg *egg, const char *str, int atr) {
238  if (atr) {
239  if (attsyntax) {
240  rz_egg_printf(egg, " call *%s\n", str);
241  } else {
242  rz_egg_printf(egg, " call [%s]\n", str);
243  }
244  } else {
245  rz_egg_printf(egg, " call %s\n", str);
246  }
247 }
248 
249 static void emit_jmp(RzEgg *egg, const char *str, int atr) {
250  if (str) {
251  if (atr) {
252  if (attsyntax) {
253  rz_egg_printf(egg, " jmp *%s\n", str);
254  } else {
255  rz_egg_printf(egg, " jmp [%s]\n", str);
256  }
257  } else {
258  rz_egg_printf(egg, " jmp %s\n", str);
259  }
260  } else {
261  eprintf("Jump without destination\n");
262  }
263 }
264 
265 static void emit_arg(RzEgg *egg, int xs, int num, const char *str) {
266  int d = atoi(str);
267  if (!attsyntax && (*str == '$')) {
268  str = str + 1;
269  }
270  switch (xs) {
271  case 0:
272 #ifdef ARCH_X86_64
273  /* push imm64 instruction not exist, it´s translated to:
274  mov rax, 0x0102030405060708
275  push rax
276  */
277  if (attsyntax) {
278  rz_egg_printf(egg, " mov %s, %%" RZ_AX "\n", str);
279  rz_egg_printf(egg, " push %%" RZ_AX "\n");
280  } else {
281  rz_egg_printf(egg, " mov " RZ_AX ", %s\n", str);
282  rz_egg_printf(egg, " push " RZ_AX "\n");
283  }
284 #else
285  rz_egg_printf(egg, " push %s\n", str);
286 #endif
287  break;
288  case '*':
289  if (attsyntax) {
290  rz_egg_printf(egg, " push (%s)\n", str);
291  } else {
292  rz_egg_printf(egg, " push [%s]\n", str);
293  }
294  break;
295  case '&':
296  if (attsyntax) {
297  if (d != 0) {
298  rz_egg_printf(egg, " addl $%d, %%" RZ_BP "\n", d);
299  }
300  rz_egg_printf(egg, " pushl %%" RZ_BP "\n");
301  if (d != 0) {
302  rz_egg_printf(egg, " subl $%d, %%" RZ_BP "\n", d);
303  }
304  } else {
305  if (d != 0) {
306  rz_egg_printf(egg, " add " RZ_BP ", %d\n", d);
307  }
308  rz_egg_printf(egg, " push " RZ_BP "\n");
309  if (d != 0) {
310  rz_egg_printf(egg, " sub " RZ_BP ", %d\n", d);
311  }
312  }
313  break;
314  }
315 }
316 
317 static void emit_get_result(RzEgg *egg, const char *ocn) {
318  if (attsyntax) {
319  rz_egg_printf(egg, " mov %%" RZ_AX ", %s\n", ocn);
320  } else {
321  rz_egg_printf(egg, " mov %s, " RZ_AX "\n", ocn);
322  }
323 }
324 
325 static void emit_restore_stack(RzEgg *egg, int size) {
326  if (attsyntax) {
327  rz_egg_printf(egg, " add $%d, %%" RZ_SP " /* args */\n", size);
328  } else {
329  rz_egg_printf(egg, " add " RZ_SP ", %d\n", size);
330  }
331 }
332 
333 static void emit_get_while_end(RzEgg *egg, char *str, const char *ctxpush, const char *label) {
334  sprintf(str, " push %s\n jmp %s\n", ctxpush, label);
335 }
336 
337 static void emit_while_end(RzEgg *egg, const char *labelback) {
338 #if 0
339  if (attsyntax) {
340  rz_egg_printf (egg, " pop %%"RZ_AX"\n");
341  rz_egg_printf (egg, " cmp $0, %%"RZ_AX"\n"); // XXX MUST SUPPORT != 0 COMPARE HERE
342  rz_egg_printf (egg, " jnz %s\n", labelback);
343  } else {
344 #endif
345  rz_egg_printf(egg, " pop " RZ_AX "\n");
346  rz_egg_printf(egg, " test " RZ_AX ", " RZ_AX "\n"); // XXX MUST SUPPORT != 0 COMPARE HERE
347  rz_egg_printf(egg, " jnz %s\n", labelback);
348  // }
349 }
350 
351 // XXX: this is wrong
352 static void emit_get_var(RzEgg *egg, int type, char *out, int idx) {
353  switch (type) {
354  case 0: /* variable */
355  if (idx > 0) {
356  sprintf(out, "[" RZ_BP "+%d]", idx);
357  } else if (idx < 0) {
358  sprintf(out, "[" RZ_BP "%d]", idx);
359  } else {
360  strcpy(out, "[" RZ_BP "]");
361  }
362  break;
363  case 1: /* argument */
364  // OMG WE CAN'T stuff found in relative address in stack in the stack
365  eprintf("WARNING: Using stack vars in naked functions\n");
366  idx = 8; // HACK to make arg0, arg4, ... work
367  if (idx > 0) {
368  sprintf(out, "[" RZ_SP "+%d]", idx);
369  } else if (idx < 0) {
370  sprintf(out, "[" RZ_SP "%d]", idx);
371  } else {
372  strcpy(out, "[" RZ_SP "]");
373  }
374  break;
375  case 2:
376  if (idx > 0) {
377  sprintf(out, "[" RZ_BP "+%d]", idx);
378  } else if (idx < 0) {
379  sprintf(out, "[" RZ_BP "%d]", idx);
380  } else {
381  strcpy(out, "[" RZ_BP "]");
382  }
383  break;
384  }
385 }
386 
387 static void emit_trap(RzEgg *egg) {
388  rz_egg_printf(egg, " int3\n");
389 }
390 
391 static void emit_load_ptr(RzEgg *egg, const char *dst) {
392  int d = atoi(dst);
393  if (d == 0) { // hack to handle stackvarptrz
394  char *p = strchr(dst, '+');
395  if (p) {
396  d = atoi(p + 1);
397  }
398  }
399  // eprintf ("emit_load_ptr: HACK\n");
400  // XXX: 32/64bit care
401  // rz_egg_printf (egg, "# DELTA IS (%s)\n", dst);
402  if (attsyntax) {
403  rz_egg_printf(egg, " leal %d(%%" RZ_BP "), %%" RZ_AX "\n", d);
404  } else {
405  rz_egg_printf(egg, " lea " RZ_AX ", [" RZ_BP "+%d]\n", d);
406  }
407  // rz_egg_printf (egg, " movl %%"RZ_BP", %%"RZ_AX"\n");
408  // rz_egg_printf (egg, " addl $%d, %%"RZ_AX"\n", d);
409 }
410 
411 static void emit_branch(RzEgg *egg, char *b, char *g, char *e, char *n, int sz, const char *dst) {
412  char *p, str[64];
413  char *arg = NULL;
414  char *op = "jz";
415  int signed_value = 1; // XXX: add support for signed/unsigned variables
416  /* NOTE that jb/ja are inverted to fit cmp opcode */
417  if (b) {
418  *b = '\0';
419  if (signed_value) {
420  op = e ? "jge" : "jg";
421  } else {
422  op = e ? "jae" : "ja";
423  }
424  arg = b + 1;
425  } else if (g) {
426  *g = '\0';
427  if (signed_value) {
428  op = e ? "jle" : "jl";
429  } else {
430  op = e ? "jbe" : "jb";
431  }
432  arg = g + 1;
433  }
434  if (!arg) {
435  if (e) {
436  arg = e + 1;
437  op = "jne";
438  } else {
439  arg = attsyntax ? "$0" : "0";
440  if (n) {
441  op = "jnz";
442  } else {
443  op = "jz";
444  }
445  }
446  }
447 
448  if (*arg == '=') {
449  arg++; /* for <=, >=, ... */
450  }
451  p = rz_egg_mkvar(egg, str, arg, 0);
452  if (attsyntax) {
453  rz_egg_printf(egg, " pop %%" RZ_AX "\n"); /* TODO: add support for more than one arg get arg0 */
454  rz_egg_printf(egg, " cmp%c %s, %%" RZ_AX "\n", sz, p);
455  } else {
456  rz_egg_printf(egg, " pop " RZ_AX "\n"); /* TODO: add support for more than one arg get arg0 */
457  rz_egg_printf(egg, " cmp " RZ_AX ", %s\n", p);
458  }
459  // if (context>0)
460  free(p);
461  rz_egg_printf(egg, " %s %s\n", op, dst);
462 }
463 
464 static void emit_load(RzEgg *egg, const char *dst, int sz) {
465  if (attsyntax) {
466  switch (sz) {
467  case 'l':
468  rz_egg_printf(egg, " movl %s, %%" RZ_AX "\n", dst);
469  rz_egg_printf(egg, " movl (%%" RZ_AX "), %%" RZ_AX "\n");
470  break;
471  case 'b':
472  rz_egg_printf(egg, " movl %s, %%" RZ_AX "\n", dst);
473  rz_egg_printf(egg, " movzb (%%" RZ_AX "), %%" RZ_AX "\n");
474  break;
475  default:
476  // TODO: unhandled?!?
477  rz_egg_printf(egg, " mov%c %s, %%" RZ_AX "\n", sz, dst);
478  rz_egg_printf(egg, " mov%c (%%" RZ_AX "), %%" RZ_AX "\n", sz);
479  }
480  } else {
481  switch (sz) {
482  case 'l':
483  rz_egg_printf(egg, " mov " RZ_AX ", %s\n", dst);
484  rz_egg_printf(egg, " mov " RZ_AX ", [" RZ_AX "]\n");
485  break;
486  case 'b':
487  rz_egg_printf(egg, " mov " RZ_AX ", %s\n", dst);
488  rz_egg_printf(egg, " movz " RZ_AX ", [" RZ_AX "]\n");
489  break;
490  default:
491  // TODO: unhandled?!?
492  rz_egg_printf(egg, " mov " RZ_AX ", %s\n", dst);
493  rz_egg_printf(egg, " mov " RZ_AX ", [" RZ_AX "]\n");
494  }
495  }
496 }
497 
498 static void emit_mathop(RzEgg *egg, int ch, int vs, int type, const char *eq, const char *p) {
499  char *op;
500  switch (ch) {
501  case '^': op = "xor"; break;
502  case '&': op = "and"; break;
503  case '|': op = "or"; break;
504  case '-': op = "sub"; break;
505  case '+': op = "add"; break;
506  case '*': op = "mul"; break;
507  case '/': op = "div"; break;
508  default: op = "mov"; break;
509  }
510  if (attsyntax) {
511  if (!eq) {
512  eq = "%" RZ_AX;
513  }
514  if (!p) {
515  p = "%" RZ_AX;
516  }
517  rz_egg_printf(egg, " %s%c %c%s, %s\n", op, vs, type, eq, p);
518  } else {
519  if (!eq) {
520  eq = RZ_AX;
521  }
522  if (!p) {
523  p = RZ_AX;
524  }
525  // TODO:
526 #if 0
527  eprintf ("TYPE = %c\n", type);
528  eprintf (" %s%c %c%s, %s\n", op, vs, type, eq, p);
529  eprintf (" %s %s, [%s]\n", op, p, eq);
530 #endif
531  if (type == '*') {
532  rz_egg_printf(egg, " %s %s, [%s]\n", op, p, eq);
533  } else {
534  rz_egg_printf(egg, " %s %s, %s\n", op, p, eq);
535  }
536  }
537 }
538 
539 static const char *emit_regs(RzEgg *egg, int idx) {
540  return regs[idx % RZ_NGP];
541 }
542 
543 static void emit_get_ar(RzEgg *egg, char *out, int idx) {
544  const char *reg = emit_regs(egg, RZ_REG_AR_OFF + idx);
545 
546  if (reg) {
547  strcpy(out, reg);
548  }
549 }
550 
552  .retvar = RZ_AX,
553  .arch = RZ_ARCH,
554  .size = RZ_SZ,
555  .init = emit_init,
556  .jmp = emit_jmp,
557  .call = emit_call,
558  .equ = emit_equ,
559  .regs = emit_regs,
560  //.sc = emit_sc,
561  .trap = emit_trap,
562  .frame = emit_frame,
563  .frame_end = emit_frame_end,
564  .comment = emit_comment,
565  .push_arg = emit_arg,
566  .restore_stack = emit_restore_stack,
567  .get_result = emit_get_result,
568  .syscall_args = emit_syscall_args,
569  .set_string = emit_string,
570  .get_ar = emit_get_ar,
571  .get_var = emit_get_var,
572  .while_end = emit_while_end,
573  .get_while_end = emit_get_while_end,
574  .branch = emit_branch,
575  .load = emit_load,
576  .load_ptr = emit_load_ptr,
577  .mathop = emit_mathop,
578  .syscall = emit_syscall,
579 };
size_t len
Definition: 6502dis.c:15
ut8 op
Definition: 6502dis.c:13
#define e(frag)
lzma_index ** i
Definition: index.h:629
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
static int value
Definition: cmd_api.c:93
#define NULL
Definition: cris-opc.c:27
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 static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
Definition: sflib.h:118
uint32_t ut32
const char * k
Definition: dsignal.c:11
RZ_API void rz_egg_printf(RzEgg *egg, const char *fmt,...)
Definition: egg.c:336
RZ_API char * rz_egg_mkvar(RzEgg *egg, char *out, const char *_str, int delta)
Definition: egg_lang.c:538
static void emit_comment(RzEgg *egg, const char *fmt,...)
Definition: emit_x86.c:112
#define attsyntax
Definition: emit_x86.c:10
#define BPOFF
static void emit_branch(RzEgg *egg, char *b, char *g, char *e, char *n, int sz, const char *dst)
Definition: emit_x86.c:411
static char * emit_syscall(RzEgg *egg, int nargs)
Definition: emit_x86.c:47
static void emit_string(RzEgg *egg, const char *dstvar, const char *str, int j)
Definition: emit_x86.c:159
static void emit_jmp(RzEgg *egg, const char *str, int atr)
Definition: emit_x86.c:249
#define EMIT_NAME
Definition: emit_x86.c:24
static void emit_call(RzEgg *egg, const char *str, int atr)
Definition: emit_x86.c:237
#define M32(x)
#define RZ_AX
Definition: emit_x86.c:29
#define RZ_ARCH
Definition: emit_x86.c:25
#define RZ_SZ
Definition: emit_x86.c:26
#define RZ_REG_AR_OFF
Definition: emit_x86.c:32
static void emit_init(RzEgg *egg)
Definition: emit_x86.c:38
static const char * getreg(int i)
Definition: emit_x86.c:129
static char * regs[]
Definition: emit_x86.c:33
#define RZ_SP
Definition: emit_x86.c:27
static void emit_frame_end(RzEgg *egg, int sz, int ctx)
Definition: emit_x86.c:97
static void emit_get_ar(RzEgg *egg, char *out, int idx)
Definition: emit_x86.c:543
static void emit_get_while_end(RzEgg *egg, char *str, const char *ctxpush, const char *label)
Definition: emit_x86.c:333
static void emit_trap(RzEgg *egg)
Definition: emit_x86.c:387
static void emit_restore_stack(RzEgg *egg, int size)
Definition: emit_x86.c:325
static void emit_while_end(RzEgg *egg, const char *labelback)
Definition: emit_x86.c:337
#define SYSCALL_INTEL
Definition: emit_x86.c:31
#define SYSCALL_ATT
Definition: emit_x86.c:30
#define RZ_BP
Definition: emit_x86.c:28
static void emit_get_var(RzEgg *egg, int type, char *out, int idx)
Definition: emit_x86.c:352
static void emit_load(RzEgg *egg, const char *dst, int sz)
Definition: emit_x86.c:464
#define RZ_NGP
Definition: emit_x86.c:36
static const char * emit_regs(RzEgg *egg, int idx)
Definition: emit_x86.c:539
static void emit_arg(RzEgg *egg, int xs, int num, const char *str)
Definition: emit_x86.c:265
static void emit_mathop(RzEgg *egg, int ch, int vs, int type, const char *eq, const char *p)
Definition: emit_x86.c:498
static void emit_syscall_args(RzEgg *egg, int nargs)
Definition: emit_x86.c:136
static void emit_get_result(RzEgg *egg, const char *ocn)
Definition: emit_x86.c:317
static void emit_frame(RzEgg *egg, int sz)
Definition: emit_x86.c:78
static void emit_load_ptr(RzEgg *egg, const char *dst)
Definition: emit_x86.c:391
static void emit_equ(RzEgg *egg, const char *key, const char *value)
Definition: emit_x86.c:125
struct @667 g
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
sprintf
Definition: kernel.h:365
vsnprintf
Definition: kernel.h:366
#define reg(n)
return memset(p, 0, total)
void * p
Definition: libc.cpp:67
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * calloc(size_t number, size_t size)
Definition: malloc.c:102
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
Definition: sflib.h:126
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
char * dst
Definition: lz4.h:724
int n
Definition: mipsasm.c:19
int type
Definition: mipsasm.c:17
int idx
Definition: setup.py:197
#define eprintf(x, y...)
Definition: rlcc.c:7
static RzSocket * s
Definition: rtr.c:28
#define RZ_EGG_OS_DARWIN
Definition: rz_egg.h:129
#define RZ_EGG_OS_MACOS
Definition: rz_egg.h:132
#define RZ_EGG_OS_OSX
Definition: rz_egg.h:128
#define RZ_EGG_OS_LINUX
Definition: rz_egg.h:127
#define d(i)
Definition: sha256.c:44
#define b(i)
Definition: sha256.c:42
Definition: dis.h:35
ut32 os
Definition: rz_egg.h:109
Definition: dis.c:32