Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: I get an error when I try to import frida in update 15.1.12 #10129

Closed
arjatr opened this issue Dec 12, 2021 · 16 comments · Fixed by #10938
Closed

[Bug]: I get an error when I try to import frida in update 15.1.12 #10129

arjatr opened this issue Dec 12, 2021 · 16 comments · Fixed by #10938
Labels
bug report Something is not working properly help wanted Help is wanted in order to solve the issue root Issue is related to stuff requiring root permissions or root-packages

Comments

@arjatr
Copy link

arjatr commented Dec 12, 2021

Problem description

I get an error when I try to import frida in update 15.1.12
Screenshot_20211212-150201328

What steps will reproduce the bug?

updating version

What is the expected behavior?

No response

System information

Application version:
0.117
Packages CPU architecture:
aarch64
Subscribed repositories:

sources.list

deb https://packages.termux.org/apt/termux-main/ stable main

science-repo (sources.list.d/science.list)

deb https://packages.termux.org/apt/termux-science science stable

sources.list.d/root.list.bak

deb https://www.grimler.se/termux-root-packages-24 root stable

root-repo (sources.list.d/root.list)

deb https://packages.termux.org/apt/termux-root root stable

game-repo (sources.list.d/game.list)

deb https://packages.termux.org/apt/termux-games games stable

x11-repo (sources.list.d/x11.list)

deb https://packages.termux.org/apt/termux-x11 x11 main
Updatable packages:
All packages up to date
Android version:
10
Kernel build information:
Linux localhost 4.4.243-pixel-g86d2da2c2a83-ab881ba1b70d termux/termux-root-packages#1 SMP PREEMPT Sun Nov 22 22:52:36 UTC 2020 aarch64 Android
Device manufacturer:
Xiaomi
Device model:
Mi A2

@Grimler91
Copy link
Member

Thanks. Supposedly there is some incompatibility between the python3.10 in ubuntu that we are using in the cross-compilation process, and the python3.10 we have on device. Just re-compiling the package, and upgrading to frida 15.1.14, does not help

@Grimler91 Grimler91 added the bug label Dec 12, 2021
@arjatr
Copy link
Author

arjatr commented Dec 12, 2021

Any solution after updating termux no longer worked?

@Grimler91
Copy link
Member

No, I don't know how to fix the error yet.

Perhaps you can compile the python library on device to get something that works, but that is not a trivial thing to do in any case

@Grimler91
Copy link
Member

Seems more likely that it is due to frida using it's own toolchain. Aligning their mesonbuild system with ours (and/or linker flags) might be the solution. Adding just -Wl,--hash-style=gnu, removing --strip-all from strip flags and preventing meson from removing some DT_ flags does not help though.

@Grimler91
Copy link
Member

Grimler91 commented Dec 13, 2021

We can see that GNU_HASH is missing from _frida.so with objdump -x $PREFIX/lib/python3.10/site-packages/_frida.so, we currently have:

[...]
Dynamic Section:
  NEEDED               libc.so
  NEEDED               libpython3.10.so.1.0
  NEEDED               libdl.so
  NEEDED               libm.so
  FLAGS                0x0000000000000008
  FLAGS_1              0x0000000000000001
  RELA                 0x0000000000003408
  RELASZ               0x0000000000065910
  RELAENT              0x0000000000000018
  RELACOUNT            0x0000000000004395
  JMPREL               0x0000000000068d18
  PLTRELSZ             0x0000000000001d88
  PLTGOT               0x0000000003cc4da0
  PLTREL               0x0000000000000007
  SYMTAB               0x0000000000000308
  SYMENT               0x0000000000000018
  STRTAB               0x0000000000002530
  STRSZ                0x0000000000000ed2
  FINI_ARRAYSZ         0x0000000000000028
  INIT_ARRAY           0x0000000003cc3730
  INIT_ARRAYSZ         0x0000000000000028
  FINI_ARRAY           0x0000000003cc3708
  
[...]

while other libraries have GNU_HASH as well (objdump -x $PREFIX/lib/python3.10/lib-dynload/_md5.cpython-310.so):

