* [PATCH bpf-next] selftests/bpf: define string const as global for test_sysctl_prog.c
@ 2020-09-10 20:27 Yonghong Song
2020-09-10 21:56 ` Andrii Nakryiko
2020-09-11 3:03 ` Alexei Starovoitov
0 siblings, 2 replies; 3+ messages in thread
From: Yonghong Song @ 2020-09-10 20:27 UTC (permalink / raw)
To: bpf, netdev; +Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team
When tweaking llvm optimizations, I found that selftest build failed
with the following error:
libbpf: elf: skipping unrecognized data section(6) .rodata.str1.1
libbpf: prog 'sysctl_tcp_mem': bad map relo against '.L__const.is_tcp_mem.tcp_mem_name'
in section '.rodata.str1.1'
Error: failed to open BPF object file: Relocation failed
make: *** [/work/net-next/tools/testing/selftests/bpf/test_sysctl_prog.skel.h] Error 255
make: *** Deleting file `/work/net-next/tools/testing/selftests/bpf/test_sysctl_prog.skel.h'
The local string constant "tcp_mem_name" is put into '.rodata.str1.1' section
which libbpf cannot handle. Using untweaked upstream llvm, "tcp_mem_name"
is completely inlined after loop unrolling.
Commit 7fb5eefd7639 ("selftests/bpf: Fix test_sysctl_loop{1, 2}
failure due to clang change") solved a similar problem by defining
the string const as a global. Let us do the same here
for test_sysctl_prog.c so it can weather future potential llvm changes.
Signed-off-by: Yonghong Song <yhs@fb.com>
---
tools/testing/selftests/bpf/progs/test_sysctl_prog.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/test_sysctl_prog.c b/tools/testing/selftests/bpf/progs/test_sysctl_prog.c
index 50525235380e..5489823c83fc 100644
--- a/tools/testing/selftests/bpf/progs/test_sysctl_prog.c
+++ b/tools/testing/selftests/bpf/progs/test_sysctl_prog.c
@@ -19,11 +19,11 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
+const char tcp_mem_name[] = "net/ipv4/tcp_mem";
static __always_inline int is_tcp_mem(struct bpf_sysctl *ctx)
{
- char tcp_mem_name[] = "net/ipv4/tcp_mem";
unsigned char i;
- char name[64];
+ char name[sizeof(tcp_mem_name)];
int ret;
memset(name, 0, sizeof(name));
--
2.24.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: define string const as global for test_sysctl_prog.c
2020-09-10 20:27 [PATCH bpf-next] selftests/bpf: define string const as global for test_sysctl_prog.c Yonghong Song
@ 2020-09-10 21:56 ` Andrii Nakryiko
2020-09-11 3:03 ` Alexei Starovoitov
1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2020-09-10 21:56 UTC (permalink / raw)
To: Yonghong Song
Cc: bpf, Networking, Alexei Starovoitov, Daniel Borkmann, Kernel Team
On Thu, Sep 10, 2020 at 1:30 PM Yonghong Song <yhs@fb.com> wrote:
>
> When tweaking llvm optimizations, I found that selftest build failed
> with the following error:
> libbpf: elf: skipping unrecognized data section(6) .rodata.str1.1
> libbpf: prog 'sysctl_tcp_mem': bad map relo against '.L__const.is_tcp_mem.tcp_mem_name'
> in section '.rodata.str1.1'
> Error: failed to open BPF object file: Relocation failed
> make: *** [/work/net-next/tools/testing/selftests/bpf/test_sysctl_prog.skel.h] Error 255
> make: *** Deleting file `/work/net-next/tools/testing/selftests/bpf/test_sysctl_prog.skel.h'
>
> The local string constant "tcp_mem_name" is put into '.rodata.str1.1' section
> which libbpf cannot handle. Using untweaked upstream llvm, "tcp_mem_name"
> is completely inlined after loop unrolling.
>
> Commit 7fb5eefd7639 ("selftests/bpf: Fix test_sysctl_loop{1, 2}
> failure due to clang change") solved a similar problem by defining
> the string const as a global. Let us do the same here
> for test_sysctl_prog.c so it can weather future potential llvm changes.
>
> Signed-off-by: Yonghong Song <yhs@fb.com>
> ---
Acked-by: Andrii Nakryiko <andriin@fb.com>
> tools/testing/selftests/bpf/progs/test_sysctl_prog.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/test_sysctl_prog.c b/tools/testing/selftests/bpf/progs/test_sysctl_prog.c
> index 50525235380e..5489823c83fc 100644
> --- a/tools/testing/selftests/bpf/progs/test_sysctl_prog.c
> +++ b/tools/testing/selftests/bpf/progs/test_sysctl_prog.c
> @@ -19,11 +19,11 @@
> #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
> #endif
>
> +const char tcp_mem_name[] = "net/ipv4/tcp_mem";
nit: I'd prefer keeping an empty line between variables and functions
> static __always_inline int is_tcp_mem(struct bpf_sysctl *ctx)
> {
> - char tcp_mem_name[] = "net/ipv4/tcp_mem";
> unsigned char i;
> - char name[64];
> + char name[sizeof(tcp_mem_name)];
> int ret;
>
> memset(name, 0, sizeof(name));
> --
> 2.24.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: define string const as global for test_sysctl_prog.c
2020-09-10 20:27 [PATCH bpf-next] selftests/bpf: define string const as global for test_sysctl_prog.c Yonghong Song
2020-09-10 21:56 ` Andrii Nakryiko
@ 2020-09-11 3:03 ` Alexei Starovoitov
1 sibling, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2020-09-11 3:03 UTC (permalink / raw)
To: Yonghong Song
Cc: bpf, Network Development, Alexei Starovoitov, Daniel Borkmann,
Kernel Team
On Thu, Sep 10, 2020 at 1:27 PM Yonghong Song <yhs@fb.com> wrote:
>
> When tweaking llvm optimizations, I found that selftest build failed
> with the following error:
> libbpf: elf: skipping unrecognized data section(6) .rodata.str1.1
> libbpf: prog 'sysctl_tcp_mem': bad map relo against '.L__const.is_tcp_mem.tcp_mem_name'
> in section '.rodata.str1.1'
> Error: failed to open BPF object file: Relocation failed
> make: *** [/work/net-next/tools/testing/selftests/bpf/test_sysctl_prog.skel.h] Error 255
> make: *** Deleting file `/work/net-next/tools/testing/selftests/bpf/test_sysctl_prog.skel.h'
>
> The local string constant "tcp_mem_name" is put into '.rodata.str1.1' section
> which libbpf cannot handle. Using untweaked upstream llvm, "tcp_mem_name"
> is completely inlined after loop unrolling.
>
> Commit 7fb5eefd7639 ("selftests/bpf: Fix test_sysctl_loop{1, 2}
> failure due to clang change") solved a similar problem by defining
> the string const as a global. Let us do the same here
> for test_sysctl_prog.c so it can weather future potential llvm changes.
>
> Signed-off-by: Yonghong Song <yhs@fb.com>
Applied. Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-11 3:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 20:27 [PATCH bpf-next] selftests/bpf: define string const as global for test_sysctl_prog.c Yonghong Song
2020-09-10 21:56 ` Andrii Nakryiko
2020-09-11 3:03 ` Alexei Starovoitov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.