diff mbox series

[bpf-next,2/3] libbpf: skip BTF fixup if object file has no BTF

Message ID 20210319205909.1748642-3-andrii@kernel.org (mailing list archive)
State Accepted
Delegated to: BPF
Headers show
Series Handle no-BTF object files better | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers fail 1 blamed authors not CCed: ast@kernel.org; 6 maintainers not CCed: yhs@fb.com kpsingh@kernel.org kafai@fb.com ast@kernel.org john.fastabend@gmail.com songliubraving@fb.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Andrii Nakryiko March 19, 2021, 8:59 p.m. UTC
Skip BTF fixup step when input object file is missing BTF altogether.

Reported-by: Jiri Olsa <jolsa@redhat.com>
Fixes: 8fd27bf69b86 ("libbpf: Add BPF static linker BTF and BTF.ext support")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/lib/bpf/linker.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jiri Olsa March 19, 2021, 9:25 p.m. UTC | #1
On Fri, Mar 19, 2021 at 01:59:08PM -0700, Andrii Nakryiko wrote:
> Skip BTF fixup step when input object file is missing BTF altogether.
> 
> Reported-by: Jiri Olsa <jolsa@redhat.com>
> Fixes: 8fd27bf69b86 ("libbpf: Add BPF static linker BTF and BTF.ext support")
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

Tested-by: Jiri Olsa <jolsa@redhat.com>

thanks for the quick fix,
jirka

> ---
>  tools/lib/bpf/linker.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c
> index b4fff912dce2..5e0aa2f2c0ca 100644
> --- a/tools/lib/bpf/linker.c
> +++ b/tools/lib/bpf/linker.c
> @@ -1313,6 +1313,9 @@ static int linker_fixup_btf(struct src_obj *obj)
>  	struct src_sec *sec;
>  	int i, j, n, m;
>  
> +	if (!obj->btf)
> +		return 0;
> +
>  	n = btf__get_nr_types(obj->btf);
>  	for (i = 1; i <= n; i++) {
>  		struct btf_var_secinfo *vi;
> -- 
> 2.30.2
>
diff mbox series

Patch

diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c
index b4fff912dce2..5e0aa2f2c0ca 100644
--- a/tools/lib/bpf/linker.c
+++ b/tools/lib/bpf/linker.c
@@ -1313,6 +1313,9 @@  static int linker_fixup_btf(struct src_obj *obj)
 	struct src_sec *sec;
 	int i, j, n, m;
 
+	if (!obj->btf)
+		return 0;
+
 	n = btf__get_nr_types(obj->btf);
 	for (i = 1; i <= n; i++) {
 		struct btf_var_secinfo *vi;