[...]
Dynamic Section:
  RUNPATH              /data/data/com.termux/files/usr/lib:/data/data/com.termux/files/usr/lib:/data/data/com.termux/files/usr/lib
  NEEDED               libpython3.10.so.1.0
  NEEDED               libc.so
  FLAGS                0x0000000000000008
  FLAGS_1              0x0000000000000001
  RELA                 0x00000000000009d8
  RELASZ               0x0000000000000450
  RELAENT              0x0000000000000018
  RELACOUNT            0x000000000000002b
  JMPREL               0x0000000000000e28
  PLTRELSZ             0x00000000000002a0
  PLTGOT               0x0000000000004e68
  PLTREL               0x0000000000000007
  SYMTAB               0x0000000000000308
  SYMENT               0x0000000000000018
  STRTAB               0x00000000000006fc
  STRSZ                0x00000000000002d5
  GNU_HASH             0x00000000000006d0
  FINI_ARRAY           0x0000000000004cc0
  FINI_ARRAYSZ         0x0000000000000010
  VERSYM               0x0000000000000668
  VERNEED              0x00000000000006b0
  VERNEEDNUM           0x0000000000000001

[...]

@arjatr
Copy link
Author

arjatr commented Dec 18, 2021

any alternative in the meantime? Before updating it worked excellent until I updated termux

@Grimler91
Copy link
Member

Not really, you would have to build python3.9, and rebuild frida against it

@Grimler91
Copy link
Member

@oleavr do you perhaps have an idea why GNU_HASH is missing from _frida.so here?

I am sure my various patches/hacks to make it build are in some way responsible..

@oleavr
Copy link

oleavr commented Dec 23, 2021

@Grimler91 (Sorry for the delay here, totally missed this.) Hmm, I strongly suspect it's caused by our recent upgrade to Android NDK r24. Since the previous NDK we were on they've fully transitioned to an LLVM toolchain, and binutils is gone. So I guess binary compatibility went out the window with that change? (It wouldn't be the first time that the NDK ABI broke.)

@djerryz
Copy link

djerryz commented Jan 11, 2022

I just update frida-server . And i get the same bug when i try to exec frida-server or frida-ps:
image

old version frida-server is 12.11.18, new version be 15.1.12 after update:

apt update && apt upgrade -y
apt remove frida-server
apt install frida-server
apt remove frida-tools
apt install frida-tools

Here is my termux-info:

Application version:
unsupported
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main
# root-repo (sources.list.d/root.list)
deb https://packages.termux.org/apt/termux-root root stable
# game-repo (sources.list.d/game.list)
deb https://packages.termux.org/apt/termux-games games stable
# science-repo (sources.list.d/science.list)
deb https://packages.termux.org/apt/termux-science science stable
Updatable packages:
All packages up to date
Android version:
9
Kernel build information:
Linux kali 3.18.140-Re4son-r1b1-1 termux/termux-root-packages#1 SMP PREEMPT Fri May 1 10:20:30 AEST 2020 aarch64 Android
Device manufacturer:
OnePlus
Device model:
ONEPLUS A3000

@djerryz
Copy link

djerryz commented Jan 12, 2022

~ $ frida-ps --version

***
Failed to load the Frida native extension: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/data/com.termux/files/usr/lib/python3.10/site-packages/_frida.so" (new hash type from the future?)
Please ensure that the extension was compiled for Python 3.x.
***

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/frida-ps", line 10, in <module>
    frida_tools.ps.main()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida_tools/ps.py", line 17, in main
    from frida_tools.application import ConsoleApplication
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida_tools/application.py", line 23, in <module>
    import frida
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida/__init__.py", line 24, in <module>
    raise ex
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida/__init__.py", line 7, in <module>
    import _frida
ImportError: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/data/com.termux/files/usr/lib/python3.10/site-packages/_frida.so" (new hash type from the future?)

@Grimler91
Copy link
Member

  • Compiling _frida.so on device gives a working library (after hacking compilation flags to fix compilation errors)
  • Using a termux's meson (instead of github.com/frida/meson) when building frida does not fix the issue
  • Changing so termux's toolchain is used instead of frida's does not seem to help
  • Skipping the strip step does not help (the hash seem to never be added)

Has to be some compiler or linker flag that explains the issue, but I can't see anything obvious.
Running the build with --verbose shows that the library with the missing HASH is compiled with the command:

non-working command
[1/3] Compiling C object src/_frida.so.p/_frida.c.o
Android (7714059, based on r416183c1) clang version 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d7cf2016289302412d708641d52d2f7ee)
Target: aarch64-none-linux-android24
Thread model: posix
InstalledDir: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin
Found candidate GCC installation: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x
Selected GCC installation: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x
Candidate multilib: .;@m64
Selected multilib: .;@m64
 (in-process)
 "/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" \
