Comments (12)
@iotcg thanks for sharing your header build script. Could you send me a pull-request to add out-of-tree kernel header build support to --kernelsrc
option? I think we will also need additional options maybe: --kernelsrc
and --kernelout
?
from adeb.
Hi,
I try the methods of @Linuxuser4 provide as follows,the bcc compilation on target board success.
-
A softlink to stdc++ was required since compilation complained of missing stdc++ library.
ln -s /usr/lib/gcc/aarch64-linux-gnu/7/libstdc++.so /usr/lib/libstdc++.so -
Two include paths needed to be provided to avoid missing header error. These were added in CMakeLists.txt in the base folder:
include_directories(/usr/include/c++/7/)
include_directories(/usr/include/aarch64-linux-gnu/c++/7/)
When run the command "funclatency do_sys_open" generate Issue 1: Headers are missing on the target device, but I don't know how to solve this problem.
root@localhost:/# funclatency do_sys_open
In file included from :2:
In file included from /virtual/include/bcc/bpf.h:12:
In file included from include/linux/types.h:5:
include/uapi/linux/types.h:4:10: fatal error: 'asm/types.h' file not found
#include <asm/types.h>
^~~~~~~~~~~~~
1 error generated.
Traceback (most recent call last):
File "/usr/share/bcc/tools/funclatency", line 206, in
b = BPF(text=bpf_text)
File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 318, in init
raise Exception("Failed to compile BPF text")
Exception: Failed to compile BPF text
from adeb.
I enabled adeb on x86 android platform. The issue is resolved in:
https://github.com/iotcg/adeb/tree/develop.
You can check the git log to find how to set the right environment variable to resolve these issues.
from adeb.
Yes, I have changed the source code in bashrc.common as follow:
#WA for library link issue
LIBRARY_PATH=${LIBRARY_PATH}:/usr/lib/gcc/aarch64-linux-gnu/7/
export LIBRARY_PATH=${LIBRARY_PATH}:/usr/lib/aarch64-linux-gnu/
#WA for include path issue
CPATH=${CPATH}:/usr/include/c++/7
export CPATH=${CPATH}:/usr/include/aarch64-linux-gnu/c++/7
#WA for kernel include files on arm64 device
export CPATH=${CPATH}:/kernel-headers/include
cat /proc/cpuinfo | grep -q aarch64 2>/dev/null
rst=$?
if [ $rst -eq 0 ]
then
CPATH=${CPATH}:/kernel-headers/arch/arm64/include/generated
export CPATH=${CPATH}:/kernel-headers/arch/arm64/include/generated/uapi
fi
The bcc compilation also failed, is my kernel config issue?
-- Configuring done
-- Generating done
-- Build files have been written to: /bcc-master/build
Scanning dependencies of target bpf-static
Scanning dependencies of target bpf-shared
Scanning dependencies of target bcc-loader-static
[ 1%] Building C object src/cc/CMakeFiles/bpf-static.dir/libbpf.c.o
[ 1%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf.c.o
[ 2%] Building CXX object src/cc/CMakeFiles/bcc-loader-static.dir/bcc_syms.cc.o
In file included from /bcc-master/src/cc/libbpf.c:22:
In file included from /usr/include/fcntl.h:35:
In file included from /usr/include/aarch64-linux-gnu/bits/fcntl.h:61:
In file included from /usr/include/aarch64-linux-gnu/bits/fcntl-linux.h:346:
/kernel-headers/include/linux/falloc.h:12:2: error: unknown type name '__s16'
__s16 l_type;
In file included from /bcc-master/src/cc/libbpf.c:22:
In file included from /usr/include/fcntl.h:35:
In file included from /usr/include/aarch64-linux-gnu/bits/fcntl.h:61:
^In file included from /usr/include/aarch64-linux-gnu/bits/fcntl-linux.h
:346:
/kernel-headers/include/linux/falloc.h:12:2: error: unknown type name '__s16'
__s16 l_type;
^
/kernel-headers/include/linux/falloc.h/kernel-headers/include/linux/falloc.h:13:2: :error: unknown type name '__s16'
__s16 l_whence;13:2: error: unknown type name '__s16'
__s16 l_whence;
...
fatal error: too many errors emitted, stopping now [-ferror-limit=]
13 warnings and 20 errors generated.
make[2]: *** [src/cc/CMakeFiles/bpf-shared.dir/build.make:63: src/cc/CMakeFiles/bpf-shared.dir/libbpf.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:158: src/cc/CMakeFiles/bpf-shared.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
from adeb.
It's kernel head file issues.
Two suspect points:
- Some kernel head files are not copied into kernel-headers.
- Need more specific CPATH to include the directory to tell gcc/clang to find the header file.
BTW, you can refer to below file to generate kernel-headers:
https://github.com/iotcg/adeb/blob/develop/kernel-headers.sh
As you know, we often build kernel out of kernel source directory, e.g. build_kernel.
You can put kernel-header.sh under build_kernel and run the script, it will generate kernel-headers directory which includes all the required kernel head files.
from adeb.
from adeb.
@joelagnel Glad to see your fix, waiting for PR. I also want to know how to resolve "library link issue" & "include head file issue" besides my method.
from adeb.
Actually, the issue I was talking about is different. Your compilation could be failing because of incorrect 'kernel-headers' as you pointed:
/kernel-headers/include/linux/falloc.h:12:2: error: unknown type name '__s16'
Erick is working on removing dependency on kernel headers. His prototype is already working but it has to be merged. It will be merged either today or tomorrow. After that the following command should work:
“adeb prepare --build --bcc`
We will update you today or tomorrow. Thanks for the patience and for your help in making Androdeb better.
from adeb.
CC @ErickReyesR
from adeb.
Also as I was saying, we will also provide "backup" kernel headers incase --kernelsrc
option is skipped which @ErickReyesR is working on.
from adeb.
@joelagnel Per your request, PR: #13
This PR has been verified on local host and target device. It supports extract kernel headers when building kernel out-of-tree.
from adeb.
At the moment, I feel out-of-tree header building will complicate the flow too much. Also we have eliminated the need for kernel version as long as you are running a recent LTS kernel (headers will be automatically downloaded). For that reason, I am closing this. Thanks
from adeb.
Related Issues (20)
- Tracing user space functions outside the chroot
- eBPF C: cannot use strcmp and strncmp HOT 2
- `adeb prepare` or `adeb prepare --full` download failed HOT 1
- can not find /data/androdeb/run
- Got failed for building arm32 arch bcc HOT 3
- What is the "supported" Android kernel with `CONFIG_IKHEADERS`? HOT 1
- Exception: Failed to compile BPF module <text> HOT 1
- Failed to run some commands HOT 2
- why have aosp removed adeb?
- bpftrace uprobe pthread_create on android adeb env HOT 1
- suggestion for supporting bpftrace HOT 2
- Question: Should I be able to execute AOSP binaries via the adeb shell? HOT 3
- Have this supported Android11 with kernel-5.4? HOT 1
- `/apex` isn't mounted HOT 1
- Why are there so many '[unknown]' address info while using uprobe?
- adeb prepare advertises --distro flag but doesn't accept it HOT 7
- Support Debian Bullseye HOT 3
- how to build with su environment? HOT 1
- /data/androdeb/run: can't execute: Permission denied
- i used ./adeb prepare --archive '/home/android/Downloads/androdeb-fs.tgz.zip' and run adeb shell error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adeb.