selftests/bpf: Test pointers in arena and .bss.addr_space.1

The initial values of variables in arena point to other variables in arena:

  pointer       points to
  ------------  -------------------------------------------
  px            an int
  parr          the third element of an array
  head, next    the elements of a list
  pbig          an element of an array in .bss.addr_space.1
  psx           a static int
  psbig         an element of a static array in .bss.addr_space.1

The prog and user space must see the same pointers:
 - The prog follows each pointer and examines the value that it finds.
 - User space compares px, parr, head and next with the addresses in the
   skeleton.
 - User space reads through pbig, psx and psbig the values that the prog
   stored there. Static variables are not in the skeleton.

The selftests link each object with the static linker. Thus the object with
psx and psbig does not build without the change in linker.c.

The variables in .bss.addr_space.1 must be zero and aligned, and the object
file must be smaller than these variables. The size of .addr_space.1 is not
a multiple of the alignment, thus libbpf must align the second section.

A second object has a pointer in arena to a variable that is not in arena.
The open of this object must fail.

The test is serial, as the other tests in prog_tests/arena_*.c. See commit
a14f9ba080c1 ("selftests/bpf: Run arena tests serially").

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261104012401.1354861-8-alexei.starovoitov@gmail.com
4 files changed