-cc1 \
-triple aarch64-none-linux-android24 \
-emit-obj \
-mrelax-all \
--mrelax-relocations \
-mnoexecstack \
-disable-free \
-disable-llvm-verifier \
-discard-value-names \
-main-file-name _frida.c \
-mrelocation-model pic \
-pic-level 2 \
-fhalf-no-semantic-interposition \
-mframe-pointer=non-leaf \
-fno-rounding-math \
-mconstructor-aliases \
-munwind-tables \
-target-cpu generic \
-target-feature +neon \
-target-abi aapcs \
-mllvm \
-aarch64-fix-cortex-a53-835769=1 \
-fallow-half-arguments-and-returns \
-fno-split-dwarf-inlining \
-debug-info-kind=limited \
-dwarf-version=4 \
-debugger-tuning=gdb \
-v \
-ffunction-sections \
-fdata-sections \
-resource-dir /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.8 \
-dependency-file src/_frida.so.p/_frida.c.o.d \
-MT src/_frida.so.p/_frida.c.o \
-sys-header-deps \
-include /work/termux-build/frida-server/src/build/frida-version.h \
-I src/_frida.so.p \
-I src \
-I ../../../frida-python/src \
-I /data/data/com.termux/files/usr/include \
-I /data/data/com.termux/files/usr/include/python3.10 \
-I /work/termux-build/frida-server/src/build/frida-android-arm64/include/frida-1.0 \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/gee-0.8 \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/minizip \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/capstone \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/quickjs \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/v8-8.0 \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/v8-8.0/v8 \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/gio-unix-2.0 \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/libsoup-2.4 \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/libxml2 \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/nice \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/json-glib-1.0 \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/include/glib-2.0 \
-I /work/termux-build/frida-server/src/build/sdk-android-arm64/lib/glib-2.0/include \
-I /work/termux-build/frida-server/src/build/frida-android-arm64/include \
-D _FILE_OFFSET_BITS=64 \
-D ANDROID \
-D LIBXML_STATIC \
-isysroot /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot \
-internal-isystem /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include \
-internal-isystem /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.8/include \
-internal-externc-isystem /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android \
-internal-externc-isystem /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/include \
-internal-externc-isystem /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include \
-O0 \
-Wall \
-Winvalid-pch \
-fdebug-compilation-dir /work/termux-build/frida-server/src/build/tmp-android-arm64/frida-python3.10 \
-ferror-limit 19 \
-pthread \
-fno-signed-char \
-fgnuc-version=4.2.1 \
-fcolor-diagnostics \
-o src/_frida.so.p/_frida.c.o \
-x c \
../../../frida-python/src/_frida.c
clang -cc1 version 12.0.8 based upon LLVM 12.0.8git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/include"
#include "..." search starts here:
#include <...> search starts here:
 src/_frida.so.p
 src
 ../../../frida-python/src
 /data/data/com.termux/files/usr/include
 /data/data/com.termux/files/usr/include/python3.10
 /work/termux-build/frida-server/src/build/frida-android-arm64/include/frida-1.0
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/gee-0.8
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/minizip
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/capstone
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/quickjs
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/v8-8.0
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/v8-8.0/v8
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/gio-unix-2.0
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/libsoup-2.4
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/libxml2
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/nice
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/json-glib-1.0
 /work/termux-build/frida-server/src/build/sdk-android-arm64/include/glib-2.0
 /work/termux-build/frida-server/src/build/sdk-android-arm64/lib/glib-2.0/include
 /work/termux-build/frida-server/src/build/frida-android-arm64/include
 /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/local/include
 /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.8/include
 /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android
 /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include
