ebpf icon indicating copy to clipboard operation
ebpf copied to clipboard

btf: Pointer.Size is incorrect on arches with 32 bit pointers

Open lmb opened this issue 2 years ago • 0 comments

We currently hardcode pointer size: https://github.com/cilium/ebpf/blob/9447ec825af0802d63ea2d74523536f99622bb59/btf/types.go#L149

The kernel uses sizeof(void*) instead. That size depends on which data model is used.The correct size of Pointer in Go land is actually unsafe.Sizeof(uintptr(0)), but we can't use that directly. We may read BTF generated on a 32 bit pointer arch on a 64 bit pointer arch and vice versa.

It would be nice if we could reject parsing BTF with a different pointer size, or add "proper" support for differing pointer sizes. (What would that look like though?)

lmb avatar Mar 07 '23 15:03 lmb