[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190212050113.qkryxb34vpnst6w6@ast-mbp>
Date: Mon, 11 Feb 2019 21:01:15 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Joe Stringer <joe@...d.net.nz>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org, daniel@...earbox.net,
ast@...nel.org
Subject: Re: [PATCH bpf-next 4/4] selftests/bpf: Test static data relocation
On Mon, Feb 11, 2019 at 04:47:29PM -0800, Joe Stringer wrote:
> Add tests for libbpf relocation of static variable references into the
> .data and .bss sections of the ELF.
>
> Signed-off-by: Joe Stringer <joe@...d.net.nz>
...
> +#define __fetch(x) (__u32)(&(x))
> +
> +static __u32 static_bss = 0; /* Reloc reference to .bss section */
> +static __u32 static_data = 42; /* Reloc reference to .data section */
> +
> +/**
> + * Load a u32 value from a static variable into a map, for the userland test
> + * program to validate.
> + */
> +SEC("static_data_load")
> +int load_static_data(struct __sk_buff *skb)
> +{
> + __u32 key, value;
> +
> + key = 0;
> + value = __fetch(static_bss);
If we proceed with this approach we will not be able to add support
for normal 'value = static_bss;' C code in the future.
Let's figure out the way to do it right from the start.
Support for global and static variables is must have feature to add asap,
but let's not cut the corner like this.
We did such hacks in the past and every time it came back to bite us.
Powered by blists - more mailing lists