Skip to content

fix: prevent clang from emitting memset calls - #92

Open
gemesa wants to merge 1 commit into
SeeFlowerX:devfrom
gemesa:memset-fix
Open

gemesa wants to merge 1 commit into
SeeFlowerX:devfrom
gemesa:memset-fix

Conversation

@gemesa

@gemesa gemesa commented Nov 8, 2026

Copy link
Copy Markdown

Fixes #91

str_val is a 256 char byte array so clang assumes 1 byte alignment. Filling it takes 256 single byte stores and this is over the eBPF backend’s limit so LLVM uses a memset call instead. Older clang managed it somehow without calling memset but clang 23 does not.

The memory is already 8 byte aligned in practice because map values are:

https://github.com/torvalds/linux/blob/v6.1/kernel/bpf/hashtab.c#L128
https://github.com/torvalds/linux/blob/v6.1/kernel/bpf/hashtab.c#L1042

We just need to let clang know about this also by adding the attribute.

After this fix, there are no memset references and the program can be loaded.

$ llvm-readelf -s user/assets/syscall.o user/assets/stack.o | grep memset

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.

LLVM 23: unresolved memset breaks eBPF loading

1 participant