From e7778b1c9845050a8bb5ed2fdc3276904273154d Mon Sep 17 00:00:00 2001 From: anjmao Date: Thu, 31 Aug 2023 14:18:10 +0300 Subject: [PATCH] Add support for map struct typedef Signed-off-by: Andzej Maciusovic andzej.maciusovic@gmail.com --- elf_reader.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/elf_reader.go b/elf_reader.go index 209f6748f..c07889995 100644 --- a/elf_reader.go +++ b/elf_reader.go @@ -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) if !ok { - return fmt.Errorf("expected struct, got %s", v.Type) + if mapTypedef, isTypeDef := v.Type.(*btf.Typedef); isTypeDef { + mapStruct, ok = mapTypedef.Type.(*btf.Struct) + } + if !ok { + return fmt.Errorf("expected struct, got %s", v.Type) + } } mapSpec, err := mapSpecFromBTF(sec, &vs, mapStruct, ec.btf, name, false)