End of search list.
[2/3] Linking target src/_frida.so
Android (7714059, based on r416183c1) clang version 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d7cf2016289302412d708641d52d2f7ee)
Target: aarch64-none-linux-android24
Thread model: posix
InstalledDir: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin
Found candidate GCC installation: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x
Selected GCC installation: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/ld" \
-z noexecstack \
-EL \
--fix-cortex-a53-843419 \
--warn-shared-textrel \
-z now \
-z relro \
-z max-page-size=4096 \
--hash-style=gnu \
--enable-new-dtags \
--eh-frame-hdr \
-m aarch64linux \
-shared \
-o src/_frida.so \
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtbegin_so.o \
-L/data/data/com.termux/files/usr/lib \
-L/work/termux-build/frida-server/src/build/frida-android-arm64/lib \
-L/work/termux-build/frida-server/src/build/sdk-android-arm64/lib \
-L/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.8/lib/linux/aarch64 \
-L/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x \
-L/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/lib/aarch64-linux-android/24 \
-L/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/lib/aarch64-linux-android \
-L/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/lib \
-rpath-link=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/24 \
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.8/lib/linux/aarch64/libunwind.a \
-lc \
src/_frida.so.p/_frida.c.o \
--as-needed \
--allow-shlib-undefined \
--gc-sections \
-z noexecstack \
-z relro \
-z now \
--start-group \
-lpython3.10 \
--version-script \
/work/termux-build/frida-server/src/frida-python/src/_frida.version \
../frida-core/lib/selinux/libfrida-selinux.a \
/work/termux-build/frida-server/src/build/frida-android-arm64/lib/libfrida-core-1.0.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libgee-0.8.a \
/work/termux-build/frida-server/src/build/frida-android-arm64/lib/libfrida-gumjs-1.0.a \
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/24/liblog.so \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libdwarf.a \
-ldl \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libz.a \
/work/termux-build/frida-server/src/build/frida-android-arm64/lib/libfrida-gum-1.0.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libunwind.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/liblzma.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libelf.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libminizip.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libiconv.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libcapstone.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libquickjs.a \
-lm \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libv8-8.0.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libtcc.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libsoup-2.4.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libxml2.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libsqlite3.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libpsl.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libbrotlidec.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libbrotlicommon.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libselinux.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libsepol.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/gio/modules/libgioopenssl.a \
--export-dynamic \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libnice.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libgthread-2.0.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libssl.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libcrypto.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libusrsctp.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libjson-glib-1.0.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libgio-2.0.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libgobject-2.0.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libffi.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libgmodule-2.0.a \
/work/termux-build/frida-server/src/build/sdk-android-arm64/lib/libglib-2.0.a \
--end-group \
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.8/lib/linux/libclang_rt.builtins-aarch64-android.a \
-l:libunwind.a \
-ldl \
-lc \
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/12.0.8/lib/linux/libclang_rt.builtins-aarch64-android.a \
-l:libunwind.a \
-ldl \
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/lib/aarch64-linux-android/24/crtend_so.o

While when compiling on device, command looks like

working command
[1/2] ccache cc -Isrc/_frida.so.p -Isrc -I../src -I/data/data/com.termux/files/usr/include/frida-1.0 -I/data/data/com.termux/files/usr/include/python3.10 -I/work/termux-build/frida-server/src/build/frida-android-arm64/include/frida-1.0 -I/data/data/com.termux/files/usr/include -I/data/data/com.termux/files/usr/include/capstone -I/data/data/com.termux/files/usr/include/gio-unix-2.0 -I/data/data/com.termux/files/usr/include/libsoup-2.4 -I/data/data/com.termux/files/usr/include/libxml2 -I/data/data/com.termux/files/usr/include/json-glib-1.0 -I/data/data/com.termux/files/usr/include/glib-2.0 -I/data/data/com.termux/files/usr/lib/glib-2.0/include -fcolor-diagnostics -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -fPIC -pthread -v -MD -MQ src/_frida.so.p/_frida.c.o -MF src/_frida.so.p/_frida.c.o.d -o src/_frida.so.p/_frida.c.o -c ../src/_frida.c
clang version 13.0.0
Target: aarch64-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin
Found candidate GCC installation: /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/10.3.0
Found candidate GCC installation: /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/11.1.0
Found candidate GCC installation: /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/9.3.0
Selected GCC installation: /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/11.1.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
 (in-process)
 "/data/data/com.termux/files/usr/bin/clang-13" \
