• Joe Stringer's avatar
    bpf, selftest: test global data/bss/rodata sections · b915ebe6
    Joe Stringer authored
    Add tests for libbpf relocation of static variable references
    into the .data, .rodata and .bss sections of the ELF, also add
    read-only test for .rodata. All passing:
    
      # ./test_progs
      [...]
      test_global_data:PASS:load program 0 nsec
      test_global_data:PASS:pass global data run 925 nsec
      test_global_data_number:PASS:relocate .bss reference 925 nsec
      test_global_data_number:PASS:relocate .data reference 925 nsec
      test_global_data_number:PASS:relocate .rodata reference 925 nsec
      test_global_data_number:PASS:relocate .bss reference 925 nsec
      test_global_data_number:PASS:relocate .data reference 925 nsec
      test_global_data_number:PASS:relocate .rodata reference 925 nsec
      test_global_data_number:PASS:relocate .bss reference 925 nsec
      test_global_data_number:PASS:relocate .bss reference 925 nsec
      test_global_data_number:PASS:relocate .rodata reference 925 nsec
      test_global_data_number:PASS:relocate .rodata reference 925 nsec
      test_global_data_number:PASS:relocate .rodata reference 925 nsec
      test_global_data_string:PASS:relocate .rodata reference 925 nsec
      test_global_data_string:PASS:relocate .data reference 925 nsec
      test_global_data_string:PASS:relocate .bss reference 925 nsec
      test_global_data_string:PASS:relocate .data reference 925 nsec
      test_global_data_string:PASS:relocate .bss reference 925 nsec
      test_global_data_struct:PASS:relocate .rodata reference 925 nsec
      test_global_data_struct:PASS:relocate .bss reference 925 nsec
      test_global_data_struct:PASS:relocate .rodata reference 925 nsec
      test_global_data_struct:PASS:relocate .data reference 925 nsec
      test_global_data_rdonly:PASS:test .rodata read-only map 925 nsec
      [...]
      Summary: 229 PASSED, 0 FAILED
    
    Note map helper signatures have been changed to avoid warnings
    when passing in const data.
    
    Joint work with Daniel Borkmann.
    Signed-off-by: default avatarJoe Stringer <joe@wand.net.nz>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
    Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    b915ebe6
global_data.c 4.15 KB