wargio / r2dec-js

radare2 plugin - converts asm to pseudo-C code.
508 stars 48 forks source link

standalone tool is broken #315

Closed trufae closed 4 weeks ago

trufae commented 1 month ago
0$ b/r2dec-standalone issue.json
ReferenceError: 'process' is not defined
    at <anonymous> (../js/r2dec-plugin.js:109)

1$
wargio commented 4 weeks ago

is not broken. i do not know what you did, but definitely is not.

deroad@dev r2dec-js (master) $ meson setup -Dstandalone=true build-st
The Meson build system
Version: 1.4.1
Source dir: /home/deroad/r2dec-js
Build dir: /home/deroad/r2dec-js/build-st
Build type: native build
Project name: r2dec
Project version: undefined
C compiler for the host machine: cc (gcc 14.1.1 "cc (GCC) 14.1.1 20240522")
C linker for the host machine: cc ld.bfd 2.42.0
Host machine cpu family: x86_64
Host machine cpu: x86_64

Executing subproject libquickjs 

libquickjs| Project name: quickjs
libquickjs| Project version: 2021-03-27-frida
libquickjs| C compiler for the host machine: cc (gcc 14.1.1 "cc (GCC) 14.1.1 20240522")
libquickjs| C linker for the host machine: cc ld.bfd 2.42.0
libquickjs| Run-time dependency threads found: YES
libquickjs| Library dl found: YES
libquickjs| Library m found: YES
libquickjs| Has header "unistd.h" : YES
libquickjs| Checking for function "malloc_usable_size" : YES
libquickjs| Configuring config.h using configuration
libquickjs| Build targets in project: 2
libquickjs| Subproject libquickjs finished.

Build targets in project: 6

r2dec undefined

  Subprojects
    libquickjs: YES

  User defined options
    standalone: true

Found ninja-1.12.1 at /usr/bin/ninja
deroad@dev r2dec-js (master) $ ninja -C build-st
ninja: Entering directory `build-st'
[18/18] Linking target r2dec-standalone
deroad@dev r2dec-js (master) $ build-st/r2dec-standalone ../r2dec-regression/tests/example.ppc.json 
    ; assembly                               | /* r2dec pseudo code output */
                                             | /* testsuite @ 0x0 */
                                             | #include <stdint.h>
                                             | #define SPR_HID1 (0x3f1)
                                             | #define SPR_HID4 (0x3f4)
                                             | #define SPR_HID0 (0x3f0)
                                             | #define SPR_HID5 (0x3f6)
                                             | #define SPR_HID6 (0x3f9)
                                             |  
                                             | uint64_t rotate_left64 (uint64_t value, uint32_t count) {
                                             |     const uint64_t mask = (CHAR_BIT * sizeof (value)) - 1;
                                             |     count &= mask;
                                             |     return (value << count) | (value >> (-count & mask));
                                             | }
                                             |  
    ; (fcn) boot ()                          | void boot () {
    0x00000ae8 li r0, 0                      |     r0 = 0;
    0x00000aec mfpvr r4                      |     _mfpvr ();
    0x00000af0 lis r5, 0                     |     r5 = 0xa48;
    0x00000af4 ori r5, r5, 0xa48             |     
                                             |     do {
    0x00000af8 ld r6, 0(r5)                  |         r6 = *((int64_t*) r5);
    0x00000afc cmpd r6, r4                   |         
                                             |         if (r6 == r4) {
    0x00000b00 beq- 0xb18                    |             goto label_0;
                                             |         }
    0x00000b04 cmpdi r6, 0                   |         
                                             |         if (r6 == 0) {