undefined symbol in modpost "zero"
Ben Dooks
ben.dooks at codethink.co.uk
Fri Dec 23 08:38:46 PST 2022
I'm getting the following error from modpost:
ERROR: modpost: "zero" [arch/riscv/kvm/kvm.ko] undefined!
ERROR: modpost: "zero" [drivers/gpu/drm/drm.ko] undefined!
ERROR: modpost: "zero" [drivers/nvme/host/nvme.ko] undefined!
ERROR: modpost: "zero" [drivers/i2c/algos/i2c-algo-bit.ko] undefined!
This seems to be coming from arch/riscv/include/asm/jump_label.h
with the arch_static_branch_jump() assembling some code:
> 40 {
> 41 asm_volatile_goto(
> 42 " .option push \n\t"
> 43 " .option norelax \n\t"
> 44 " .option norvc \n\t"
> 45 "1: jal zero, %l[label] \n\t"
> 46 " .option pop \n\t"
> 47 " .pushsection __jump_table, \"aw\" \n\t"
> 48 " .align " RISCV_LGPTR " \n\t"
> 49 " .long 1b - ., %l[label] - . \n\t"
> 50 " " RISCV_PTR " %0 - . \n\t"
> 51 " .popsection \n\t"
> 52 : : "i"(&((char *)key)[branch]) : : label);
> 53
> 54 return false;
> 55 label:
> 56 return true;
> 57 }
>
Changing the jal zero to jal x0 doesn't fix it, it just comes up with
"x0" being undefined.
gcc version 12.2.0 (Debian 12.2.0-9)
GNU assembler version 2.39.50 (riscv64-linux-gnu) using BFD version (GNU
Binutils for Debian) 2.39.50.20221208
I suspect this is a gas bug where it means to assemble a J instruction
to the label without outputting the unused symbol "zero" into the symbol
table. Is the right thing to fix gas, or can the kernel be changed?
FYI:
tmp.s:
1 .text
2
3 1:
4 jal zero, 1b
produces:
0000000000000000 <.L1^B1>:
0: 0000006f j 0 <.L1^B1>
0: R_RISCV_JAL .L1^B1
and
$ riscv64-linux-gnu-nm -a tmp.o
0000000000000000 b .bss
0000000000000000 d .data
0000000000000000 n .riscv.attributes
0000000000000000 t .text
U zero
Current fix is to:
diff --git a/arch/riscv/include/asm/jump_label.h
b/arch/riscv/include/asm/jump_label.h
index 6d58bbb5da46..a4abbacd0b62 100644
--- a/arch/riscv/include/asm/jump_label.h
+++ b/arch/riscv/include/asm/jump_label.h
@@ -42,7 +42,7 @@ static __always_inline bool
arch_static_branch_jump(struct static_key * const ke
" .option push \n\t"
" .option norelax \n\t"
" .option norvc \n\t"
- "1: jal zero, %l[label] \n\t"
+ "1: j %l[label] \n\t"
" .option pop \n\t"
" .pushsection __jump_table, \"aw\" \n\t"
" .align " RISCV_LGPTR " \n\t"
This fixes modpost, not sure if this should be applied or not.
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
https://www.codethink.co.uk/privacy.html
More information about the linux-riscv
mailing list