frida / frida-gum

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

gumcmodule-runtime.h:3414:70: error: dlclose undeclared #719

Closed milahu closed 1 year ago

milahu commented 1 year ago

fails to compile with vanilla tinycc

[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 ... -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: generate-runtime.py should ignore tcclib.h

dlclose comes from tcclib.h

generate-runtime.py with debug prints ```py for header_dir, header_reldir, header_filter, header_transform, header_kind in inputs: print(f"generate-runtime.py: header_dir={header_dir}", file=sys.stderr) print(f"generate-runtime.py: header_reldir={header_reldir}", file=sys.stderr) print(f"generate-runtime.py: header_filter={header_filter}", file=sys.stderr) for header_name, header_source in find_headers(header_dir, header_reldir, header_filter, header_transform): print(f"generate-runtime.py: header_name={header_name}", file=sys.stderr) input_identifier = "gum_cmodule_{0}".format(identifier(header_name)) for pattern in (cmodule_function_pattern, cmodule_variable_pattern): for m in pattern.finditer(header_source): name = m.group(2) symbols.append(name) print(f"generate-runtime.py: symbol={name}", file=sys.stderr) ```
generate-runtime.py: header_dir=/nix/store/6baj0zbk91jmf88qiggnhghr7w9w1il1-frida-tinycc-unstable-2022-04-01/lib/tcc/include
generate-runtime.py: header_reldir=None
generate-runtime.py: header_filter=<function is_header at 0x7ffff73f7d00>
generate-runtime.py: header_name=stdbool.h
generate-runtime.py: header_name=varargs.h
generate-runtime.py: header_name=stddef.h
generate-runtime.py: header_name=tcclib.h
generate-runtime.py: symbol=free
generate-runtime.py: symbol=atoi
generate-runtime.py: symbol=exit
...
generate-runtime.py: symbol=perror
generate-runtime.py: symbol=strlen
generate-runtime.py: symbol=dlclose

also mentioned in #713

see also https://github.com/frida/tinycc/issues/6

milahu commented 1 year ago

fails to compile with vanilla tinycc

with #720 it compiles with vanilla tinycc

what is the difference to frida/tinycc? should we require frida/tinycc?