Blob Blame History Raw
From: Alexei Starovoitov <ast@kernel.org>
Date: Wed, 27 Nov 2019 17:46:56 -0800
Subject: libbpf: Fix sym->st_value print on 32-bit arches
Git-commit: 7c3977d1e80401b1a25efded698b05d60ee26e31
References: bsc#1158962
Patch-mainline: v5.5-rc1
Signed-off-by: Tony Jones <tonyj@suse.de>
X-Info: adjust for context, no be18010ea2d83c184cc32afdc895410a1cf2cbd5, no 1f8e2bcb2cd5ee1a731fb625a5438e2c305f6a7c

The st_value field is a 64-bit value and causing this error on 32-bit arches:

In file included from libbpf.c:52:
libbpf.c: In function 'bpf_program__record_reloc':
libbpf_internal.h:59:22: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'Elf64_Addr' {aka 'const long long unsigned int'} [-Werror=format=]

Fix it with (__u64) cast.

Fixes: 1f8e2bcb2cd5 ("libbpf: Refactor relocation handling")
Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

NOTE (Gary Lin): Refresh this patch after applying 1f8e2bcb2cd5
---
 tools/lib/bpf/libbpf.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1813,7 +1813,7 @@ static int bpf_program__record_reloc(str
 			return -LIBBPF_ERRNO__RELOC;
 		}
 		if (sym->st_value % 8) {
-			pr_warning("bad call relo offset: %lu\n", sym->st_value);
+			pr_warning("bad call relo offset: %llu\n", (__u64)sym->st_value);
 			return -LIBBPF_ERRNO__RELOC;
 		}
 		reloc_desc->type = RELO_CALL;