Rizin
unix-like reverse engineering framework and cli tools
opcode_27.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2020 FXTi <zjxiang1998@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include "opcode.h"
5 
7  pyc_opcodes *ret = opcode_26();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_27;
13 
14  // Below are opcode changes since Python 2.6
15  rm_op(.op_obj = ret->opcodes, .op_name = "BUILD_MAP", .op_code = 104);
16  rm_op(.op_obj = ret->opcodes, .op_name = "LOAD_ATTR", .op_code = 105);
17  rm_op(.op_obj = ret->opcodes, .op_name = "COMPARE_OP", .op_code = 106);
18  rm_op(.op_obj = ret->opcodes, .op_name = "IMPORT_NAME", .op_code = 107);
19  rm_op(.op_obj = ret->opcodes, .op_name = "IMPORT_FROM", .op_code = 108);
20  rm_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_FALSE", .op_code = 111);
21  rm_op(.op_obj = ret->opcodes, .op_name = "EXTENDED_ARG", .op_code = 143);
22  rm_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_TRUE", .op_code = 112);
23 
24  def_op(.op_obj = ret->opcodes, .op_name = "LIST_APPEND", .op_code = 94, .pop = 2, .push = 1); // Calls list.append(TOS[-i], TOS).
25  // Used to implement list comprehensions.
26  def_op(.op_obj = ret->opcodes, .op_name = "BUILD_SET", .op_code = 104); // Number of set items
27  def_op(.op_obj = ret->opcodes, .op_name = "BUILD_MAP", .op_code = 105);
28  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_ATTR", .op_code = 106);
29  compare_op(.op_obj = ret->opcodes, .op_name = "COMPARE_OP", .op_code = 107);
30 
31  name_op(.op_obj = ret->opcodes, .op_name = "IMPORT_NAME", .op_code = 108, .pop = 2, .push = 1); // Index in name list
32  name_op(.op_obj = ret->opcodes, .op_name = "IMPORT_FROM", .op_code = 109, .pop = 0, .push = 1);
33 
34  jabs_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_FALSE_OR_POP", .op_code = 111, .conditional = true); // Target byte offset from beginning of code
35  jabs_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_TRUE_OR_POP", .op_code = 112, .conditional = true); // ""
36  jabs_op(.op_obj = ret->opcodes, .op_name = "POP_JUMP_IF_FALSE", .op_code = 114, .conditional = true); // ""
37  jabs_op(.op_obj = ret->opcodes, .op_name = "POP_JUMP_IF_TRUE", .op_code = 115, .conditional = true); // ""
38  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_WITH", .op_code = 143, .pop = 0, .push = 2);
39 
40  def_op(.op_obj = ret->opcodes, .op_name = "EXTENDED_ARG", .op_code = 145);
41  def_op(.op_obj = ret->opcodes, .op_name = "SET_ADD", .op_code = 146, .pop = 1, .push = 0); // Calls set.add(TOS1[-i], TOS).
42  // Used to implement set comprehensions.
43  def_op(.op_obj = ret->opcodes, .op_name = "MAP_ADD", .op_code = 147, .pop = 2, .push = 1); // Calls dict.setitem(TOS1[-i], TOS, TOS1)
44  // Used to implement dict comprehensions.
45 
47  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
49 
50  return ret;
51 }
#define NULL
Definition: cris-opc.c:27
RZ_API void rz_list_purge(RZ_NONNULL RzList *list)
Empties the list without freeing the list pointer.
Definition: list.c:120
void add_arg_fmt(pyc_opcodes *ret, char *op_name, const char *(*formatter)(ut32 oparg))
Definition: opcode.c:234
pyc_opcodes * opcode_27(void)
Definition: opcode_27.c:6
const char * format_extended_arg(ut32 oparg)
Definition: opcode_arg_fmt.c:6
#define jabs_op(...)
Definition: opcode.h:163
pyc_opcodes * opcode_26(void)
Definition: opcode_26.c:6
#define compare_op(...)
Definition: opcode.h:158
#define jrel_op(...)
Definition: opcode.h:168
#define def_op(...)
Definition: opcode.h:127
#define rm_op(...)
Definition: opcode.h:175
const char * format_CALL_FUNCTION_pos_name_encoded(ut32 oparg)
#define name_op(...)
Definition: opcode.h:133
char * op_name
Definition: opcode.h:38
void *(* version_sig)()
Definition: opcode.h:49
pyc_opcode_object * opcodes
Definition: opcode.h:51
RzList * opcode_arg_fmt
Definition: opcode.h:50