Skip to content

Commit

Permalink
Add support for map struct typedef
Browse files Browse the repository at this point in the history
Signed-off-by: Andzej Maciusovic [email protected]
  • Loading branch information
anjmao committed Aug 31, 2023
1 parent 01ebd4c commit e7778b1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion elf_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e7778b1

Please sign in to comment.