-
Notifications
You must be signed in to change notification settings - Fork 128
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
Error in compiling #21
Comments
Hi Pascal, The eBPF JIT-compiler in this repo is for x86_64 CPU architecture, which means that it is not compatible with ARM processors such as the one on your Pi. There is little to be done I'm afraid, except writing a new JIT-compiler for ARM (there is one in the Linux kernel, but it is under GPL so it cannot be merged here). The other thing you could do is try to compile without the JIT-compiler, and use only the interpreter for running your programs. Best of luck! |
Hello, @qmonnet 's comment is true, but the real issue is here I think.
These casts are not valid on your platform I think. This cast is valid on X86-64 platforms because sizeof(void *) equals to sizeof(uint64_t). I guess on your platform, this is not the case.
This program makes clear that. Please try this and show us an output. |
Hi, Output of the program is false |
Sorry, I updated my comment but its ok. It seems in your platform, there is a mismatch between the sizeof(uint64_t) and sizeof(void *) and unfortunately, currently ubpf is not aware of such platform. The quick solution is removing -Werror in the Makefile. It just "works" I think. Does anyone have idea to correctly solve this? |
I thought for a while and now I think using uintptr_t for pointer arithmetic may work. At least int-to-pointer-cast warning doesn't appear. |
@PascalHf - Does @YutaroHayakawa's suggestion solve your issue? |
The Problem is the pointer arithmetic, like @YutaroHayakawa said. Removing -Werror does not fix the whole Problem. I removed some code to compile the programm but I did not try if it does work as it should now because I switched to another Architecture. |
@PascalHf is this still an issue? If not, I will resolve this PR. |
Hi guys,
I am very happy to find your Repo here and tried to install the uBPF on Raspberry Pi 3 with Ubuntu Xenial today.
After installing the requirements and using make -C vm I get this Error:
ubpf_vm.c: In function ‘ubpf_exec’:
ubpf_vm.c:369:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.src] + inst.offset, size, "load", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:381:13: note: in expansion of macro ‘BOUNDS_CHECK_LOAD’
BOUNDS_CHECK_LOAD(4);
^
ubpf_vm.c:369:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.src] + inst.offset, size, "load", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:385:13: note: in expansion of macro ‘BOUNDS_CHECK_LOAD’
BOUNDS_CHECK_LOAD(2);
^
ubpf_vm.c:369:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.src] + inst.offset, size, "load", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:389:13: note: in expansion of macro ‘BOUNDS_CHECK_LOAD’
BOUNDS_CHECK_LOAD(1);
^
ubpf_vm.c:369:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.src] + inst.offset, size, "load", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:393:13: note: in expansion of macro ‘BOUNDS_CHECK_LOAD’
BOUNDS_CHECK_LOAD(8);
^
ubpf_vm.c:375:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.dst] + inst.offset, size, "store", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:398:13: note: in expansion of macro ‘BOUNDS_CHECK_STORE’
BOUNDS_CHECK_STORE(4);
^
ubpf_vm.c:375:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.dst] + inst.offset, size, "store", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:402:13: note: in expansion of macro ‘BOUNDS_CHECK_STORE’
BOUNDS_CHECK_STORE(2);
^
ubpf_vm.c:375:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.dst] + inst.offset, size, "store", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:406:13: note: in expansion of macro ‘BOUNDS_CHECK_STORE’
BOUNDS_CHECK_STORE(1);
^
ubpf_vm.c:375:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.dst] + inst.offset, size, "store", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:410:13: note: in expansion of macro ‘BOUNDS_CHECK_STORE’
BOUNDS_CHECK_STORE(8);
^
ubpf_vm.c:375:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.dst] + inst.offset, size, "store", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:415:13: note: in expansion of macro ‘BOUNDS_CHECK_STORE’
BOUNDS_CHECK_STORE(4);
^
ubpf_vm.c:375:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.dst] + inst.offset, size, "store", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:419:13: note: in expansion of macro ‘BOUNDS_CHECK_STORE’
BOUNDS_CHECK_STORE(2);
^
ubpf_vm.c:375:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.dst] + inst.offset, size, "store", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:423:13: note: in expansion of macro ‘BOUNDS_CHECK_STORE’
BOUNDS_CHECK_STORE(1);
^
ubpf_vm.c:375:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
if (!bounds_check((void *)reg[inst.dst] + inst.offset, size, "store", cur_pc, mem, mem_len, stack)) {
^
ubpf_vm.c:427:13: note: in expansion of macro ‘BOUNDS_CHECK_STORE’
BOUNDS_CHECK_STORE(8);
^
After a closer look into the Code I tried to put an & before reg like this in line 369 and 375:
if (!bounds_check((void *)®[inst.src] + inst.offset, size, "load", cur_pc, mem, mem_len, stack)) { \
if (!bounds_check((void *)®[inst.dst] + inst.offset, size, "store", cur_pc, mem, mem_len, stack)) { \
I think it gets me a step further but I have the next Error:
cc -Wall -Werror -Iinc -O2 -g -c -o ubpf_vm.o ubpf_vm.c
cc -Wall -Werror -Iinc -O2 -g -c -o ubpf_jit_x86_64.o ubpf_jit_x86_64.c
cc -Wall -Werror -Iinc -O2 -g -c -o ubpf_loader.o ubpf_loader.c
ar rc libubpf.a ubpf_vm.o ubpf_jit_x86_64.o ubpf_loader.o
cc -Wall -Werror -Iinc -O2 -g -c -o test.o test.c
/tmp/ccdsP4py.s: Assembler messages:
/tmp/ccdsP4py.s:82: Error: ARM register expected --
mov $0xf0,%rax' /tmp/ccdsP4py.s:82: Error: ARM register expected --
mov $0xf1,%rcx'/tmp/ccdsP4py.s:82: Error: ARM register expected --
mov $0xf2,%rdx' /tmp/ccdsP4py.s:82: Error: ARM register expected --
mov $0xf3,%rsi'/tmp/ccdsP4py.s:82: Error: ARM register expected --
mov $0xf4,%rdi' /tmp/ccdsP4py.s:82: Error: ARM register expected --
mov $0xf5,%r8'/tmp/ccdsP4py.s:82: Error: ARM register expected --
mov $0xf6,%r9' /tmp/ccdsP4py.s:82: Error: ARM register expected --
mov $0xf7,%r10'/tmp/ccdsP4py.s:82: Error: ARM register expected -- `mov $0xf8,%r11'
: recipe for target 'test.o' failed
make: *** [test.o] Error 1
I am very new to Linux and tried to change from GCC to Clang but get the same result.
Do you have a way to fix it?
Thanks
Pascal
The text was updated successfully, but these errors were encountered: