From: Alexei Starovoitov The format strings of bpf_printk() moved from .rodata to .rodata.str for one reason. .arena.data moved .rodata into arena, and helpers cannot read strings from arena. .arena.data is removed. Move the strings back to .rodata. As a result, an object that has its own .rodata has one map less. This reverts commit 373e1223ff00 ("libbpf: Keep format strings of bpf_printk() in .rodata.str"). libbpf 1.8.0 has the strings in .rodata. Signed-off-by: Alexei Starovoitov --- tools/lib/bpf/bpf_helpers.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h index b37b727ef216..9d160b5b9c0e 100644 --- a/tools/lib/bpf/bpf_helpers.h +++ b/tools/lib/bpf/bpf_helpers.h @@ -248,21 +248,13 @@ enum libbpf_tristate { #define ___bpf_fill(arr, args...) \ ___bpf_apply(___bpf_fill, ___bpf_narg(args))(arr, 0, args) -/* - * Format strings are in a section of their own. When global data of the object - * is in arena (the object has .arena.data section) libbpf keeps .rodata.str* - * sections in read-only maps, which is where helpers and kfuncs take strings - * from. - */ -#define ___bpf_fmt_sec __attribute__((section(".rodata.str"))) - /* * BPF_SEQ_PRINTF to wrap bpf_seq_printf to-be-printed values * in a structure. */ #define BPF_SEQ_PRINTF(seq, fmt, args...) \ ({ \ - static const char ___fmt[] ___bpf_fmt_sec = fmt; \ + static const char ___fmt[] = fmt; \ unsigned long long ___param[___bpf_narg(args)]; \ \ _Pragma("GCC diagnostic push") \ @@ -280,7 +272,7 @@ enum libbpf_tristate { */ #define BPF_SNPRINTF(out, out_size, fmt, args...) \ ({ \ - static const char ___fmt[] ___bpf_fmt_sec = fmt; \ + static const char ___fmt[] = fmt; \ unsigned long long ___param[___bpf_narg(args)]; \ \ _Pragma("GCC diagnostic push") \ @@ -295,7 +287,7 @@ enum libbpf_tristate { #ifdef BPF_NO_GLOBAL_DATA #define BPF_PRINTK_FMT_MOD #else -#define BPF_PRINTK_FMT_MOD static const ___bpf_fmt_sec +#define BPF_PRINTK_FMT_MOD static const #endif #define __bpf_printk(fmt, ...) \ @@ -311,7 +303,7 @@ enum libbpf_tristate { */ #define __bpf_vprintk(fmt, args...) \ ({ \ - static const char ___fmt[] ___bpf_fmt_sec = fmt; \ + static const char ___fmt[] = fmt; \ unsigned long long ___param[___bpf_narg(args)]; \ \ _Pragma("GCC diagnostic push") \ @@ -325,7 +317,7 @@ enum libbpf_tristate { #define bpf_stream_printk(stream_id, fmt, args...) \ ({ \ - static const char ___fmt[] ___bpf_fmt_sec = fmt; \ + static const char ___fmt[] = fmt; \ unsigned long long ___param[___bpf_narg(args)]; \ \ _Pragma("GCC diagnostic push") \ -- 2.55.0