gobpfer / gobpfer

Serial experiments ebpf
0 stars 0 forks source link

BPF backend bypasses VFS overlay #2

Open mejedi opened 1 month ago

mejedi commented 1 month ago

VFS overlay (-vfsoverlay, sparsely documented in llvm's llvm/include/llvm/Support/VirtualFileSystem.h) enables clang to consume files from a "virtual filesystem image". An image is defined in a yaml file, e.g.:

{
  'version': 0,
  'roots': [
    { 'name': 'foobar', 'type': 'directory',
      'contents': [
        { 'name': 'input.c', 'type': 'file',
          'external-contents': 'b.c',
        }
      ]
    }
  ]
}

Unconventionally, BPF backend reads the source files to embed source code in bpf object (to improve verifier error diagnostics). It bypasses the VFS overlay and fails to find foobar/input.c. End result: no source code embedded / worse error diagnostics.

mejedi commented 1 month ago

We intend to build an improved bpf2go tool. Major features

We need to identify source code files, package them somehow and ship into a Docker container. An idea I was toying with was to use a VFS overlay.

Instead we could just render a filesystem tree in /tmp, which might be a better option (this bug, -vfsoverlay missing in older clangs).