Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elf: Add support for map struct typedef #1125

Merged
merged 2 commits into from
Oct 10, 2023
Merged

Conversation

anjmao
Copy link

@anjmao anjmao commented Aug 31, 2023

Fixes #1126

@anjmao anjmao force-pushed the typedef-struct branch 2 times, most recently from e7778b1 to 36e1eb1 Compare August 31, 2023 11:19
Copy link
Collaborator

@lmb lmb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work with libbpf?

elf_reader.go Outdated
@@ -750,7 +750,12 @@ func (ec *elfCode) loadBTFMaps() error {
// Each Var representing a BTF map definition contains a Struct.
mapStruct, ok := v.Type.(*btf.Struct)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using https://pkg.go.dev/github.com/cilium/ebpf/btf#UnderlyingType here is more appropriate.

@anjmao
Copy link
Author

anjmao commented Sep 12, 2023

Does this work with libbpf?

Yes, typedefs are used in some tracee ebpf code places. It uses libbpf and libbpfgo cgo wrapper. It's great that this was the only needed change to migrate such large ebpf code base to cilium/ebpf.

@lmb
Copy link
Collaborator

lmb commented Sep 12, 2023

I forgot: can you add a test in loader.c for this behaviour?

@lmb lmb force-pushed the typedef-struct branch 2 times, most recently from 16841c3 to ee441ef Compare October 3, 2023 09:23
Accept typedef'd structs in addition to regular anonymous structs.

Fixes cilium#1126

Signed-off-by: anjmao <andzej@cast.ai>
Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
@lmb lmb changed the title Add support for map struct typedef elf: Add support for map struct typedef Oct 10, 2023
@lmb lmb merged commit ccd0b88 into cilium:main Oct 10, 2023
12 checks passed
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.

Add support for map struct typedef #1125
2 participants