host linux version 4.4.154 target:firefly rk3399 (arm64)
I cross-compile gator on host use
make -C /home/emel/arm-project/linux-kernel/kernel M=`pwd` ARCH=arm64 CROSS_COMPILE=/opt/gcc-linaro-4.9-2016.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- GATOR_WITH_MALI_SUPPORT=MALI_MIDGARD MALI_DIR_MIDGARD=/home/emel/arm-project/linux-kernel/kernel/drivers/gpu/arm/midgard/ modules
the errors follow:
make: Entering directory '/home/emel/arm-project/linux-kernel/kernel'CC [M] /home/emel/arm-project/gator/driver/gator_main.oIn file included from /home/emel/arm-project/gator/driver/gator_main.c:270:0:/home/emel/arm-project/gator/driver/gator_backtrace.c: In function 'report_trace':/home/emel/arm-project/gator/driver/gator_backtrace.c:64:33: error: 'struct module' has no member named 'module_core'(unsigned long)mod->module_core;
In file included from /home/emel/arm-project/gator/driver/gator_main.c:270:0:/home/emel/arm-project/gator/driver/gator_backtrace.c: In function 'report_trace':/home/emel/arm-project/gator/driver/gator_backtrace.c:64:33: error: 'struct module' has no member named 'module_core'(unsigned long)mod->module_core;^/home/emel/arm-project/gator/driver/gator_backtrace.c: In function 'kernel_backtrace':/home/emel/arm-project/gator/driver/gator_backtrace.c:105:21: warning: passing argument 1 of 'walk_stackframe' from incompatible pointer typeerror, forbidden warning:gator_backtrace.c:105walk_stackframe(&frame, report_trace, &depth);^In file included from /home/emel/arm-project/gator/driver/gator_backtrace.c:34:0,from /home/emel/arm-project/gator/driver/gator_main.c:270:./arch/arm64/include/asm/stacktrace.h:31:13: note: expected 'struct task_struct *' but argument is of type 'struct stackframe *'extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame,^In file included from /home/emel/arm-project/gator/driver/gator_main.c:270:0:/home/emel/arm-project/gator/driver/gator_backtrace.c:105:29: warning: passing argument 2 of 'walk_stackframe' from incompatible pointer typeerror, forbidden warning:gator_backtrace.c:105walk_stackframe(&frame, report_trace, &depth);^In file included from /home/emel/arm-project/gator/driver/gator_backtrace.c:34:0,from /home/emel/arm-project/gator/driver/gator_main.c:270:./arch/arm64/include/asm/stacktrace.h:31:13: note: expected 'struct stackframe *' but argument is of type 'int (*)(struct stackframe *, void *)'extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame,^In file included from /home/emel/arm-project/gator/driver/gator_main.c:270:0:/home/emel/arm-project/gator/driver/gator_backtrace.c:105:43: warning: passing argument 3 of 'walk_stackframe' from incompatible pointer typeerror, forbidden warning:gator_backtrace.c:105walk_stackframe(&frame, report_trace, &depth);^In file included from /home/emel/arm-project/gator/driver/gator_backtrace.c:34:0,from /home/emel/arm-project/gator/driver/gator_main.c:270:./arch/arm64/include/asm/stacktrace.h:31:13: note: expected 'int (*)(struct stackframe *, void *)' but argument is of type 'int *'extern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame,^In file included from /home/emel/arm-project/gator/driver/gator_main.c:270:0:/home/emel/arm-project/gator/driver/gator_backtrace.c:105:5: error: too few arguments to function 'walk_stackframe'walk_stackframe(&frame, report_trace, &depth);^In file included from /home/emel/arm-project/gator/driver/gator_backtrace.c:34:0,from /home/emel/arm-project/gator/driver/gator_main.c:270:./arch/arm64/include/asm/stacktrace.h:31:13: note: declared hereextern void walk_stackframe(struct task_struct *tsk, struct stackframe *frame,^scripts/Makefile.build:277: recipe for target '/home/emel/arm-project/gator/driver/gator_main.o' failedmake[1]: *** [/home/emel/arm-project/gator/driver/gator_main.o] Error 1Makefile:1474: recipe for target '_module_/home/emel/arm-project/gator/driver' failedmake: *** [_module_/home/emel/arm-project/gator/driver] Error 2make: Leaving directory '/home/emel/arm-project/linux-kernel/kernel'
I read source code gator_backtrace.c:
60 if (mod) {61 cookie = get_cookie(cpu, current, mod->name, false);62 addr = addr -63 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)64 (unsigned long)mod->module_core;65 #else66 (unsigned long)mod->core_layout.base;67 #endif68 }69 else {70 cookie = NO_COOKIE;71 }72 #endif
...
102 #if defined(__aarch64__) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)103 walk_stackframe(current, &frame, report_trace, &depth);104 #else105 walk_stackframe(&frame, report_trace, &depth);106 #endif
so is it because linux kernel version not match ?
so I change KERNEL_VERSION(4, 5, 0) instead of KERNEL_VERSION(4, 4, 0)
It can make successfully.
after that i copy gator.ko to rk3399 and insmod .but fail.
unknown symbol in module .
dmesg: unknown symbol walk_stackframe(err 0)
so do I make some mistake with my operation above ? shold I change KERNEL_VERSION(4, 5, 0) ? or where is walk_stackframe ?
thanks very much!
Hi,
But I add gator module code inside driver of rk3399 (Kernel version 4.4) and it gives compile error, which require to modify gator exactly same as what emel did. When I check the header file arch/arm64/include/asm/stacktrace.h in rk3399 kernel (version 4.4) it has 4 inputs not 3 inputs and so reauire to change:
to this:
102 #if defined(__aarch64__) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)103 walk_stackframe(current, &frame, report_trace, &depth);104 #else105 walk_stackframe(&frame, report_trace, &depth);106 #endif
To match with the defined function in Linux header! It resolve the compile error but when I try to compile gator module out of the tree, it give warning:
WARNING: "walk_stackframe" [../gator.ko] undefined.
And I guess it may not work well or may even not load correctly.
PS: I am using kernel inside AOSP of Rockpi n10 board:
https://gitlab.com/rk-vendor/rk/kernel/-/tree/rk3399pro-toybrick-stable
Best regards,
Ehsan