Fixing string literal relocations in IOVisor's uBPF
While spending time learning more about eBPF, I integrated IOVisor's uBPF
(Userspace eBPF) with FD.io VPP for fun. I quickly came across the problem that
uBPF didn't like the ELF object file's produced by Clang.
On investigation, I found that while these object contained .text sections with
eBPF byte code as you would expect, it was also introducing ELF relocations for
functions and string literals what uBPF couldn't interpret.Turns out that uBPF's
support for ELF relocations for string literals and functions both need some
work. I wrote PR #102 which fixes the most obvious problems with string
literals. It copies the rodata sections containing the string literals onto the
heap, and then reads the relocation sections and updates pointers in the eBPF
byte code to point to the string literals, just before the eBPF byte itself is
interpreted into x86 byte code.
There is a long standing bug #18 raised against uBPF that talks through most of
the gory details.
eBPF uBPF