linux-next: build warning after merge of the bpf-next tree
Subsystems (3)
Hi all,
After merging the bpf-next tree, today's linux-next build (powerpc ppc64_defconfig) produced this warning:
WARNING: 2 bad relocationsc000000001998a48 R_PPC64_ADDR64 _binary__btf_vmlinux_bin_startc000000001998a50 R_PPC64_ADDR64 _binary__btf_vmlinux_bin_end
Introduced by commit
8580ac9404f6 ("bpf: Process in-kernel BTF")
Signature · 2 lines
Cheers, Stephen Rothwell
Quoted 8 lines · Stephen Rothwell
Hi all,
After merging the bpf-next tree, today's linux-next build (powerpc
ppc64_defconfig) produced this warning:WARNING: 2 bad relocations
c000000001998a48R_PPC64_ADDR64_binary__btf_vmlinux_bin_startc000000001998a50R_PPC64_ADDR64_binary__btf_vmlinux_bin_end
Can ppc folks help me figure out what this warning means?
Hi all,
Quoted 6 lines · On Fri, 18 Oct 2019 10:56:57 +1100 Stephen Rothwell <[email protected]>…
Hi all,
After merging the bpf-next tree, today's linux-next build (powerpc
ppc64_defconfig) produced this warning:
Quoted 7 lines
WARNING: 2 bad relocations
c000000001998a48R_PPC64_ADDR64_binary__btf_vmlinux_bin_startc000000001998a50R_PPC64_ADDR64_binary__btf_vmlinux_bin_endIntroduced by commit
8580ac9404f6("bpf: Process in-kernel BTF")
This warning now appears in the net-next tree build.
Signature · 2 lines
Cheers, Stephen Rothwell
Hi guys,
Quoted 8 lines · Stephen Rothwell
Hi all,
Quoted 5 lines · On Fri, 18 Oct 2019 10:56:57 +1100 Stephen Rothwell <[email protected]>…
Hi all,
After merging the bpf-next tree, today's linux-next build (powerpc
ppc64_defconfig) produced this warning:
Quoted 10 lines
Quoted 7 lines
WARNING: 2 bad relocations
c000000001998a48R_PPC64_ADDR64_binary__btf_vmlinux_bin_startc000000001998a50R_PPC64_ADDR64_binary__btf_vmlinux_bin_endIntroduced by commit
8580ac9404f6 ("bpf: Process in-kernel BTF")This warning now appears in the net-next tree build.
I bump that thread up because Zong also noticed that 2 new relocations for those symbols appeared in my riscv relocatable kernel branch following that commit.
I also noticed 2 new relocations R_AARCH64_ABS64 appearing in arm64 kernel.
Those 2 weak undefined symbols have existed since commit 341dfcf8d78e ("btf: expose BTF info through sysfs") but this is the fact to declare those symbols into btf.c that produced those relocations.
I'm not sure what this all means, but this is not something I expected for riscv for a kernel linked with -shared/-fpie. Maybe should we just leave them to zero ?
I think that deserves a deeper look if someone understands all this better than I do.
Alex
Quoted 32 lines · Alexandre Ghiti
Hi guys,
Quoted 8 lines · Stephen Rothwell
Hi all,
Quoted 5 lines · On Fri, 18 Oct 2019 10:56:57 +1100 Stephen Rothwell <[email protected]>…
Hi all,
After merging the bpf-next tree, today's linux-next build (powerpc
ppc64_defconfig) produced this warning:Quoted 10 lines
Quoted 7 lines
WARNING: 2 bad relocations
c000000001998a48R_PPC64_ADDR64_binary__btf_vmlinux_bin_startc000000001998a50R_PPC64_ADDR64_binary__btf_vmlinux_bin_endIntroduced by commit
8580ac9404f6 ("bpf: Process in-kernel BTF")This warning now appears in the net-next tree build.
I bump that thread up because Zong also noticed that 2 new relocations for those symbols appeared in my riscv relocatable kernel branch following that commit.
I also noticed 2 new relocations
R_AARCH64_ABS64appearing in arm64 kernel.Those 2 weak undefined symbols have existed since commit
341dfcf8d78e("btf: expose BTF info through sysfs") but this is the fact to declare those symbols intobtf.cthat produced those relocations.
Quoted 7 lines
I'm not sure what this all means, but this is not something I expected for riscv for
a kernel linked with -shared/-fpie. Maybe should we just leave them to zero ?I think that deserves a deeper look if someone understands all this better than I do.
Are you saying there is a warning for arm64 as well? Can ppc folks explain the above warning?
What does it mean "2 bad relocations"?
The code is doing:
extern char __weak _binary__btf_vmlinux_bin_start[]; extern char __weak _binary__btf_vmlinux_bin_end[]; Since they are weak they should be zero when not defined. What's the issue?
Quoted 32 lines · Alexei Starovoitov
Quoted 31 lines · Alexandre Ghiti
Hi guys,
Quoted 8 lines · Stephen Rothwell
Hi all,
Quoted 5 lines · On Fri, 18 Oct 2019 10:56:57 +1100 Stephen Rothwell <[email protected]>…
Hi all,
After merging the bpf-next tree, today's linux-next build (powerpc
ppc64_defconfig) produced this warning:Quoted 10 lines
Quoted 7 lines
WARNING: 2 bad relocations
c000000001998a48R_PPC64_ADDR64_binary__btf_vmlinux_bin_startc000000001998a50R_PPC64_ADDR64_binary__btf_vmlinux_bin_endIntroduced by commit
8580ac9404f6 ("bpf: Process in-kernel BTF")This warning now appears in the net-next tree build.
I bump that thread up because Zong also noticed that 2 new relocations for those symbols appeared in my riscv relocatable kernel branch following that commit.
I also noticed 2 new relocations
R_AARCH64_ABS64appearing in arm64 kernel.Those 2 weak undefined symbols have existed since commit
341dfcf8d78e("btf: expose BTF info through sysfs") but this is the fact to declare those symbols intobtf.cthat produced those relocations.
Quoted 8 lines
Quoted 7 lines
I'm not sure what this all means, but this is not something I expected for riscv for
a kernel linked with -shared/-fpie. Maybe should we just leave them to zero ?I think that deserves a deeper look if someone understands all this better than I do.
Are you saying there is a warning for arm64 as well?
Nop.
Quoted 2 lines
Can ppc folks explain the above warning? What does it mean "2 bad relocations"?
This is what I'd like to understand too, it is not clear in the ppc tool that outputs this message why it is considered 'bad'.
Quoted 5 lines
The code is doing:
extern char__weak_binary__btf_vmlinux_bin_start[]; extern char__weak_binary__btf_vmlinux_bin_end[]; Since they are weak they should be zero when not defined. What's the issue?
There likely is no issue, I just want to make sure those relocations are legitimate and I want to understand what we should do with those.
At the moment arm64 does not relocate those at runtime and purely ignore them: is this the right thing to do ?
Quoted 31 lines · On Fri, 10 Jan 2020 14:28:17 PST (-0800), [email protected] wrote:
Hi guys,
Quoted 8 lines · Stephen Rothwell
Hi all,
Quoted 5 lines · On Fri, 18 Oct 2019 10:56:57 +1100 Stephen Rothwell <[email protected]>…
Hi all,
After merging the bpf-next tree, today's linux-next build (powerpc
ppc64_defconfig) produced this warning:Quoted 10 lines
Quoted 7 lines
WARNING: 2 bad relocations
c000000001998a48R_PPC64_ADDR64_binary__btf_vmlinux_bin_startc000000001998a50R_PPC64_ADDR64_binary__btf_vmlinux_bin_endIntroduced by commit
8580ac9404f6 ("bpf: Process in-kernel BTF")This warning now appears in the net-next tree build.
I bump that thread up because Zong also noticed that 2 new relocations for those symbols appeared in my riscv relocatable kernel branch following that commit.
I also noticed 2 new relocations
R_AARCH64_ABS64appearing in arm64 kernel.Those 2 weak undefined symbols have existed since commit
341dfcf8d78e("btf: expose BTF info through sysfs") but this is the fact to declare those symbols intobtf.cthat produced those relocations.
Quoted 7 lines
I'm not sure what this all means, but this is not something I expected for riscv for
a kernel linked with -shared/-fpie. Maybe should we just leave them to zero ?I think that deserves a deeper look if someone understands all this better than I do.
Can you give me a pointer to your tree and how to build a relocatable kernel? Weak undefined symbols have the absolute value 0, but the kernel is linked at an address such that 0 can't be reached by normal means. When I added support to binutils for this I did it in a way that required almost no code -- essetially I just stopped dissallowing x0 as a possible base register for PCREL relocations, which results in 0 always being accessible. I just wanted to get the kernel to build again, so I didn't worry about chasing around all the addressing modes. The PIC/PIE support generates different relocations and I wouldn't be surprised if I just missed one (or more likely all) of them.
It's probably a simple fix, though I feel like every time I say that about the linker I end up spending a month in there...
Quoted 37 lines · Palmer Dabbelt
Quoted 36 lines · On Fri, 10 Jan 2020 14:28:17 PST (-0800), [email protected] wrote:
Hi guys,
Quoted 8 lines · Stephen Rothwell
Hi all,
Quoted 5 lines · On Fri, 18 Oct 2019 10:56:57 +1100 Stephen Rothwell <[email protected]>…
Hi all,
After merging the bpf-next tree, today's linux-next build (powerpc
ppc64_defconfig) produced this warning:Quoted 10 lines
Quoted 7 lines
WARNING: 2 bad relocations
c000000001998a48R_PPC64_ADDR64_binary__btf_vmlinux_bin_startc000000001998a50R_PPC64_ADDR64_binary__btf_vmlinux_bin_endIntroduced by commit
8580ac9404f6("bpf: Process in-kernel BTF")This warning now appears in the net-next tree build.
I bump that thread up because Zong also noticed that 2 new relocations for those symbols appeared in my riscv relocatable kernel branch following that commit.
I also noticed 2 new relocations
R_AARCH64_ABS64appearing in arm64 kernel.Those 2 weak undefined symbols have existed since commit
341dfcf8d78e("btf: expose BTF info through sysfs") but this is the fact to declare those symbols intobtf.cthat produced those relocations.I'm not sure what this all means, but this is not something I expected for riscv for
a kernel linked with -shared/-fpie. Maybe should we just leave them to zero ?
Quoted 5 lines
Quoted 2 lines
I think that deserves a deeper look if someone understands all this better than I do.
Can you give me a pointer to your tree and how to build a relocatable kernel? Weak undefined symbols have the absolute value 0,
So according to you the 2 new relocations R_RISCV_64 are normal and should not be modified at runtime right ?
Quoted 11 lines
but the kernel is linked at
an address such that 0 can't be reached by normal means. When I added support to binutils for this I did it in a way that required almost no code -- essetially I just stopped dissallowing x0 as a possible base register for PCREL relocations, which results in 0 always being accessible. I just wanted to get the kernel to build again, so I didn't worry about chasing around all the addressing modes. The PIC/PIE support generates different relocations and I wouldn't be surprised if I just missed one (or more likely all) of them.It's probably a simple fix, though I feel like every time I say that about the linker I end up spending a month in there...
You can find it here:
https://github.com/AlexGhiti/riscv-linux/tree/int/alex/riscv_relocatable_v1
Zong fixed the bug introduced by those 2 new relocations and everything works like a charm, so I'm not sure you have to dig in the linker :)
Alex
Quoted 73 lines · Alexandre Ghiti
Quoted 40 lines · Palmer Dabbelt
Quoted 39 lines · On Fri, 10 Jan 2020 14:28:17 PST (-0800), [email protected] wrote:
Hi guys,
Quoted 9 lines · Stephen Rothwell
Hi all,
Quoted 5 lines · On Fri, 18 Oct 2019 10:56:57 +1100 Stephen Rothwell <[email protected]>…
Hi all,
After merging the bpf-next tree, today's linux-next build (powerpc
ppc64_defconfig) produced this warning:Quoted 10 lines
Quoted 7 lines
WARNING: 2 bad relocations
c000000001998a48R_PPC64_ADDR64_binary__btf_vmlinux_bin_startc000000001998a50R_PPC64_ADDR64_binary__btf_vmlinux_bin_endIntroduced by commit
8580ac9404f6 ("bpf: Process in-kernel BTF")This warning now appears in the net-next tree build.
I bump that thread up because Zong also noticed that 2 new relocations for
those symbols appeared in my riscv relocatable kernel branch following that commit.I also noticed 2 new relocations
R_AARCH64_ABS64appearing in arm64 kernel.Those 2 weak undefined symbols have existed since commit
341dfcf8d78e("btf: expose BTF info through sysfs") but this is the fact to declare those symbols intobtf.cthat produced those relocations.I'm not sure what this all means, but this is not something I expected for riscv for
a kernel linked with -shared/-fpie. Maybe should we just leave them to zero ?Quoted 6 lines
Quoted 2 lines
I think that deserves a deeper look if someone understands all this better than I do.
Can you give me a pointer to your tree and how to build a relocatable kernel?
Weak undefined symbols have the absolute value 0,So according to you the 2 new relocations
R_RISCV_64are normal and should not
be modified at runtime right ?Quoted 13 lines
but the kernel is linked at
an address such that 0 can't be reached by normal means. When I added support
to binutils for this I did it in a way that required almost no code -- essetially I just stopped dissallowing x0 as a possible base register for PCREL
relocations, which results in 0 always being accessible. I just wanted to get
the kernel to build again, so I didn't worry about chasing around all the addressing modes. The PIC/PIE support generates different relocations and I
wouldn't be surprised if I just missed one (or more likely all) of them.Quoted 3 lines
It's probably a simple fix, though I feel like every time I say that about the
linker I end up spending a month in there...
Quoted 8 lines
You can find it here:
https://github.com/AlexGhiti/riscv-linux/tree/int/alex/riscv_relocatable_v1
Zong fixed the bug introduced by those 2 new relocations and everything works
like a charm, so I'm not sure you have to dig in the linker :)
I'm not quite familiar with btf, so I have no idea why there are two weak symbols be added in 8580ac9404f6 ("bpf: Process in-kernel BTF") as well, According on relocation mechanism, maybe it is unnecessary to handle weak undefined symbol at this time, because there is no substantive help to relocate the absolute value 0. I just simply ignore the non-relative relocation types to make processing can go forward, and it works for me based on v5.5-rc5.
Quoted 2 lines
Alex
Quoted 3 lines · Zong Li
I'm not quite familiar with btf, so I have no idea why there are two weak symbols be added in
8580ac9404f6("bpf: Process in-kernel BTF")
I can explain what these weak symbols are for, but that won't change the fact that compiler or linker are buggy. The weak symbols should work in all cases and compiler should pick correct relocation.
In this case it sounds that compiler picked relative relocation and failed to reach zero from that address.
Quoted 8 lines · Alexei Starovoitov
Quoted 2 lines · Zong Li
I'm not quite familiar with btf, so I have no idea why there are two weak symbols be added in
8580ac9404f6("bpf: Process in-kernel BTF")I can explain what these weak symbols are for, but that won't change the fact that compiler or linker are buggy. The weak symbols should work in all cases and compiler should pick correct relocation.
In this case it sounds that compiler picked relative relocation and failed to reach zero from that address.
Sorry for the response delay: I now agree that there is nothing weird about those relocations. All compiler/linker I took a look at (arm64, ppc64 and riscv64) correctly emit an absolute relocation to the address 0 in case of a weak unresolved symbol, so there's no buggy compiler/linker.
And regarding ppc warning, the kernel being compiled as -pie, the scripts looks for absolute relocations which it considers as "bad", except for one that is known to be weak and that is ignored: I have just sent a patch to fix this script so that weak undefined symbol relocations are not considered as bad.
Thanks,
Alex