frida / frida-gum

Cross-platform instrumentation and introspection library written in C
https://frida.re
Other
753 stars 245 forks source link

gumv8script-runtime.h: error: narrowing conversion from int to gchar #713

Closed milahu closed 1 year ago

milahu commented 1 year ago

trying to build with v8

meson -Dgumjs=enabled -Dv8=enabled
FAILED: bindings/gumjs/libfrida-gumjs-1.0.so.p/gumv8script.cpp.o 
g++ -Ibindings/gumjs/libfrida-gumjs-1.0.so.p -Ibindings/gumjs -I../bindings/gumjs -Ibindings -I../bindings -I. -I.. -Igum -I../gum -I../gum/arch-x86 -I../gum/arch-arm -I../gum/arch-arm64 -I../gum/arch-mips -Ilibs -I../libs -Ilibs/gum/heap -I../libs/gum/heap -Ilibs/gum/prof -I../libs/gum/prof -I../gum/backend-elf -I/nix/store/7gp6sgjxwr4bzvy4r29a0rmb476pxww0-glib-2.74.3-dev/include/glib-2.0 -I/nix/store/i4dqcpppyyq5yqcvw95mv5s11yfyy8pf-glib-2.74.3/lib/glib-2.0/include -I/nix/store/aw5yynzqi8cg4h733qjch53zcm4nkshr-capstone-5.0-rc2/include/capstone -I/nix/store/7gp6sgjxwr4bzvy4r29a0rmb476pxww0-glib-2.74.3-dev/include -I/nix/store/xwwsq9npsaqxkafsz7158ndm2jyqc3xd-frida-v8-unstable-2022-11-02/include/v8-10.0 -I/nix/store/7gp6sgjxwr4bzvy4r29a0rmb476pxww0-glib-2.74.3-dev/include/gio-unix-2.0 -I/nix/store/9kzjvxagf6cdqcsyy6z9vf1vvcbcb6xv-json-glib-1.6.6-dev/include/json-glib-1.0 -I/nix/store/s7dns7drgskk7xpr4s3kvqcc745dg9js-libffi-3.4.4-dev/include -I/nix/store/wm1jdcfwdjqzbk0sazarndjljchcdhj9-frida-tinycc-unstable-2022-04-01/include -I/nix/store/w7828xfm8r7xj5jik8qv1kbz80imqcyf-sqlite-3.40.1-dev/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -std=c++17 -fno-exceptions -fno-rtti -include /tmp/tmp.39DDKEItsr/frida-gum/build/config.h '-DG_LOG_DOMAIN="Frida"' -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_56 -DG_DISABLE_DEPRECATED -D_GNU_SOURCE=1 -fPIC -DV8_GN_HEADER -DUSING_V8_SHARED -DUSING_V8_PLATFORM_SHARED -MD -MQ bindings/gumjs/libfrida-gumjs-1.0.so.p/gumv8script.cpp.o -MF bindings/gumjs/libfrida-gumjs-1.0.so.p/gumv8script.cpp.o.d -o bindings/gumjs/libfrida-gumjs-1.0.so.p/gumv8script.cpp.o -c ../bindings/gumjs/gumv8script.cpp
In file included from ../bindings/gumjs/gumv8script.cpp:12:
bindings/gumjs/gumv8script-runtime.h:2168:1: error: narrowing conversion of ‘240’ from ‘int’ to ‘gchar’ {aka ‘char’} [-Wnarrowing]
 2168 | };
      | ^

in bindings/gumjs/gumv8script-runtime.h

#include "gumv8bundle.h"

