mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
libbpf: Don't error out on CO-RE relos for overriden weak subprogs
[ Upstream commite89d57d938
] During BPF static linking, all the ELF relocations and .BTF.ext information (including CO-RE relocations) are preserved for __weak subprograms that were logically overriden by either previous weak subprogram instance or by corresponding "strong" (non-weak) subprogram. This is just how native user-space linkers work, nothing new. But libbpf is over-zealous when processing CO-RE relocation to error out when CO-RE relocation belonging to such eliminated weak subprogram is encountered. Instead of erroring out on this expected situation, log debug-level message and skip the relocation. Fixes:db2b8b0642
("libbpf: Support CO-RE relocations for multi-prog sections") Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20220408181425.2287230-2-andrii@kernel.org Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
d47f85cc01
commit
049a44dfd6
@ -5238,10 +5238,17 @@ bpf_object__relocate_core(struct bpf_object *obj, const char *targ_btf_path)
|
|||||||
insn_idx = rec->insn_off / BPF_INSN_SZ;
|
insn_idx = rec->insn_off / BPF_INSN_SZ;
|
||||||
prog = find_prog_by_sec_insn(obj, sec_idx, insn_idx);
|
prog = find_prog_by_sec_insn(obj, sec_idx, insn_idx);
|
||||||
if (!prog) {
|
if (!prog) {
|
||||||
pr_warn("sec '%s': failed to find program at insn #%d for CO-RE offset relocation #%d\n",
|
/* When __weak subprog is "overridden" by another instance
|
||||||
sec_name, insn_idx, i);
|
* of the subprog from a different object file, linker still
|
||||||
err = -EINVAL;
|
* appends all the .BTF.ext info that used to belong to that
|
||||||
goto out;
|
* eliminated subprogram.
|
||||||
|
* This is similar to what x86-64 linker does for relocations.
|
||||||
|
* So just ignore such relocations just like we ignore
|
||||||
|
* subprog instructions when discovering subprograms.
|
||||||
|
*/
|
||||||
|
pr_debug("sec '%s': skipping CO-RE relocation #%d for insn #%d belonging to eliminated weak subprogram\n",
|
||||||
|
sec_name, i, insn_idx);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
/* no need to apply CO-RE relocation if the program is
|
/* no need to apply CO-RE relocation if the program is
|
||||||
* not going to be loaded
|
* not going to be loaded
|
||||||
|
Loading…
Reference in New Issue
Block a user