bpf: fix is_allow_list section
authorJames Hilliard <james.hilliard1@gmail.com>
Mon, 1 Aug 2022 01:11:47 +0000 (01:11 +0000)
committerLennart Poettering <lennart@poettering.net>
Wed, 3 Aug 2022 14:24:10 +0000 (16:24 +0200)
commite8b1e9cf1095f9d6d0f1e2dce2503e25fec2e6c5
treedd9647cd50b08e5a17355e198404b31e163b8a6e
parent00852912edc69e652f4932fa536da60528f08ed3
bpf: fix is_allow_list section

The llvm bpf compiler appears to place const volatile variables in
a non-standard section which creates an incompatibility with the gcc
bpf compiler.

To fix this force GCC to also use the rodata section.

Note this does emit an assembler warning:
Generating src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.unstripped.o with a custom command
/tmp/ccM2b7jP.s: Assembler messages:
/tmp/ccM2b7jP.s:87: Warning: setting incorrect section attributes for .rodata

See:
https://github.com/llvm/llvm-project/issues/56468

Fixes:
../src/core/restrict-ifaces.c:45:14: error: ‘struct
restrict_ifaces_bpf’ has no member named ‘rodata’; did you mean
‘data’?
   45 |         obj->rodata->is_allow_list = is_allow_list;
      |              ^~~~~~
      |              data
src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.c