Commit 8f40a9b
btf: Avoid weak external references
commit fc5eb4a upstream.
If the BTF code is enabled in the build configuration, the start/stop
BTF markers are guaranteed to exist. Only when CONFIG_DEBUG_INFO_BTF=n,
the references in btf_parse_vmlinux() will remain unsatisfied, relying
on the weak linkage of the external references to avoid breaking the
build.
Avoid GOT based relocations to these markers in the final executable by
dropping the weak attribute and instead, make btf_parse_vmlinux() return
ERR_PTR(-ENOENT) directly if CONFIG_DEBUG_INFO_BTF is not enabled to
begin with. The compiler will drop any subsequent references to
__start_BTF and __stop_BTF in that case, allowing the link to succeed.
Note that Clang will notice that taking the address of __start_BTF can
no longer yield NULL, so testing for that condition becomes unnecessary.
Signed-off-by: Ard Biesheuvel <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Signed-off-by: Juxin Gao <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Acked-by: Arnd Bergmann <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Binbin Zhou <[email protected]>1 parent a725701 commit 8f40a9b
2 files changed
+8
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5579 | 5579 | | |
5580 | 5580 | | |
5581 | 5581 | | |
5582 | | - | |
5583 | | - | |
| 5582 | + | |
| 5583 | + | |
5584 | 5584 | | |
5585 | 5585 | | |
5586 | 5586 | | |
| |||
5729 | 5729 | | |
5730 | 5730 | | |
5731 | 5731 | | |
| 5732 | + | |
| 5733 | + | |
| 5734 | + | |
5732 | 5735 | | |
5733 | 5736 | | |
5734 | 5737 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
0 commit comments