static const gchar gumjs_frida_source_code[45743] =
{
  240,159,147,166,10,50,48,48,32,47,114,117,110,116,105,109,101,47,101,110,
  116,114,121,112,111,105,110,116,45,118,56,46,106,115,46,109,97,112,10,

generated by bindings/gumjs/generate-runtime.py

240,159,147,166 = b'\xf0\x9f\x93\xa6' = utf-8 f09f93a6 = 📦 = Unicode Character 'PACKAGE'

existing code (and glib) uses gchar, so cast from uchar to char in generate-runtime.py: if b >= 128: b -= 256

and

../bindings/gumjs/gumv8script.cpp: In function ‘gboolean gum_v8_script_create_context(GumV8Script*, GError**)’:
../bindings/gumjs/gumv8script.cpp:513:43: error: ‘gumjs_frida_source_map’ was not declared in this scope; did you mean ‘gumjs_frida_source_code’?
  513 |     _gum_v8_core_init (&self->core, self, gumjs_frida_source_map,
      |                                           ^~~~~~~~~~~~~~~~~~~~~~
      |                                           gumjs_frida_source_code

→ define gumjs_frida_source_map as empty string NULL would be prettier but does not work

fixed

In file included from ../bindings/gumjs/gumv8scriptbackend.cpp:12:
../bindings/gumjs/gumv8platform.h:63:7: error: ‘ThreadingBackend’ in namespace ‘v8’ does not name a type
   63 |   v8::ThreadingBackend * GetThreadingBackend () override;
      |       ^~~~~~~~~~~~~~~~

problem: i was using libv8-10.8.25 from nodejs-19.4.0 fix: use https://github.com/frida/v8

[99/181] Compiling C object bindings/gumjs/libfrida-gumjs-1.0.so.p/gumcmodule.c.o
FAILED: bindings/gumjs/libfrida-gumjs-1.0.so.p/gumcmodule.c.o 
gcc -Ibindings/gumjs/libfrida-gumjs-1.0.so.p -Ibindings/gumjs -I../bindings/gumjs -Ibindings -I../bindings -I. -I.. -Igum -I../gum -I../gum/arch-x86 -I../gum/arch-arm -I../gum/arch-arm64 -I../gum/arch-mips -Ilibs -I../libs -Ilibs/gum/heap -I../libs/gum/heap -Ilibs/gum/prof -I../libs/gum/prof -I../gum/backend-elf -I/nix/store/7gp6sgjxwr4bzvy4r29a0rmb476pxww0-glib-2.74.3-dev/include/glib-2.0 -I/nix/store/i4dqcpppyyq5yqcvw95mv5s11yfyy8pf-glib-2.74.3/lib/glib-2.0/include -I/nix/store/aw5yynzqi8cg4h733qjch53zcm4nkshr-capstone-5.0-rc2/include/capstone -I/nix/store/7gp6sgjxwr4bzvy4r29a0rmb476pxww0-glib-2.74.3-dev/include -I/nix/store/z4a64qb5s8iq4zzvfj15nns2d1v1w01x-nodejs-19.4.0-libv8/include -I/nix/store/7gp6sgjxwr4bzvy4r29a0rmb476pxww0-glib-2.74.3-dev/include/gio-unix-2.0 -I/nix/store/9kzjvxagf6cdqcsyy6z9vf1vvcbcb6xv-json-glib-1.6.6-dev/include/json-glib-1.0 -I/nix/store/s7dns7drgskk7xpr4s3kvqcc745dg9js-libffi-3.4.4-dev/include -I/nix/store/nkyrir8vb4cb0slnfxi2lsdqd1m06jhs-tcc-unstable-2022-07-15/include -I/nix/store/w7828xfm8r7xj5jik8qv1kbz80imqcyf-sqlite-3.40.1-dev/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=gnu99 -include /tmp/tmp.39DDKEItsr/frida-gum/build/config.h '-DG_LOG_DOMAIN="Frida"' -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_56 -DG_DISABLE_DEPRECATED -D_GNU_SOURCE=1 -fPIC -MD -MQ bindings/gumjs/libfrida-gumjs-1.0.so.p/gumcmodule.c.o -MF bindings/gumjs/libfrida-gumjs-1.0.so.p/gumcmodule.c.o.d -o bindings/gumjs/libfrida-gumjs-1.0.so.p/gumcmodule.c.o -c ../bindings/gumjs/gumcmodule.c
In file included from /nix/store/i4dqcpppyyq5yqcvw95mv5s11yfyy8pf-glib-2.74.3/lib/glib-2.0/include/glibconfig.h:9,
                 from /nix/store/7gp6sgjxwr4bzvy4r29a0rmb476pxww0-glib-2.74.3-dev/include/glib-2.0/glib/gtypes.h:34,
                 from /nix/store/7gp6sgjxwr4bzvy4r29a0rmb476pxww0-glib-2.74.3-dev/include/glib-2.0/glib/galloca.h:34,
                 from /nix/store/7gp6sgjxwr4bzvy4r29a0rmb476pxww0-glib-2.74.3-dev/include/glib-2.0/glib.h:32,
                 from ../gum/gumdefs.h:10,
                 from ../gum/gummemory.h:11,
                 from ../bindings/gumjs/gumcmodule.h:10,
                 from ../bindings/gumjs/gumcmodule.c:7:
bindings/gumjs/gumcmodule-runtime.h: In function ‘gum_cmodule_get_symbols’:
bindings/gumjs/gumcmodule-runtime.h:3414:70: error: ‘dlclose’ undeclared (first use in this function); did you mean ‘pclose’?
 3414 |     g_hash_table_insert (symbols, "dlclose", GUM_FUNCPTR_TO_POINTER (dlclose));
      |                                                                      ^~~~~~~

fix: use https://github.com/frida/tinycc

[1/82] Compiling C object bindings/gumjs/libfrida-gumjs-1.0.so.p/gumcmodule.c.o
../bindings/gumjs/gumcmodule.c: In function ‘gum_tcc_cmodule_new’:
../bindings/gumjs/gumcmodule.c:453:3: warning: implicit declaration of function ‘tcc_set_cpp_load_func’; did you mean ‘tcc_set_error_func’? [-Wimplicit-function-declaration]
  453 |   tcc_set_cpp_load_func (state, cmodule, gum_tcc_cmodule_load_header);
      |   ^~~~~~~~~~~~~~~~~~~~~

fix: use https://github.com/frida/tinycc