-cc1 \
-triple aarch64-unknown-linux-android24 \
-emit-obj \
-mrelax-all \
--mrelax-relocations \
-mnoexecstack \
-disable-free \
-disable-llvm-verifier \
-discard-value-names \
-main-file-name _frida.c \
-mrelocation-model pic \
-pic-level 2 \
-fhalf-no-semantic-interposition \
-mframe-pointer=non-leaf \
-fno-rounding-math \
-mconstructor-aliases \
-munwind-tables \
-target-cpu generic \
-target-feature +neon \
-target-abi aapcs \
-mllvm \
-aarch64-fix-cortex-a53-835769=1 \
-fallow-half-arguments-and-returns \
-debug-info-kind=constructor \
-dwarf-version=4 \
-debugger-tuning=gdb \
-v \
-fcoverage-compilation-dir=/data/data/com.termux/files/home/projects/frida-python/build \
-resource-dir /data/data/com.termux/files/usr/lib/clang/13.0.0 \
-dependency-file src/_frida.so.p/_frida.c.o.d \
-MT src/_frida.so.p/_frida.c.o \
-sys-header-deps \
-I src/_frida.so.p \
-I src \
-I ../src \
-I /data/data/com.termux/files/usr/include/frida-1.0 \
-I /data/data/com.termux/files/usr/include/python3.10 \
-I /work/termux-build/frida-server/src/build/frida-android-arm64/include/frida-1.0 \
-I /data/data/com.termux/files/usr/include \
-I /data/data/com.termux/files/usr/include/capstone \
-I /data/data/com.termux/files/usr/include/gio-unix-2.0 \
-I /data/data/com.termux/files/usr/include/libsoup-2.4 \
-I /data/data/com.termux/files/usr/include/libxml2 \
-I /data/data/com.termux/files/usr/include/json-glib-1.0 \
-I /data/data/com.termux/files/usr/include/glib-2.0 \
-I /data/data/com.termux/files/usr/lib/glib-2.0/include \
-D _FILE_OFFSET_BITS=64 \
-isysroot /data/data/com.termux/files \
-internal-isystem /data/data/com.termux/files/usr/lib/clang/13.0.0/include \
-internal-isystem /data/data/com.termux/files/usr/local/include \
-internal-isystem /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/11.1.0/../../../../aarch64-linux-android/include \
-internal-externc-isystem /data/data/com.termux/files/usr/include/aarch64-linux-android \
-internal-externc-isystem /data/data/com.termux/files/include \
-internal-externc-isystem /data/data/com.termux/files/usr/include \
-O0 \
-Wall \
-Winvalid-pch \
-fdebug-compilation-dir=/data/data/com.termux/files/home/projects/frida-python/build \
-ferror-limit 19 \
-pthread \
-fno-signed-char \
-fgnuc-version=4.2.1 \
-fcolor-diagnostics \
-target-feature +outline-atomics \
-D__GCC_HAVE_DWARF2_CFI_ASM=1 \
-o src/_frida.so.p/_frida.c.o \
-x c \
../src/_frida.c
clang -cc1 version 13.0.0 based upon LLVM 13.0.0 default target aarch64-unknown-linux-android24
ignoring nonexistent directory "/work/termux-build/frida-server/src/build/frida-android-arm64/include/frida-1.0"
ignoring nonexistent directory "/data/data/com.termux/files/usr/local/include"
ignoring nonexistent directory "/data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/11.1.0/../../../../aarch64-linux-android/include"
ignoring nonexistent directory "/data/data/com.termux/files/include"
ignoring duplicate directory "/data/data/com.termux/files/usr/include"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
include <...> search starts here:
 src/_frida.so.p
 src
 ../src
 /data/data/com.termux/files/usr/include/frida-1.0
 /data/data/com.termux/files/usr/include/python3.10
 /data/data/com.termux/files/usr/include/capstone
 /data/data/com.termux/files/usr/include/gio-unix-2.0
 /data/data/com.termux/files/usr/include/libsoup-2.4
 /data/data/com.termux/files/usr/include/libxml2
 /data/data/com.termux/files/usr/include/json-glib-1.0
 /data/data/com.termux/files/usr/include/glib-2.0
 /data/data/com.termux/files/usr/lib/glib-2.0/include
 /data/data/com.termux/files/usr/lib/clang/13.0.0/include
 /data/data/com.termux/files/usr/include/aarch64-linux-android
 /data/data/com.termux/files/usr/include
End of search list.

