support per-map/prog selinux context and cross .o map sharing

Tested by making the map struct conditional on #define V18,
and only #defining that in the top line of netd.c,
this results in:

$ objdump -s -j size_of_bpf_map_def out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/net_shared/clatd.o
out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/net_shared/clatd.o:     file format elf64-little
Contents of section size_of_bpf_map_def:
 0000 30000000 00000000                    0.......

$ objdump -s -j size_of_bpf_prog_def out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/net_shared/clatd.o
out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/net_shared/clatd.o:     file format elf64-little
Contents of section size_of_bpf_prog_def:
 0000 1c000000 00000000                    ........

$ objdump -s -j size_of_bpf_map_def out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/netd_shared/netd.o
out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/netd_shared/netd.o:     file format elf64-little
Contents of section size_of_bpf_map_def:
 0000 74000000 00000000                    t.......

$ objdump -s -j size_of_bpf_prog_def out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/netd_shared/netd.o
out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/netd_shared/netd.o:     file format elf64-little
Contents of section size_of_bpf_prog_def:
 0000 5c000000 00000000                    \.......

$ echo $[0x00000030] $[0x00000074]
48 116

$ echo $[0x0000001c] $[0x0000005c]
28 92

and it still successfully boots.
So the struct extension infrastructure works as desired.

Bug: 218408035
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8b55769e69dbf9580e844f2a50d48651fd9a0cff
1 file changed
tree: 4be50982363e83025514c9c7350ed6311d59d0bf
  1. staticlibs/