Rizin
unix-like reverse engineering framework and cli tools
il_opcodes.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 heersin <teablearcher@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_il/rz_il_opcodes.h>
5 
6 #define rz_il_op_new_0(sort, id) \
7  do { \
8  ret = RZ_NEW0(RzILOp##sort); \
9  if (!ret) { \
10  return NULL; \
11  } \
12  ret->code = id; \
13  } while (0)
14 
15 #define rz_il_op_new_1(sort, id, t, s, v0) \
16  do { \
17  ret = RZ_NEW0(RzILOp##sort); \
18  if (!ret) { \
19  return NULL; \
20  } \
21  ret->code = id; \
22  ret->op.s.v0 = v0; \
23  } while (0)
24 
25 #define rz_il_op_new_2(sort, id, t, s, v0, v1) \
26  do { \
27  ret = RZ_NEW0(RzILOp##sort); \
28  if (!ret) { \
29  return NULL; \
30  } \
31  ret->code = id; \
32  ret->op.s.v0 = v0; \
33  ret->op.s.v1 = v1; \
34  } while (0)
35 
36 #define rz_il_op_new_3(sort, id, t, s, v0, v1, v2) \
37  do { \
38  ret = RZ_NEW0(RzILOp##sort); \
39  if (!ret) { \
40  return NULL; \
41  } \
42  ret->code = id; \
43  ret->op.s.v0 = v0; \
44  ret->op.s.v1 = v1; \
45  ret->op.s.v2 = v2; \
46  } while (0)
47 
54  rz_return_val_if_fail(condition && (x || y), NULL);
55  RzILOpPure *ret;
56  rz_il_op_new_3(Pure, RZ_IL_OP_ITE, RzILOpArgsIte, ite, condition, x, y);
57  return ret;
58 }
59 
67  RzILOpPure *ret;
68  rz_il_op_new_2(Pure, RZ_IL_OP_VAR, RzILOpArgsVar, var, v, kind);
69  return ret;
70 }
71 
76  rz_return_val_if_fail(name && exp && body, NULL);
77  RzILOpPure *ret;
78  rz_il_op_new_3(Pure, RZ_IL_OP_LET, RzILOpArgsLet, let, name, exp, body);
79  return ret;
80 }
81 
86  RzILOpPure *ret;
88  return ret;
89 }
90 
95  RzILOpPure *ret;
97  return ret;
98 }
99 
109  RzILOpBool *ret;
110  rz_il_op_new_2(Bool, RZ_IL_OP_AND, RzILOpArgsBoolAnd, booland, x, y);
111  return ret;
112 }
113 
123  RzILOpBool *ret;
124  rz_il_op_new_2(Bool, RZ_IL_OP_OR, RzILOpArgsBoolOr, boolor, x, y);
125  return ret;
126 }
127 
137  RzILOpBool *ret;
138  rz_il_op_new_2(Bool, RZ_IL_OP_XOR, RzILOpArgsBoolXor, boolxor, x, y);
139  return ret;
140 }
141 
151  RzILOpBool *ret;
153  return ret;
154 }
155 
163  RzILOpBitVector *ret;
164  rz_il_op_new_1(BitVector, RZ_IL_OP_BITV, RzILOpArgsBv, bitv, value);
165  return ret;
166 }
167 
175  if (!value) {
176  return NULL;
177  }
178  RzILOpBool *ret = RZ_NEW0(RzILOpBool);
179  if (!ret) {
180  rz_bv_free(value);
181  return NULL;
182  }
183  ret->code = RZ_IL_OP_BITV;
184  ret->op.bitv.value = value;
185  return ret;
186 }
187 
195  if (!value) {
196  return NULL;
197  }
198  RzILOpBool *ret = RZ_NEW0(RzILOpBool);
199  if (!ret) {
200  rz_bv_free(value);
201  return NULL;
202  }
203  ret->code = RZ_IL_OP_BITV;
204  ret->op.bitv.value = value;
205  return ret;
206 }
207 
214  RzILOpBool *ret;
215  rz_il_op_new_1(Bool, RZ_IL_OP_MSB, RzILOpArgsLsb, lsb, bv);
216  return ret;
217 }
218 
225  RzILOpBool *ret;
226  rz_il_op_new_1(Bool, RZ_IL_OP_LSB, RzILOpArgsMsb, lsb, bv);
227  return ret;
228 }
229 
235  RzILOpBool *ret;
236  rz_il_op_new_1(Bool, RZ_IL_OP_IS_ZERO, RzILOpArgsIsZero, is_zero, bv);
237  return ret;
238 }
239 
246 }
247 
253  RzILOpBool *ret;
255  return ret;
256 }
257 
265  RzILOpBool *ret;
266  rz_il_op_new_2(Bool, RZ_IL_OP_ULE, RzILOpArgsUle, ule, x, y);
267  return ret;
268 }
269 
277  RzILOpBool *ret;
278  rz_il_op_new_2(Bool, RZ_IL_OP_SLE, RzILOpArgsSle, sle, x, y);
279  return ret;
280 }
281 
287  return rz_il_op_new_bool_and(
288  rz_il_op_new_ule(x, y),
290 }
291 
297  return rz_il_op_new_bool_and(
298  rz_il_op_new_sle(x, y),
300 }
301 
307  return rz_il_op_new_bool_or(
310 }
311 
317  return rz_il_op_new_bool_or(
320 }
321 
328 }
329 
336 }
337 
343  RzILOpBitVector *ret;
345  return ret;
346 }
347 
356 }
357 
366 }
367 
375  RzILOpBitVector *ret;
376  rz_il_op_new_1(BitVector, RZ_IL_OP_NEG, RzILOpArgsNeg, neg, bv);
377  return ret;
378 }
379 
387  RzILOpBitVector *ret;
388  rz_il_op_new_1(BitVector, RZ_IL_OP_LOGNOT, RzILOpArgsLogNot, lognot, bv);
389  return ret;
390 }
391 
399  RzILOpBitVector *ret;
400  rz_il_op_new_2(BitVector, RZ_IL_OP_ADD, RzILOpArgsAdd, add, x, y);
401  return ret;
402 }
403 
411  RzILOpBitVector *ret;
412  rz_il_op_new_2(BitVector, RZ_IL_OP_SUB, RzILOpArgsSub, sub, x, y);
413  return ret;
414 }
415 
423  RzILOpBitVector *ret;
424  rz_il_op_new_2(BitVector, RZ_IL_OP_MUL, RzILOpArgsMul, mul, x, y);
425  return ret;
426 }
427 
435  RzILOpBitVector *ret;
436  rz_il_op_new_2(BitVector, RZ_IL_OP_DIV, RzILOpArgsDiv, div, x, y);
437  return ret;
438 }
439 
447  RzILOpBitVector *ret;
449  return ret;
450 }
451 
459  RzILOpBitVector *ret;
460  rz_il_op_new_2(BitVector, RZ_IL_OP_MOD, RzILOpArgsSmod, smod, x, y);
461  return ret;
462 }
463 
471  RzILOpBitVector *ret;
472  rz_il_op_new_2(BitVector, RZ_IL_OP_SMOD, RzILOpArgsMod, mod, x, y);
473  return ret;
474 }
475 
483  RzILOpBitVector *ret;
484  rz_il_op_new_2(BitVector, RZ_IL_OP_LOGAND, RzILOpArgsLogand, logand, x, y);
485  return ret;
486 }
487 
495  RzILOpBitVector *ret;
496  rz_il_op_new_2(BitVector, RZ_IL_OP_LOGOR, RzILOpArgsLogor, logor, x, y);
497  return ret;
498 }
499 
507  RzILOpBitVector *ret;
508  rz_il_op_new_2(BitVector, RZ_IL_OP_LOGXOR, RzILOpArgsLogxor, logxor, x, y);
509  return ret;
510 }
511 
518  rz_return_val_if_fail(fill_bit && x && y, NULL);
519  RzILOpBitVector *ret;
520  rz_il_op_new_3(BitVector, RZ_IL_OP_SHIFTL, RzILOpArgsShiftLeft, shiftl, fill_bit, x, y);
521  return ret;
522 }
523 
530  rz_return_val_if_fail(fill_bit && x && y, NULL);
531  RzILOpBitVector *ret;
532  rz_il_op_new_3(BitVector, RZ_IL_OP_SHIFTR, RzILOpArgsShiftRight, shiftr, fill_bit, x, y);
533  return ret;
534 }
535 
542 }
543 
548  rz_return_val_if_fail(high && low, NULL);
549  RzILOpBitVector *ret;
550  rz_il_op_new_2(BitVector, RZ_IL_OP_APPEND, RzILOpArgsAppend, append, high, low);
551  return ret;
552 }
553 
561  RzILOpEffect *ret;
563  return ret;
564 }
565 
567  RzILOpEffect *ret;
568  rz_il_op_new_0(Effect, RZ_IL_OP_NOP);
569  return ret;
570 }
571 
579  RzILOpEffect *ret;
580  rz_il_op_new_3(Effect, RZ_IL_OP_SET, RzILOpArgsSet, set, v, is_local, x);
581  return ret;
582 }
583 
591  RzILOpEffect *ret;
593  return ret;
594 }
595 
603  RzILOpEffect *ret;
604  rz_il_op_new_1(Effect, RZ_IL_OP_GOTO, RzILOpArgsGoto, goto_, lbl);
605  return ret;
606 }
607 
615  RzILOpEffect *ret;
616  rz_il_op_new_2(Effect, RZ_IL_OP_SEQ, RzILOpArgsSeq, seq, x, y);
617  return ret;
618 }
619 
633  if (!n) {
634  return rz_il_op_new_nop();
635  }
637  RzILOpEffect *prev_seq = NULL;
638  va_list args;
639  va_start(args, n);
640  for (ut32 i = 0; i < n; ++i) {
641  RzILOpEffect *cur_op = va_arg(args, RzILOpEffect *);
642  if (i == n - 1) {
643  // last one
644  if (prev_seq) {
645  prev_seq->op.seq.y = cur_op;
646  } else {
647  // n == 1, no need for seq at all
648  root = cur_op;
649  }
650  break;
651  }
653  if (!seq) {
654  break;
655  }
656  seq->code = RZ_IL_OP_SEQ;
657  seq->op.seq.x = cur_op;
658  if (prev_seq) {
659  // not the first one
660  // We let the seq recurse in the second op because that
661  // can enable tail call elimination in the evaluation.
662  prev_seq->op.seq.y = seq;
663  } else {
664  // first one
665  root = seq;
666  }
667  prev_seq = seq;
668  }
669  va_end(args);
670  return root;
671 }
672 
679  rz_return_val_if_fail(data_eff && ctrl_eff, NULL);
680  RzILOpEffect *ret;
681  rz_il_op_new_3(Effect, RZ_IL_OP_BLK, RzILOpArgsBlk, blk, label, data_eff, ctrl_eff);
682  return ret;
683 }
684 
691  rz_return_val_if_fail(condition && data_eff, NULL);
692  RzILOpEffect *ret;
693  rz_il_op_new_2(Effect, RZ_IL_OP_REPEAT, RzILOpArgsRepeat, repeat, condition, data_eff);
694  return ret;
695 }
696 
703  rz_return_val_if_fail(condition && (true_eff || false_eff), NULL);
704  RzILOpEffect *ret;
705  if (!true_eff) {
706  true_eff = rz_il_op_new_nop();
707  }
708  if (!false_eff) {
709  false_eff = rz_il_op_new_nop();
710  }
711  rz_il_op_new_3(Effect, RZ_IL_OP_BRANCH, RzILOpArgsBranch, branch, condition, true_eff, false_eff);
712  return ret;
713 }
714 
720  RzILOpPure *ret;
722  return ret;
723 }
724 
730  RzILOpEffect *ret;
732  return ret;
733 }
734 
739  rz_return_val_if_fail(key && n_bits, NULL);
740  RzILOpPure *ret;
741  rz_il_op_new_3(Pure, RZ_IL_OP_LOADW, RzILOpArgsLoadW, loadw, mem, key, n_bits);
742  return ret;
743 }
744 
750  RzILOpEffect *ret;
752  return ret;
753 }
754 
755 #undef rz_il_op_new_0
756 #undef rz_il_op_new_1
757 #undef rz_il_op_new_2
758 #undef rz_il_op_new_3
759 
766  if (!r) {
767  return NULL;
768  }
769 #define DUP_OP1(arg, m0) \
770  do { \
771  r->op.arg.m0 = rz_il_op_pure_dup(op->op.arg.m0); \
772  if (!r->op.arg.m0) { \
773  return NULL; \
774  } \
775  } while (0);
776 #define DUP_OP2(arg, m0, m1) \
777  do { \
778  r->op.arg.m0 = rz_il_op_pure_dup(op->op.arg.m0); \
779  r->op.arg.m1 = rz_il_op_pure_dup(op->op.arg.m1); \
780  if (!r->op.arg.m0 || !r->op.arg.m1) { \
781  rz_il_op_pure_free(r->op.arg.m0); \
782  rz_il_op_pure_free(r->op.arg.m1); \
783  return NULL; \
784  } \
785  } while (0);
786 #define DUP_OP3(arg, m0, m1, m2) \
787  do { \
788  r->op.arg.m0 = rz_il_op_pure_dup(op->op.arg.m0); \
789  r->op.arg.m1 = rz_il_op_pure_dup(op->op.arg.m1); \
790  r->op.arg.m2 = rz_il_op_pure_dup(op->op.arg.m2); \
791  if (!r->op.arg.m0 || !r->op.arg.m1 || !r->op.arg.m2) { \
792  rz_il_op_pure_free(r->op.arg.m0); \
793  rz_il_op_pure_free(r->op.arg.m1); \
794  rz_il_op_pure_free(r->op.arg.m2); \
795  return NULL; \
796  } \
797  } while (0);
798  r->code = op->code;
799  switch (op->code) {
800  case RZ_IL_OP_VAR:
801  r->op.var.v = op->op.var.v;
802  r->op.var.kind = op->op.var.kind;
803  break;
804  case RZ_IL_OP_ITE:
805  DUP_OP3(ite, condition, x, y);
806  break;
807  case RZ_IL_OP_LET:
808  r->op.let.name = op->op.let.name;
809  DUP_OP2(let, exp, body);
810  break;
811  case RZ_IL_OP_B0:
812  break;
813  case RZ_IL_OP_B1:
814  break;
815  case RZ_IL_OP_INV:
816  DUP_OP1(boolinv, x);
817  break;
818  case RZ_IL_OP_AND:
819  DUP_OP2(booland, x, y);
820  break;
821  case RZ_IL_OP_OR:
822  DUP_OP2(boolor, x, y);
823  break;
824  case RZ_IL_OP_XOR:
825  DUP_OP2(boolxor, x, y);
826  break;
827  case RZ_IL_OP_BITV:
828  r->op.bitv.value = rz_bv_dup(op->op.bitv.value);
829  break;
830  case RZ_IL_OP_MSB:
831  DUP_OP1(msb, bv);
832  break;
833  case RZ_IL_OP_LSB:
834  DUP_OP1(lsb, bv);
835  break;
836  case RZ_IL_OP_IS_ZERO:
837  DUP_OP1(is_zero, bv);
838  break;
839  case RZ_IL_OP_NEG:
840  DUP_OP1(neg, bv);
841  break;
842  case RZ_IL_OP_LOGNOT:
843  DUP_OP1(lognot, bv);
844  break;
845  case RZ_IL_OP_ADD:
846  DUP_OP2(add, x, y);
847  break;
848  case RZ_IL_OP_SUB:
849  DUP_OP2(sub, x, y);
850  break;
851  case RZ_IL_OP_MUL:
852  DUP_OP2(mul, x, y);
853  break;
854  case RZ_IL_OP_DIV:
855  DUP_OP2(div, x, y);
856  break;
857  case RZ_IL_OP_SDIV:
858  DUP_OP2(sdiv, x, y);
859  break;
860  case RZ_IL_OP_MOD:
861  DUP_OP2(mod, x, y);
862  break;
863  case RZ_IL_OP_SMOD:
864  DUP_OP2(smod, x, y);
865  break;
866  case RZ_IL_OP_LOGAND:
867  DUP_OP2(logand, x, y);
868  break;
869  case RZ_IL_OP_LOGOR:
870  DUP_OP2(logor, x, y);
871  break;
872  case RZ_IL_OP_LOGXOR:
873  DUP_OP2(logxor, x, y);
874  break;
875  case RZ_IL_OP_SHIFTR:
876  DUP_OP3(shiftr, x, y, fill_bit);
877  break;
878  case RZ_IL_OP_SHIFTL:
879  DUP_OP3(shiftl, x, y, fill_bit);
880  break;
881  case RZ_IL_OP_EQ:
882  DUP_OP2(eq, x, y);
883  break;
884  case RZ_IL_OP_SLE:
885  DUP_OP2(sle, x, y);
886  break;
887  case RZ_IL_OP_ULE:
888  DUP_OP2(ule, x, y);
889  break;
890  case RZ_IL_OP_CAST:
891  r->op.cast.length = op->op.cast.length;
892  DUP_OP2(cast, fill, val);
893  break;
894  case RZ_IL_OP_APPEND:
895  DUP_OP2(append, high, low);
896  break;
897  case RZ_IL_OP_LOAD:
898  r->op.load.mem = op->op.load.mem;
899  DUP_OP1(load, key);
900  break;
901  case RZ_IL_OP_LOADW:
902  r->op.loadw.mem = op->op.loadw.mem;
903  r->op.loadw.n_bits = op->op.loadw.n_bits;
904  DUP_OP1(loadw, key);
905  break;
906  default:
908  break;
909  }
910 #undef DUP_OP
911 #undef DUP_OP2
912 #undef DUP_OP3
913  return r;
914 }
915 
916 #define rz_il_op_free_1(sort, s, v0) \
917  rz_il_op_##sort##_free(op->op.s.v0);
918 
919 #define rz_il_op_free_2(sort, s, v0, v1) \
920  rz_il_op_##sort##_free(op->op.s.v0); \
921  rz_il_op_##sort##_free(op->op.s.v1);
922 
923 #define rz_il_op_free_3(sort, s, v0, v1, v2) \
924  rz_il_op_##sort##_free(op->op.s.v0); \
925  rz_il_op_##sort##_free(op->op.s.v1); \
926  rz_il_op_##sort##_free(op->op.s.v2);
927 
929  if (!op) {
930  return;
931  }
932  switch (op->code) {
933  case RZ_IL_OP_VAR:
934  break;
935  case RZ_IL_OP_ITE:
936  rz_il_op_free_3(pure, ite, condition, x, y);
937  break;
938  case RZ_IL_OP_LET:
939  rz_il_op_free_2(pure, let, exp, body);
940  break;
941  case RZ_IL_OP_B0:
942  case RZ_IL_OP_B1:
943  break;
944  case RZ_IL_OP_INV:
945  rz_il_op_free_1(pure, boolinv, x);
946  break;
947  case RZ_IL_OP_AND:
948  case RZ_IL_OP_OR:
949  case RZ_IL_OP_XOR:
950  // BoolXor, BoolOr and BoolAnd shares the same struct
951  rz_il_op_free_2(pure, boolxor, x, y);
952  break;
953  case RZ_IL_OP_BITV:
954  rz_bv_free(op->op.bitv.value);
955  break;
956  case RZ_IL_OP_MSB:
957  rz_il_op_free_1(pure, msb, bv);
958  break;
959  case RZ_IL_OP_LSB:
960  rz_il_op_free_1(pure, lsb, bv);
961  break;
962  case RZ_IL_OP_IS_ZERO:
963  rz_il_op_free_1(pure, is_zero, bv);
964  break;
965  case RZ_IL_OP_NEG:
966  rz_il_op_free_1(pure, neg, bv);
967  break;
968  case RZ_IL_OP_LOGNOT:
969  rz_il_op_free_1(pure, lognot, bv);
970  break;
971  case RZ_IL_OP_ADD:
972  rz_il_op_free_2(pure, add, x, y);
973  break;
974  case RZ_IL_OP_SUB:
975  rz_il_op_free_2(pure, sub, x, y);
976  break;
977  case RZ_IL_OP_MUL:
978  rz_il_op_free_2(pure, mul, x, y);
979  break;
980  case RZ_IL_OP_DIV:
981  rz_il_op_free_2(pure, div, x, y);
982  break;
983  case RZ_IL_OP_SDIV:
984  rz_il_op_free_2(pure, sdiv, x, y);
985  break;
986  case RZ_IL_OP_MOD:
987  rz_il_op_free_2(pure, mod, x, y);
988  break;
989  case RZ_IL_OP_SMOD:
990  rz_il_op_free_2(pure, smod, x, y);
991  break;
992  case RZ_IL_OP_LOGAND:
993  rz_il_op_free_2(pure, logand, x, y);
994  break;
995  case RZ_IL_OP_LOGOR:
996  rz_il_op_free_2(pure, logor, x, y);
997  break;
998  case RZ_IL_OP_LOGXOR:
999  rz_il_op_free_2(pure, logxor, x, y);
1000  break;
1001  case RZ_IL_OP_SHIFTR:
1002  rz_il_op_free_3(pure, shiftr, fill_bit, x, y);
1003  break;
1004  case RZ_IL_OP_SHIFTL:
1005  rz_il_op_free_3(pure, shiftl, fill_bit, x, y);
1006  break;
1007  case RZ_IL_OP_EQ:
1008  rz_il_op_free_2(pure, eq, x, y);
1009  break;
1010  case RZ_IL_OP_SLE:
1011  rz_il_op_free_2(pure, sle, x, y);
1012  break;
1013  case RZ_IL_OP_ULE:
1014  rz_il_op_free_2(pure, ule, x, y);
1015  break;
1016  case RZ_IL_OP_CAST:
1017  rz_il_op_free_2(pure, cast, fill, val);
1018  break;
1019  case RZ_IL_OP_APPEND:
1020  rz_il_op_free_2(pure, append, high, low);
1021  break;
1022  case RZ_IL_OP_LOAD:
1023  rz_il_op_free_1(pure, load, key);
1024  break;
1025  case RZ_IL_OP_LOADW:
1026  rz_il_op_free_1(pure, loadw, key);
1027  break;
1028  default:
1030  RZ_LOG_ERROR("RzIL: unknown opcode %u\n", op->code);
1031  break;
1032  }
1033  free(op);
1034 }
1035 
1037  if (!op) {
1038  return;
1039  }
1040  switch (op->code) {
1041  case RZ_IL_OP_EMPTY:
1042  break;
1043  case RZ_IL_OP_STORE:
1044  rz_il_op_free_2(pure, store, key, value);
1045  break;
1046  case RZ_IL_OP_STOREW:
1047  rz_il_op_free_2(pure, storew, key, value);
1048  break;
1049  case RZ_IL_OP_NOP:
1050  break;
1051  case RZ_IL_OP_SET:
1052  rz_il_op_free_1(pure, set, x);
1053  break;
1054  case RZ_IL_OP_JMP:
1055  rz_il_op_free_1(pure, jmp, dst);
1056  break;
1057  case RZ_IL_OP_GOTO:
1058  break;
1059  case RZ_IL_OP_SEQ:
1060  rz_il_op_free_2(effect, seq, x, y);
1061  break;
1062  case RZ_IL_OP_BLK:
1063  rz_il_op_free_2(effect, blk, data_eff, ctrl_eff);
1064  break;
1065  case RZ_IL_OP_REPEAT:
1066  rz_il_op_pure_free(op->op.repeat.condition);
1067  rz_il_op_free_1(effect, repeat, data_eff);
1068  break;
1069  case RZ_IL_OP_BRANCH:
1070  rz_il_op_pure_free(op->op.repeat.condition);
1071  rz_il_op_free_2(effect, branch, true_eff, false_eff);
1072  break;
1073  default:
1075  RZ_LOG_ERROR("RzIL: unknown opcode %u\n", op->code);
1076  break;
1077  }
1078  free(op);
1079 }
1080 
1081 #undef rz_il_op_free_0
1082 #undef rz_il_op_free_1
1083 #undef rz_il_op_free_2
1084 #undef rz_il_op_free_3
#define jmp
lzma_index ** i
Definition: index.h:629
#define cast(x, y)
Definition: arch_53.h:166
static RzILOpEffect * sdiv(cs_insn *insn, bool is_thumb)
Definition: arm_il32.c:1911
static RzILOpEffect * mul(cs_insn *insn, bool is_thumb)
Definition: arm_il32.c:539
static ut32 neg(ArmOp *op)
Definition: armass64.c:981
ut16 val
Definition: armass64_const.h:6
static int value
Definition: cmd_api.c:93
#define append(x, y)
Definition: cmd_print.c:1740
#define RZ_API
#define NULL
Definition: cris-opc.c:27
#define r
Definition: crypto_rc6.c:12
int mod(int a, int b)
Definition: crypto_rot.c:8
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
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 static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
uint32_t ut32
const char * v
Definition: dsignal.c:12
int root
Definition: enough.c:226
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API RZ_OWN RzILOpPure * rz_il_op_new_loadw(RzILMemIndex mem, RZ_NONNULL RzILOpBitVector *key, ut32 n_bits)
Helper to create RzILOpArgsLoadW.
Definition: il_opcodes.c:738
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_blk(RZ_NONNULL const char *label, RZ_NONNULL RzILOpEffect *data_eff, RZ_NONNULL RzILOpEffect *ctrl_eff)
op structure for blk (label -> data eff -> ctrl eff -> unit eff)
Definition: il_opcodes.c:678
#define rz_il_op_free_1(sort, s, v0)
Definition: il_opcodes.c:916
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_shiftl(RZ_NONNULL RzILOpBool *fill_bit, RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for left shift (bool -> 's bitv -> 'b bitv -> 's bitv)
Definition: il_opcodes.c:517
#define rz_il_op_new_1(sort, id, t, s, v0)
Definition: il_opcodes.c:15
#define rz_il_op_new_3(sort, id, t, s, v0, v1, v2)
Definition: il_opcodes.c:36
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_log_xor(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: il_opcodes.c:505
RZ_API RZ_OWN RzILOpPure * rz_il_op_new_load(RzILMemIndex mem, RZ_NONNULL RzILOpPure *key)
Helper to create RzILOpArgsLoad.
Definition: il_opcodes.c:718
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_log_and(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: il_opcodes.c:481
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_branch(RZ_NONNULL RzILOpBool *condition, RZ_NULLABLE RzILOpEffect *true_eff, RZ_NULLABLE RzILOpEffect *false_eff)
op structure for branch (bool -> 'a eff -> 'a eff -> 'a eff)
Definition: il_opcodes.c:702
RZ_API RZ_OWN RzILOpPure * rz_il_op_new_let(RZ_NONNULL const char *name, RZ_NONNULL RzILOpPure *exp, RZ_NONNULL RzILOpPure *body)
Definition: il_opcodes.c:75
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_repeat(RZ_NONNULL RzILOpBool *condition, RZ_NONNULL RzILOpEffect *data_eff)
op structure for repeat (bool -> data eff -> data eff)
Definition: il_opcodes.c:690
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_empty()
oop structure for an empty effect (val empty : 'a sort -> 'a t)
Definition: il_opcodes.c:560
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_ult(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y)
Definition: il_opcodes.c:285
#define DUP_OP2(arg, m0, m1)
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_b1()
op structure for bool true
Definition: il_opcodes.c:94
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_sub(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: il_opcodes.c:409
RZ_API RZ_OWN RzILOpPure * rz_il_op_new_ite(RZ_NONNULL RzILOpPure *condition, RZ_NULLABLE RzILOpPure *x, RZ_NULLABLE RzILOpPure *y)
op structure for ite (bool -> 'a pure -> 'a pure -> 'a pure)
Definition: il_opcodes.c:53
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_uge(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y)
Definition: il_opcodes.c:305
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_eq(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
Definition: il_opcodes.c:251
RZ_API void rz_il_op_pure_free(RZ_NULLABLE RzILOpPure *op)
Definition: il_opcodes.c:928
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_ugt(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y)
Definition: il_opcodes.c:325
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_mul(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: il_opcodes.c:421
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_shiftr(RZ_NONNULL RzILOpBool *fill_bit, RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for right shift (bool -> 's bitv -> 'b bitv -> 's bitv)
Definition: il_opcodes.c:529
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_append(RZ_NONNULL RzILOpBitVector *high, RZ_NONNULL RzILOpBitVector *low)
op structure for appending 2 bitv: MSB:LSB high:low
Definition: il_opcodes.c:547
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_jmp(RZ_NONNULL RzILOpBitVector *dst)
op structure for jmp (_ bitv -> ctrl eff)
Definition: il_opcodes.c:589
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_is_zero(RZ_NONNULL RzILOpPure *bv)
Definition: il_opcodes.c:233
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_smod(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: il_opcodes.c:457
#define rz_il_op_free_2(sort, s, v0, v1)
Definition: il_opcodes.c:919
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_bool_xor(RZ_NONNULL RzILOpBool *x, RZ_NONNULL RzILOpBool *y)
op structure for xor (bool -> bool -> bool)
Definition: il_opcodes.c:135
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_signed(ut32 length, RZ_NONNULL RzILOpBitVector *val)
Extend val to length bits, filling up with val's most significant bit.
Definition: il_opcodes.c:363
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_set(RZ_NONNULL const char *v, bool is_local, RZ_NONNULL RzILOpPure *x)
op structure for set ('a var -> 'a pure -> data eff)
Definition: il_opcodes.c:577
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_bool_and(RZ_NONNULL RzILOpBool *x, RZ_NONNULL RzILOpBool *y)
op structure for and (bool -> bool -> bool)
Definition: il_opcodes.c:107
RZ_API void rz_il_op_effect_free(RZ_NULLABLE RzILOpEffect *op)
Definition: il_opcodes.c:1036
#define DUP_OP1(arg, m0)
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_log_or(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: il_opcodes.c:493
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_bool_or(RZ_NONNULL RzILOpBool *x, RZ_NONNULL RzILOpBool *y)
op structure for or (bool -> bool -> bool)
Definition: il_opcodes.c:121
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_bitv_from_st64(ut32 length, st64 number)
op structure for bitvector converted from st64
Definition: il_opcodes.c:193
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_ule(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for sle/ule ('a bitv -> 'a bitv -> bool)
Definition: il_opcodes.c:263
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_sdiv(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: il_opcodes.c:445
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_neg(RZ_NONNULL RzILOpBitVector *bv)
op structure for neg ('s bitv -> 's bitv)
Definition: il_opcodes.c:373
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_store(RzILMemIndex mem, RZ_NONNULL RzILOpBitVector *key, RZ_NONNULL RzILOpBitVector *value)
Helper to create RzILOpArgsStoreW.
Definition: il_opcodes.c:728
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_mod(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: il_opcodes.c:469
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_bool_inv(RZ_NONNULL RzILOpBool *x)
op structure for inv (!bool -> bool)
Definition: il_opcodes.c:149
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_lsb(RZ_NONNULL RzILOpBitVector *bv)
op structure for lsb ('s bitv -> bool) [LSB] lsb x is the least significant bit of x.
Definition: il_opcodes.c:223
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_log_not(RZ_NONNULL RzILOpBitVector *bv)
op structure for not ('s bitv -> 's bitv)
Definition: il_opcodes.c:385
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_goto(RZ_NONNULL const char *lbl)
op structure for goto (label -> ctrl eff)
Definition: il_opcodes.c:601
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_cast(ut32 length, RZ_NONNULL RzILOpBool *fill, RZ_NONNULL RzILOpBitVector *val)
op structure for casting bitv
Definition: il_opcodes.c:341
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_seqn(ut32 n,...)
Definition: il_opcodes.c:632
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_bitv(RZ_NONNULL RzBitVector *value)
op structure for bitvector
Definition: il_opcodes.c:161
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_bitv_from_ut64(ut32 length, ut64 number)
op structure for bitvector converted from ut64
Definition: il_opcodes.c:173
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_msb(RZ_NONNULL RzILOpBitVector *bv)
op structure for msb ('s bitv -> bool) [MSB] msb x is the most significant bit of x.
Definition: il_opcodes.c:212
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_non_zero(RZ_NONNULL RzILOpPure *bv)
Definition: il_opcodes.c:243
#define DUP_OP3(arg, m0, m1, m2)
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_b0()
op structure for bool false
Definition: il_opcodes.c:85
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_slt(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y)
Definition: il_opcodes.c:295
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_unsigned(ut32 length, RZ_NONNULL RzILOpBitVector *val)
Extend val to length bits, filling up with zeroes.
Definition: il_opcodes.c:353
#define rz_il_op_free_3(sort, s, v0, v1, v2)
Definition: il_opcodes.c:923
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_sgt(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y)
Definition: il_opcodes.c:333
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_div(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: il_opcodes.c:433
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_storew(RzILMemIndex mem, RZ_NONNULL RzILOpBitVector *key, RZ_NONNULL RzILOpBitVector *value)
Helper to create RzILOpArgsStoreW.
Definition: il_opcodes.c:748
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_shiftr_arith(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
alias for shiftr (msb x) x d, right-shift filling up with the left operand's msb
Definition: il_opcodes.c:539
RZ_API RZ_OWN RzILOpBitVector * rz_il_op_new_add(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: il_opcodes.c:397
#define rz_il_op_new_2(sort, id, t, s, v0, v1)
Definition: il_opcodes.c:25
#define rz_il_op_new_0(sort, id)
Definition: il_opcodes.c:6
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_sge(RZ_NONNULL RzILOpPure *x, RZ_NONNULL RzILOpPure *y)
Definition: il_opcodes.c:315
RZ_API RZ_OWN RzILOpPure * rz_il_op_new_var(RZ_NONNULL const char *v, RzILVarKind kind)
op structure for var ('a var -> 'a pure)
Definition: il_opcodes.c:65
RZ_API RZ_OWN RzILOpBool * rz_il_op_new_sle(RZ_NONNULL RzILOpBitVector *x, RZ_NONNULL RzILOpBitVector *y)
op structure for sle/ule ('a bitv -> 'a bitv -> bool)
Definition: il_opcodes.c:275
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_seq(RZ_NONNULL RzILOpEffect *x, RZ_NONNULL RzILOpEffect *y)
op structure for Seq ('a eff -> 'a eff -> 'a eff)
Definition: il_opcodes.c:613
RZ_API RzILOpPure * rz_il_op_pure_dup(RZ_NONNULL RzILOpPure *op)
Definition: il_opcodes.c:763
RZ_API RZ_OWN RzILOpEffect * rz_il_op_new_nop()
Definition: il_opcodes.c:566
void * mem
Definition: libc.cpp:91
char * dst
Definition: lz4.h:724
ut32 RzILMemIndex
Definition: mem.h:14
int args
Definition: mipsasm.c:18
int x
Definition: mipsasm.c:20
int n
Definition: mipsasm.c:19
void * load(const char *name, size_t *len)
Definition: pufftest.c:60
static void repeat(struct parse *, sopno, int, int)
Definition: regcomp.c:1155
#define rz_warn_if_reached()
Definition: rz_assert.h:29
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API RZ_OWN RzBitVector * rz_bv_dup(const RZ_NONNULL RzBitVector *bv)
Definition: bitvector.c:167
RZ_API void rz_bv_free(RZ_NULLABLE RzBitVector *bv)
Definition: bitvector.c:85
RZ_API RZ_OWN RzBitVector * rz_bv_new_from_st64(ut32 length, st64 value)
Definition: bitvector.c:1179
RZ_API RZ_OWN RzBitVector * rz_bv_new_from_ut64(ut32 length, ut64 value)
Definition: bitvector.c:1161
signatures of core theory opcodes
@ RZ_IL_OP_SHIFTR
@ RZ_IL_OP_ULE
@ RZ_IL_OP_SUB
@ RZ_IL_OP_LOGNOT
@ RZ_IL_OP_MSB
@ RZ_IL_OP_ITE
@ RZ_IL_OP_SLE
@ RZ_IL_OP_LSB
@ RZ_IL_OP_OR
@ RZ_IL_OP_IS_ZERO
@ RZ_IL_OP_NEG
@ RZ_IL_OP_ADD
@ RZ_IL_OP_B0
@ RZ_IL_OP_LET
@ RZ_IL_OP_CAST
@ RZ_IL_OP_MOD
@ RZ_IL_OP_LOGOR
@ RZ_IL_OP_VAR
@ RZ_IL_OP_INV
@ RZ_IL_OP_APPEND
@ RZ_IL_OP_DIV
@ RZ_IL_OP_SHIFTL
@ RZ_IL_OP_EQ
@ RZ_IL_OP_MUL
@ RZ_IL_OP_BITV
@ RZ_IL_OP_B1
@ RZ_IL_OP_XOR
@ RZ_IL_OP_LOAD
@ RZ_IL_OP_AND
@ RZ_IL_OP_SMOD
@ RZ_IL_OP_LOGXOR
@ RZ_IL_OP_SDIV
@ RZ_IL_OP_LOADW
@ RZ_IL_OP_LOGAND
@ RZ_IL_OP_BLK
@ RZ_IL_OP_GOTO
@ RZ_IL_OP_SEQ
@ RZ_IL_OP_NOP
@ RZ_IL_OP_JMP
@ RZ_IL_OP_EMPTY
@ RZ_IL_OP_STORE
@ RZ_IL_OP_STOREW
@ RZ_IL_OP_REPEAT
@ RZ_IL_OP_BRANCH
@ RZ_IL_OP_SET
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
#define RZ_NULLABLE
Definition: rz_types.h:65
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_NONNULL
Definition: rz_types.h:64
#define st64
Definition: rz_types_base.h:10
structure for bitvector
Definition: rz_bitvector.h:19
Definition: dis.h:35
Definition: z80asm.h:102
op structure for two-operand algorithm and logical operations ('s bitv -> 's bitv -> 's bitv)
Definition: rz_il_opcodes.h:97
op structure for appending 2 bitv: MSB:LSB high:low
op structure for inv (!bool -> bool)
op structure for and, or and xor (bool -> bool -> bool)
op structure for branch (bool -> 'a eff -> 'a eff -> 'a eff)
value is a bitvector constant.
Definition: rz_il_opcodes.h:51
RzBitVector * value
value of bitvector
Definition: rz_il_opcodes.h:52
op structure for casting bitv
op structure for binary comparison ops ('a bitv -> 'a bitv -> bool)
op structure for goto (label -> ctrl eff)
op structure for ite (bool -> 'a pure -> 'a pure -> 'a pure)
op structure for jmp (_ bitv -> ctrl eff)
op structure for let_ : 'a var -> 'a pure -> 'b pure -> 'b pure
op structure for load (('a, 'b) mem -> 'a bitv -> 'b bitv)
Load an entire word of arbitrary bit size from a memory.
op structure for Seq ('a eff -> 'a eff -> 'a eff)
RzILOpEffect * y
perform this second
RzILOpEffect * x
perform this first
op structure for set ('a var -> 'a pure -> data eff)
op structure for lshift and rshift (bool -> 's bitv -> 'b bitv -> 's bitv)
op structure for store (('a, 'b) mem -> 'a bitv -> 'b bitv -> ('a, 'b) mem)
Store an entire word of arbitrary bit size into a memory.
op structure for 's bitv -> bool [MSB] msb x is the most significant bit of x. [LSB] lsb x is the lea...
Definition: rz_il_opcodes.h:61
op structure for var ('a var -> 'a pure)
RzILOpEffectCode code
RzILOpArgsSeq seq
union rz_il_op_effect_t::@287 op
An IL op performing a pure computation, 'a pure.
union rz_il_op_pure_t::@286 op
RzILOpPureCode code
RzILOpArgsBv bitv
op structure for blk (label -> data eff -> ctrl eff -> unit eff)
op structure for repeat (bool -> data eff -> data eff)
Definition: dis.c:32
struct op_code code
Definition: dis.c:33
RzILVarKind
Definition: variable.h:46
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int add(char *argv[])
Definition: ziptool.c:84