facebookexperimental / ExtendedAndroidTools

Extended Android Tools is a place to host and maintain a build environment and makefiles cross compiling Linux tools we all love for Android.
Apache License 2.0
189 stars 63 forks source link

run bpftrace on android meet proble" cannot locate symbol "CrcGenerateTable" " #20

Closed micro2440 closed 2 years ago

micro2440 commented 2 years ago

Hi,

I pull this project and build bpftrace, but when I run bpftrace on android, but the error like below:

WARNING: linker: Warning: "/data/local/tmp/bpftools/lib/libc++_shared.so" unused DT entry: unknown processor-specific (type 0x70000001 arg 0x0) (ignoring) WARNING: linker: Warning: "/data/local/tmp/bpftools/lib/libc++_shared.so" unused DT entry: unknown processor-specific (type 0x70000001 arg 0x0) (ignoring) WARNING: linker: Warning: "/data/local/tmp/bpftools/lib/libc++_shared.so" unused DT entry: unknown processor-specific (type 0x70000001 arg 0x0) (ignoring) CANNOT LINK EXECUTABLE "bpftrace": cannot locate symbol "CrcGenerateTable" referenced by "/system/lib64/libunwindstack.so"...

So , Is any one can help me out, how to slove this problem.

micro2440 commented 2 years ago

All,

After try many times , I already slove this problem and running on android.

michalgr commented 2 years ago

Hi,

Could you share more details ? What was the problem and how did you fix it ?

micro2440 commented 2 years ago

Hi,

Issue1: CANNOT LINK EXECUTABLE "bpftrace": cannot locate symbol "CrcGenerateTable" referenced by "/system/lib64/libunwindstack.so. slove1: In my Android source code , I found the symbol "CrcGenerateTable" in liblzma.so, but in build lib "out/android/arm64/lib" I also found liblzma.so, but I have not found the symbol in out/android/arm64/lib/liblzma.so, so I thought maybe I can replace liblzma.so via android's liblzma.so, after that I can run bpftrace on android device.

Issue2: when I run the example : ./bpftrace -e 'kprobe:do_nanosleep { printf("PID %d sleeping...\n", pid); }' I found the error: ./bpftrace/include/clang_workarounds.h:14:10: fatal error: 'linux/types.h' file not found,

So after adb push many "*.h" to the device and run command:

k6873v1_64_phone:/data/local/tmp/bpftools/include # ls -l total 32

drwxrwxrwx 2 root root 4096 2022-04-22 07:15 asm drwxrwxrwx 2 root root 4096 2022-04-22 07:16 asm-generic drwxrwxrwx 2 root root 4096 2022-04-22 07:14 linux drwxrwxrwx 4 root root 4096 2022-04-22 06:58 uapi

./bpftrace -e 'kprobe:do_nanosleep { printf("PID %d sleeping...\n", pid); }' -I ./include/

After two steps, the bpftrace command can successful run on android device.

So as the above, that are details, if you any question, please contact me.

wangzhangjun commented 1 year ago

Hi,

Issue1: CANNOT LINK EXECUTABLE "bpftrace": cannot locate symbol "CrcGenerateTable" referenced by "/system/lib64/libunwindstack.so. slove1: In my Android source code , I found the symbol "CrcGenerateTable" in liblzma.so, but in build lib "out/android/arm64/lib" I also found liblzma.so, but I have not found the symbol in out/android/arm64/lib/liblzma.so, so I thought maybe I can replace liblzma.so via android's liblzma.so, after that I can run bpftrace on android device.

Issue2: when I run the example : ./bpftrace -e 'kprobe:do_nanosleep { printf("PID %d sleeping...\n", pid); }' I found the error: ./bpftrace/include/clang_workarounds.h:14:10: fatal error: 'linux/types.h' file not found,

So after adb push many "*.h" to the device and run command:

k6873v1_64_phone:/data/local/tmp/bpftools/include # ls -l total 32

drwxrwxrwx 2 root root 4096 2022-04-22 07:15 asm drwxrwxrwx 2 root root 4096 2022-04-22 07:16 asm-generic drwxrwxrwx 2 root root 4096 2022-04-22 07:14 linux drwxrwxrwx 4 root root 4096 2022-04-22 06:58 uapi

./bpftrace -e 'kprobe:do_nanosleep { printf("PID %d sleeping...\n", pid); }' -I ./include/

After two steps, the bpftrace command can successful run on android device.

So as the above, that are details, if you any question, please contact me.

hi , I also meet I found the error: ./bpftrace/include/clang_workarounds.h:14:10: fatal error: 'linux/types.h' file not found. Could you explain what these files(asm, asm-generic, linux , uapi) are? And Where to get? thank you !