mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-15 19:58:31 +00:00
Fix wasm function offset lookup ##bin
This commit is contained in:
parent
b2567a8eec
commit
d100777d4c
@ -347,12 +347,13 @@ static RBuffer *create(RBin *bin, const ut8 *code, int codelen, const ut8 *data,
|
||||
return buf;
|
||||
}
|
||||
|
||||
static int get_fcn_offset_from_id(RBinFile *bf, int fcn_idx) {
|
||||
// XXX shouldn't the number of functions in imports be considered?
|
||||
static int get_fcn_offset_from_id(RBinFile *bf, int ordinal) {
|
||||
RBinWasmObj *bin = bf->o->bin_obj;
|
||||
ut32 min = first_ord_not_import (bin, R_BIN_WASM_EXTERNALKIND_Function);
|
||||
RPVector *codes = r_bin_wasm_get_codes (bin);
|
||||
if (codes) {
|
||||
RBinWasmCodeEntry *func = vector_at (codes, fcn_idx);
|
||||
if (min <= ordinal && codes) {
|
||||
ordinal -= min;
|
||||
RBinWasmCodeEntry *func = vector_at (codes, ordinal);
|
||||
if (func) {
|
||||
return func->code;
|
||||
}
|
||||
|
@ -88,26 +88,25 @@ FILE=bins/wasm/sections.wasm
|
||||
CMDS=aa;afl
|
||||
EXPECT=<<EOF
|
||||
0x00000207 1 3 entry0
|
||||
0x0000053d 1 4 sym.__errno_location
|
||||
0x0000023d 3 209 sym.main
|
||||
0x00000415 6 148 sym.__main_void
|
||||
0x000004ab 1 3 sym.__original_main
|
||||
0x000004df 1 12 sym.exit
|
||||
0x000004f5 1 3 sym.stackSave
|
||||
0x000004fa 1 5 sym.stackRestore
|
||||
0x00000516 1 19 sym.emscripten_stack_init
|
||||
0x0000023d 3 209 sym.main
|
||||
0x0000032d 1 126 sym.atoi_via_import
|
||||
0x000003b9 1 54 sym.static_int_sum
|
||||
0x000003f3 3 14 fcn.000003f3
|
||||
0x000003f1 1 2 sym._start
|
||||
0x000004ed 1 6 sym._Exit
|
||||
0x00000505 1 15 sym.stackAlloc
|
||||
0x00000403 1 7 sym.main_2e_1
|
||||
0x000004ab 1 3 sym.__original_main
|
||||
0x00000415 6 148 sym.__main_void
|
||||
0x000004df 1 12 sym.exit
|
||||
0x000004b0 1 1 sym.dummy
|
||||
0x000004b5 3 40 sym.libc_exit_fini
|
||||
0x000004ed 1 6 sym._Exit
|
||||
0x00000403 1 7 sym.main_2e_1
|
||||
0x000004f5 1 3 sym.stackSave
|
||||
0x000004fa 1 5 sym.stackRestore
|
||||
0x00000505 1 15 sym.stackAlloc
|
||||
0x0000052b 1 6 sym.emscripten_stack_get_free
|
||||
0x00000533 1 3 sym.emscripten_stack_get_base
|
||||
0x00000538 1 3 sym.emscripten_stack_get_end
|
||||
0x0000053d 1 4 sym.__errno_location
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user