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

Unable to build kernel #8

Open
dnffabs opened this issue Nov 26, 2023 · 1 comment
Open

Unable to build kernel #8

dnffabs opened this issue Nov 26, 2023 · 1 comment

Comments

@dnffabs
Copy link

dnffabs commented Nov 26, 2023

Hello, I tried to build libtea on the kali system of Raspberry PI 4B(ARM-v8A), but when I used make operation to build the kernel in the module folder, I got the following error:

make -C /lib/modules/5.15.44-Re4son-v8l+/build M=/home/kali/Desktop/frameworks-master/libtea/module clean
make[1]: Entering directory '/usr/src/linux-headers-5.15.44-Re4son-v8l+'
make[1]: Leaving directory '/usr/src/linux-headers-5.15.44-Re4son-v8l+'
make -C /lib/modules/5.15.44-Re4son-v8l+/build M=/home/kali/Desktop/frameworks-master/libtea/module modules
make[1]: Entering directory '/usr/src/linux-headers-5.15.44-Re4son-v8l+'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc (Debian 11.2.0-19) 11.2.0
You are using: gcc (Debian 10.2.0-16) 10.2.0
CC [M] /home/kali/Desktop/frameworks-master/libtea/module/libtea.o
/home/kali/Desktop/frameworks-master/libtea/module/libtea.c:10:49: warning: "LIBTEA_WINDOWS" is not defined, evaluates to 0 [-Wundef]
10 | #if defined(i386) || defined(x86_64) || LIBTEA_WINDOWS
| ^~~~~~~~~~~~~~
/home/kali/Desktop/frameworks-master/libtea/module/libtea.c: In function ‘get_system_reg’:
/home/kali/Desktop/frameworks-master/libtea/module/libtea.c:123:7: warning: unused variable ‘err’ [-Wunused-variable]
123 | int err;
| ^~~
/home/kali/Desktop/frameworks-master/libtea/module/libtea.c:122:22: warning: unused variable ‘msr_val’ [-Wunused-variable]
122 | unsigned long long msr_val;
| ^~~~~~~
/home/kali/Desktop/frameworks-master/libtea/module/libtea.c: In function ‘set_system_reg’:
/home/kali/Desktop/frameworks-master/libtea/module/libtea.c:152:7: warning: unused variable ‘err’ [-Wunused-variable]
152 | int err;
| ^~~
/home/kali/Desktop/frameworks-master/libtea/module/libtea.c: In function ‘libtea_ioctl’:
/home/kali/Desktop/frameworks-master/libtea/module/libtea.c:744:13: warning: "LIBTEA_ARM" is not defined, evaluates to 0 [-Wundef]
744 | #elif LIBTEA_ARM
| ^~~~~~~~~~
/home/kali/Desktop/frameworks-master/libtea/module/libtea.c:589:8: warning: unused variable ‘ret’ [-Wunused-variable]
589 | long ret;
| ^~~
/home/kali/Desktop/frameworks-master/libtea/module/libtea.c:588:11: warning: unused variable ‘handler’ [-Wunused-variable]
588 | ioctl_t handler = NULL;
| ^~~~~~~
/home/kali/Desktop/frameworks-master/libtea/module/libtea.c:587:8: warning: unused variable ‘data’ [-Wunused-variable]
587 | char data[256];
| ^~~~
libtea.c: Assembler messages:
libtea.c:481: Error: constant expression required
/tmp/ccV9l290.s:483: Info: macro invoked from here
libtea.c:650: Error: constant expression required
/tmp/ccV9l290.s:652: Info: macro invoked from here
make[2]: *** [scripts/Makefile.build:288: /home/kali/Desktop/frameworks-master/libtea/module/libtea.o] Error 1
make[1]: *** [Makefile:1868: /home/kali/Desktop/frameworks-master/libtea/module] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.44-Re4son-v8l+'
make: *** [Makefile:13: linux] Error 2

@cattius
Copy link
Collaborator

cattius commented Dec 3, 2023

Hi, did you run make directly in the kernel module folder, or did you use one of the AArch64 make commands in the README (running it in the top-level libtea folder)? There are different files used in the build process for each architecture (including the headers that define LIBTEA_WINDOWS and LIBTEA_ARM). The commands are libtea-aarch64-basic, libtea-aarch64-cache, and libtea-aarch64-paging - all three will build the kernel module together with the libtea header, but with different features included. The paging command will compile the most-feature complete version.

Some other tips:

  • If you get 'file not found' errors for the kernel development headers, you'll need to install them - I'm not sure which package they're in for Kali, but you should find them by searching in your package manager (or Googling). This is distro-specific - I just tried this on an EC2 instance running Amazon Linux, for example, and needed to run sudo yum install -y wget kernel-devel-$(uname -r) kernel-headers-$(uname -r) ($(uname -r) gets your current kernel version).
  • The Makefile assumes that the main use case for AArch64 will be cross-compiling for Android devices, so to compile to run directly on your Raspberry Pi, comment out the AARCH64_RECIPE = android line near the top of the Makefile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants