Skip to content

Commit efeea7d

Browse files
authored
Backport patches from r2dec and fix bug when calling pddi (#61)
1 parent ccbbd07 commit efeea7d

File tree

10 files changed

+106
-55455
lines changed

10 files changed

+106
-55455
lines changed

c/jsdec.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ jsdec_t *jsdec_new() {
199199
JS_AddIntrinsicTypedArrays(ctx);
200200
JS_AddIntrinsicPromise(ctx);
201201
JS_AddIntrinsicBigInt(ctx);
202+
JS_AddIntrinsicDate(ctx);
202203

203204

204205
// Setup global objects.

js/libdec/arch/arm.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,11 @@ var _arm = {
917917
cmp: _compare,
918918
cmn: _compare,
919919
fcmp: _compare,
920+
ccmp: function(instr, context) {
921+
context.cond.a = instr.parsed.opd[0];
922+
context.cond.b = instr.parsed.opd[1];
923+
return _conditional(instr, context, instr.parsed.opd[3].toUpperCase());
924+
},
920925
cbz: function(instr, context, instructions) {
921926
context.cond.a = instr.parsed.opd[0];
922927
context.cond.b = '0';
@@ -1356,6 +1361,17 @@ var _arm = {
13561361
}
13571362
return Base.conditional_assign(opds[0], context.cond.a, context.cond.b, cond, '1', '0');
13581363
},
1364+
cneg: function(instr, context) {
1365+
var opds = instr.parsed.opd;
1366+
var cond = 'EQ';
1367+
for (var i = 0; i < _conditional_list.length; i++) {
1368+
if (_conditional_list[i].ext == opds[1]) {
1369+
cond = _conditional_list[i].type;
1370+
break;
1371+
}
1372+
}
1373+
return Base.conditional_assign(opds[0], context.cond.a, context.cond.b, cond, '-' + opds[1], opds[0]);
1374+
},
13591375
fcset: function(instr, context) {
13601376
var opds = instr.parsed.opd;
13611377
var cond = 'EQ';

js/libdec/rzutil.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default (function() {
7979
var functions = rz_sanitize(rzpipe.string('aflj'), '[]');
8080
var classes = rz_sanitize(rzpipe.string('icj'), '[]');
8181
var data = JSONex.stringify(rizin.graph());
82-
var farguments = rz_sanitize(rzpipe.string('afvj', true), '{"sp":[],"bp":[],"reg":[]}');
82+
var farguments = rz_sanitize(rzpipe.string('afvlj', true), '{"stack":[],"reg":[]}');
8383
var arch = rz_sanitize(rzpipe.string('e asm.arch'), '');
8484
var archbits = rz_sanitize(rzpipe.string('e asm.bits'), '32');
8585
var database = rz_sanitize(rzpipe.custom('afsj @@i', null, merge_arrays), '[]');
@@ -216,11 +216,13 @@ export default (function() {
216216
strings: (isfast ? [] : rzpipe.json('Cslj', [])),
217217
functions: (isfast ? [] : rzpipe.json('aflj', [])),
218218
classes: rzpipe.json('icj', []),
219-
arguments: rzpipe.json('afvj', {
219+
arguments: rzpipe.json('afvlj', {
220220
"stack": [],
221221
"reg": []
222222
})
223223
};
224+
this.xrefs.arguments.stack = this.xrefs.arguments.stack || [];
225+
this.xrefs.arguments.reg = this.xrefs.arguments.reg || [];
224226
this.graph = rizin.graph();
225227
this.argdb = rzpipe.custom('afsj @@i', null, merge_arrays_json);
226228
},

js/libdec/testsuite.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function _new_data(issue) {
5252
// to override this is required to be converted to just an integer.
5353
bits = parseInt(bits.toString());
5454
}
55-
return {
55+
var testdata = {
5656
arch: issue.arch,
5757
bits: bits,
5858
graph: issue.agj ? _fixup_old_graph(issue.agj) : (issue.graph || []),
@@ -68,6 +68,9 @@ function _new_data(issue) {
6868
},
6969
argdb: issue.afcfj
7070
};
71+
testdata.xrefs.arguments.stack = testdata.xrefs.arguments.stack || [];
72+
testdata.xrefs.arguments.reg = testdata.xrefs.arguments.reg || [];
73+
return testdata;
7174
}
7275

7376
export default function(filename) {

meson.build

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,17 @@ project('jsdec', 'c', meson_version: '>=0.56.0',
1111

1212
cc = meson.get_compiler('c')
1313

14-
libquickjs_proj = subproject('libquickjs', default_options: ['default_library=static'])
15-
libquickjs_dep = libquickjs_proj.get_variable('quickjs_dep')
16-
qjsc = libquickjs_proj.get_variable('qjsc')
17-
1814
jsdec_incs = ['.', 'c']
1915
jsdec_c_args = []
2016
jsdec_src = [
2117
'c' / 'jsdec.c',
2218
'c' / 'base64.c',
2319
]
24-
jsdec_deps = [
25-
libquickjs_dep.as_link_whole(),
26-
]
20+
21+
libquickjs_proj = subproject('libquickjs', default_options: ['default_library=static'])
22+
libquickjs_dep = libquickjs_proj.get_variable('quickjs_dep')
23+
24+
jsdec_deps = [ libquickjs_dep ]
2725

2826
modjs_gen = executable('modjs_gen', 'tools' / 'modjs_gen.c',
2927
dependencies: [],
@@ -32,8 +30,25 @@ modjs_gen = executable('modjs_gen', 'tools' / 'modjs_gen.c',
3230
install: false,
3331
)
3432

33+
qjsc = executable('qjsc', 'tools' / 'qjsc_mod.c',
34+
dependencies: libquickjs_dep,
35+
c_args: ['-D_GNU_SOURCE=1'],
36+
include_directories: [],
37+
implicit_include_directories: false,
38+
install: false,
39+
)
40+
3541
subdir('js')
3642

43+
jsdec_link_args = []
44+
foreach flag: [
45+
'-Wl,--exclude-libs,ALL',
46+
]
47+
if cc.has_link_argument(flag)
48+
jsdec_link_args += flag
49+
endif
50+
endforeach
51+
3752
build_type = get_option('build_type')
3853
if build_type == 'standalone'
3954
jsdec_src += [
@@ -45,6 +60,8 @@ if build_type == 'standalone'
4560
jsdec_standalone = executable('jsdec-standalone', jsdec_src,
4661
c_args : jsdec_c_args,
4762
dependencies: jsdec_deps,
63+
link_args: jsdec_link_args,
64+
gnu_symbol_visibility: 'hidden',
4865
include_directories: include_directories(jsdec_incs),
4966
implicit_include_directories: false,
5067
install: false,
@@ -66,6 +83,8 @@ elif build_type == 'cutter'
6683
c_args : jsdec_c_args,
6784
dependencies: jsdec_deps,
6885
include_directories: include_directories(jsdec_incs),
86+
link_args: jsdec_link_args,
87+
gnu_symbol_visibility: 'hidden',
6988
implicit_include_directories: false,
7089
install: false,
7190
)
@@ -103,6 +122,8 @@ elif build_type == 'rizin'
103122
c_args : jsdec_c_args,
104123
dependencies: jsdec_deps,
105124
include_directories: include_directories(jsdec_incs),
125+
link_args: jsdec_link_args,
126+
gnu_symbol_visibility: 'hidden',
106127
implicit_include_directories: false,
107128
install: true,
108129
install_dir: rizin_plugdir

subprojects/libquickjs.wrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[wrap-git]
22
url = https://github.com/quickjs-ng/quickjs.git
3-
revision = v0.6.1
3+
revision = v0.8.0
44
directory = libquickjs
55
patch_directory = libquickjs
66
depth = 1
Lines changed: 34 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project('quickjs-ng', 'c',
2-
version: 'v0.6.1',
2+
version: 'v0.8.0',
33
default_options: [
44
'buildtype=release',
55
'b_vscrt=from_buildtype',
@@ -11,13 +11,10 @@ project('quickjs-ng', 'c',
1111
cc = meson.get_compiler('c')
1212

1313
threads_dep = dependency('threads')
14+
atomic_dep = cc.find_library('atomic', required: false)
1415
dl_dep = cc.find_library('dl', required: false)
1516
m_dep = cc.find_library('m', required: false)
1617

17-
headers = [
18-
'quickjs.h',
19-
]
20-
2118
sources = [
2219
'cutils.c',
2320
'libbf.c',
@@ -28,6 +25,7 @@ sources = [
2825

2926
compiler_flags = [
3027
'-fvisibility=hidden',
28+
'-fvisibility-inlines-hidden',
3129
'-Wno-implicit-fallthrough',
3230
'-Wno-sign-compare',
3331
'-Wno-missing-field-initializers',
@@ -40,59 +38,51 @@ compiler_flags = [
4038
]
4139

4240
if cc.get_id() == 'msvc'
43-
compiler_flags += '-Wno-unsafe-buffer-usage'
44-
compiler_flags += '-Wno-sign-conversion'
45-
compiler_flags += '-Wno-nonportable-system-include-path'
46-
compiler_flags += '-Wno-implicit-int-conversion'
47-
compiler_flags += '-Wno-shorten-64-to-32'
48-
compiler_flags += '-Wno-reserved-macro-identifier'
49-
compiler_flags += '-Wno-reserved-identifier'
50-
compiler_flags += '-Wdeprecated-declarations'
51-
compiler_flags += '/experimental:c11atomics'
52-
compiler_flags += '/wd4018' # -Wno-sign-conversion
53-
compiler_flags += '/wd4061' # -Wno-implicit-fallthrough
54-
compiler_flags += '/wd4100' # -Wno-unused-parameter
55-
compiler_flags += '/wd4200' # -Wno-zero-length-array
56-
compiler_flags += '/wd4242' # -Wno-shorten-64-to-32
57-
compiler_flags += '/wd4244' # -Wno-shorten-64-to-32
58-
compiler_flags += '/wd4245' # -Wno-sign-compare
59-
compiler_flags += '/wd4267' # -Wno-shorten-64-to-32
60-
compiler_flags += '/wd4388' # -Wno-sign-compare
61-
compiler_flags += '/wd4389' # -Wno-sign-compare
62-
compiler_flags += '/wd4710' # Function not inlined
63-
compiler_flags += '/wd4711' # Function was inlined
64-
compiler_flags += '/wd4820' # Padding added after construct
65-
compiler_flags += '/wd4996' # -Wdeprecated-declarations
66-
compiler_flags += '/wd5045' # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
41+
compiler_flags += '-Wno-unsafe-buffer-usage'
42+
compiler_flags += '-Wno-sign-conversion'
43+
compiler_flags += '-Wno-nonportable-system-include-path'
44+
compiler_flags += '-Wno-implicit-int-conversion'
45+
compiler_flags += '-Wno-shorten-64-to-32'
46+
compiler_flags += '-Wno-reserved-macro-identifier'
47+
compiler_flags += '-Wno-reserved-identifier'
48+
compiler_flags += '-Wdeprecated-declarations'
49+
compiler_flags += '/experimental:c11atomics'
50+
compiler_flags += '/wd4018' # -Wno-sign-conversion
51+
compiler_flags += '/wd4061' # -Wno-implicit-fallthrough
52+
compiler_flags += '/wd4100' # -Wno-unused-parameter
53+
compiler_flags += '/wd4200' # -Wno-zero-length-array
54+
compiler_flags += '/wd4242' # -Wno-shorten-64-to-32
55+
compiler_flags += '/wd4244' # -Wno-shorten-64-to-32
56+
compiler_flags += '/wd4245' # -Wno-sign-compare
57+
compiler_flags += '/wd4267' # -Wno-shorten-64-to-32
58+
compiler_flags += '/wd4388' # -Wno-sign-compare
59+
compiler_flags += '/wd4389' # -Wno-sign-compare
60+
compiler_flags += '/wd4710' # Function not inlined
61+
compiler_flags += '/wd4711' # Function was inlined
62+
compiler_flags += '/wd4820' # Padding added after construct
63+
compiler_flags += '/wd4996' # -Wdeprecated-declarations
64+
compiler_flags += '/wd5045' # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
6765
endif
6866

6967
# required on linux, but ignored by windows
70-
add_project_arguments('-D_GNU_SOURCE=1', language: 'c')
68+
quickjs_c_args = ['-D_GNU_SOURCE=1']
7169

7270
foreach flag: compiler_flags
7371
if cc.has_argument(flag)
74-
add_project_arguments(flag, language: 'c')
72+
quickjs_c_args += flag
7573
endif
7674
endforeach
7775

7876
quickjs = static_library('quickjs', sources,
79-
dependencies: [threads_dep, dl_dep, m_dep],
77+
dependencies: [atomic_dep, threads_dep, dl_dep, m_dep],
78+
c_args: quickjs_c_args,
79+
pic: true,
80+
gnu_symbol_visibility: 'hidden',
8081
implicit_include_directories: false,
81-
install: false,
82+
install: false
8283
)
8384

8485
quickjs_dep = declare_dependency(
8586
link_with: quickjs,
8687
include_directories: include_directories('.'),
8788
)
88-
89-
qjsc_sources = [
90-
'qjsc.c',
91-
]
92-
93-
qjsc = executable('qjsc', qjsc_sources,
94-
dependencies: quickjs_dep,
95-
include_directories: include_directories('.'),
96-
implicit_include_directories: false,
97-
install: false,
98-
)

0 commit comments

Comments
 (0)