[2/2] cc  -o src/_frida.so src/_frida.so.p/_frida.c.o -Wl,--as-needed -Wl,--allow-shlib-undefined -shared -fPIC -Wl,--version-script,/data/data/com.termux/files/home/projects/frida-python/src/_frida.version -v -Wl,--start-group /data/data/com.termux/files/usr/lib/libfrida-core-1.0.a /data/data/com.termux/files/usr/lib/libjson-glib-1.0.so /data/data/com.termux/files/usr/lib/libgio-2.0.so /data/data/com.termux/files/usr/lib/libgobject-2.0.so /data/data/com.termux/files/usr/lib/libglib-2.0.so -Wl,--end-group
clang version 13.0.0
Target: aarch64-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin
Found candidate GCC installation: /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/10.3.0
Found candidate GCC installation: /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/11.1.0
Found candidate GCC installation: /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/9.3.0
Selected GCC installation: /data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/11.1.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/data/data/com.termux/files/usr/bin/ld.lld" \
--sysroot=/data/data/com.termux/files \
-z noexecstack \
-EL \
--fix-cortex-a53-843419 \
--warn-shared-textrel \
-z now \
-z relro \
-z max-page-size=4096 \
--hash-style=gnu \
--enable-new-dtags \
-rpath=/data/data/com.termux/files/usr/lib \
--eh-frame-hdr \
-m aarch64linux \
-shared \
-o src/_frida.so \
/data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/11.1.0/../../../../aarch64-linux-android/lib/crtbegin_so.o \
-L/data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/11.1.0 \
-L/data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/11.1.0/../../../../aarch64-linux-android/lib \
-L/data/data/com.termux/files/usr/lib \
-L/data/data/com.termux/files/usr/aarch64-linux-android/lib \
-L/system/lib64 \
src/_frida.so.p/_frida.c.o \
--as-needed \
--allow-shlib-undefined \
--version-script /data/data/com.termux/files/home/projects/frida-python/src/_frida.version \
--start-group \
/data/data/com.termux/files/usr/lib/libfrida-core-1.0.a \
/data/data/com.termux/files/usr/lib/libjson-glib-1.0.so \
/data/data/com.termux/files/usr/lib/libgio-2.0.so \
/data/data/com.termux/files/usr/lib/libgobject-2.0.so \
/data/data/com.termux/files/usr/lib/libglib-2.0.so \
--end-group \
/data/data/com.termux/files/usr/lib/clang/13.0.0/lib/android/libclang_rt.builtins-aarch64-android.a \
-l:libunwind.a \
-ldl \
-lc \
/data/data/com.termux/files/usr/lib/clang/13.0.0/lib/android/libclang_rt.builtins-aarch64-android.a \
-l:libunwind.a \
-ldl \
/data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/11.1.0/../../../../aarch64-linux-android/lib/crtend_so.o

In both cases link command has --hash-style=gnu --enable-new-dtags (which seems like the most obvious thing that might affect the HASH).

@xtkoba, @buttaface have any of you encountered issues where DT_HASH and DT_GNU_HASH are missing from the compiled library?

@finagolfin
Copy link
Member

No, never seen this issue.

@s20208413
Copy link

s20208413 commented Apr 5, 2022

A workaround:

pip install frida-tools

then everything works fine.

Screenshot_2022-04-05-22-56-32-349_com termux

@thunder-coding thunder-coding transferred this issue from termux/termux-root-packages Apr 19, 2022
@xtkoba xtkoba added root Issue is related to stuff requiring root permissions or root-packages bug report Something is not working properly and removed bug labels Apr 19, 2022
Grimler91 added a commit that referenced this issue Jun 10, 2022
For some reason the compilation as part of termux_step_make results in
a binary that segfaults.  Issue has something to do with our
toolchain, if it is removed from PATH then frida-resource-compiler
works fine.  So, one solution is to solely use frida's toolchain, but
as we have seen in #10129 this gives libraries
and executables that do not work on device.  Using our toolchain gives
us more control over the compilation and makes it easier to solve the
issue.
Grimler91 added a commit that referenced this issue Jun 10, 2022
And avoid frida's cc/cxx wrappers.  This fixes
#10129.  Most likely it is
frida-elf-cleaner (that is run in the wrappers) that strips away
DT_GNU_HASH and friends and causes the errors.
Grimler91 added a commit that referenced this issue Jun 10, 2022
For some reason the compilation as part of termux_step_make results in
a binary that segfaults.  Issue has something to do with our
toolchain, if it is removed from PATH then frida-resource-compiler
works fine.  So, one solution is to solely use frida's toolchain, but
as we have seen in #10129 this gives libraries
and executables that do not work on device.  Using our toolchain gives
us more control over the compilation and makes it easier to solve the
issue.
@Grimler91
Copy link
Member

Fixed finally, probably it was frida-elf-cleaner causing the issue, so avoiding frida's cc/cxx wrappers (and purely using termux's toolchain) fixes the issue

@Grimler91
Copy link
Member

As @sceext2 pointed out pip install frida seem to work these days as well, so our package is rather superfluous these days, since static frida-server can be downloaded from frida's release page and python bindings installed through pip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something is not working properly help wanted Help is wanted in order to solve the issue root Issue is related to stuff requiring root permissions or root-packages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants