Skip to content

Commit 0574929

Browse files
committed
Remove globals from RBin.PYC
1 parent 0f59321 commit 0574929

File tree

8 files changed

+226
-184
lines changed

8 files changed

+226
-184
lines changed

libr/arch/p/pyc/plugin.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,27 @@ static pyc_opcodes *get_pyc_opcodes(RArchSession *s) {
3737
return ops;
3838
}
3939

40-
static RList *get_pyc_code_obj(RArchSession *as) {
40+
#if 0
41+
struct pyc_version {
42+
ut32 magic;
43+
const char *version;
44+
const char *revision;
45+
};
46+
typedef struct {
47+
ut64 code_start_offset;
48+
struct pyc_version version;
49+
RList *sections_cache; // RList<RBinSection*>
50+
RList *interned_table; // RList<char*>
51+
RList *cobjs; // RList<pyc_code_object*>
52+
} RBinPycObj;
53+
#endif
54+
55+
static inline RList *get_pyc_code_obj(RArchSession *as) {
4156
RBin *b = as->arch->binb.bin;
42-
RBinPlugin *plugin = b->cur && b->cur->bo? b->cur->bo->plugin: NULL;
43-
bool is_pyc = (plugin && strcmp (plugin->meta.name, "pyc") == 0);
44-
return is_pyc? b->cur->bo->bin_obj: NULL;
57+
RBinPlugin *plugin = R_UNWRAP4 (b, cur, bo, plugin);
58+
const bool is_pyc = (plugin && !strcmp (plugin->meta.name, "pyc"));
59+
RBinPycObj *pyc = is_pyc? b->cur->bo->bin_obj: NULL;
60+
return pyc? pyc->cobjs: NULL;
4561
}
4662

4763
static inline pyc_code_object *get_func(ut64 pc, RList *pyobj) {

libr/arch/p/pyc/pyc_dis.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66
#include <r_util.h>
77
#include <r_asm.h>
88

9+
#if 0
10+
#include "../../bin/format/pyc/pyc_magic.h"
11+
#else
12+
struct pyc_version {
13+
ut32 magic;
14+
const char *version;
15+
const char *revision;
16+
};
17+
18+
typedef struct {
19+
ut64 code_start_offset;
20+
struct pyc_version version;
21+
RList *sections_cache; // RList<RBinSection*>
22+
RList *interned_table; // RList<char*>
23+
RList *cobjs; // RList<pyc_code_object*>
24+
} RBinPycObj;
25+
#endif
26+
927
#include "opcode.h"
1028

1129
typedef struct {

0 commit comments

Comments
 (0)