Skip to content

libbpf-rs: Fix BTF int offset extraction from aux word#1367

Open
cuiweixie wants to merge 1 commit intolibbpf:masterfrom
cuiweixie:fix/btf-int-offset-shift
Open

libbpf-rs: Fix BTF int offset extraction from aux word#1367
cuiweixie wants to merge 1 commit intolibbpf:masterfrom
cuiweixie:fix/btf-int-offset-shift

Conversation

@cuiweixie
Copy link
Copy Markdown

What

Correct the shift applied after masking bits 16–23 of the BTF KIND_INT auxiliary u32 when building Int::offset. The mask 0x00_ff_00_00 must be paired with a shift of 16, not 24, so the field matches the layout used by BTF_INT_ENCODING in the kernel UAPI.

Why

With shift 24, the masked value was decoded from the wrong bit positions, so Int::offset did not reflect the encoded offset.

The auxiliary u32 for BTF_KIND_INT packs several fields; the offset lives
in bits 16–23 (see BTF_INT_ENCODING in the kernel UAPI). After masking
with 0x00_ff_00_00, shifting by 24 decodes the wrong bit range, so
Int::offset was effectively wrong. Shift by 16 to align the mask with
the documented layout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant