On Wed, Nov 27, 2019 at 10:19 AM Yonghong Song <yhs@xxxxxx> wrote: > > > > On 11/26/19 10:01 PM, Andrii Nakryiko wrote: > > Similarly to a0d7da26ce86 ("libbpf: Fix call relocation offset calculation > > bug"), relocations against global variables need to take into account > > referenced symbol's st_value, which holds offset into a corresponding data > > section (and, subsequently, offset into internal backing map). For static > > variables this offset is always zero and data offset is completely described > > by respective instruction's imm field. > > > > Convert a bunch of selftests to global variables. Previously they were relying > > on `static volatile` trick to ensure Clang doesn't inline static variables, > > which with global variables is not necessary anymore. > > > > Fixes: 393cdfbee809 ("libbpf: Support initialized global variables") > > Signed-off-by: Andrii Nakryiko <andriin@xxxxxx> > > LGTM with a few nits below. > Good points, I was too laser-focused. Updated in v2, thanks! > Acked-by: Yonghong Song <yhs@xxxxxx> > > > --- > > tools/lib/bpf/libbpf.c | 40 +++++++++---------- > > .../testing/selftests/bpf/progs/fentry_test.c | 12 +++--- > > .../selftests/bpf/progs/fexit_bpf2bpf.c | 6 +-- > > .../testing/selftests/bpf/progs/fexit_test.c | 12 +++--- > > tools/testing/selftests/bpf/progs/test_mmap.c | 4 +- > > 5 files changed, 35 insertions(+), 39 deletions(-) > > [...]