diff --git a/lib/bpf.c b/lib/bpf.c index d093d0bd..45f279fa 100644 --- a/lib/bpf.c +++ b/lib/bpf.c @@ -1758,11 +1758,13 @@ static const char *bpf_map_fetch_name(struct bpf_elf_ctx *ctx, int which) int i; for (i = 0; i < ctx->sym_num; i++) { + int type = GELF_ST_TYPE(sym.st_info); + if (gelf_getsym(ctx->sym_tab, i, &sym) != &sym) continue; if (GELF_ST_BIND(sym.st_info) != STB_GLOBAL || - GELF_ST_TYPE(sym.st_info) != STT_NOTYPE || + (type != STT_NOTYPE && type != STT_OBJECT) || sym.st_shndx != ctx->sec_maps || sym.st_value / ctx->map_len != which) continue; @@ -1849,11 +1851,13 @@ static int bpf_map_num_sym(struct bpf_elf_ctx *ctx) GElf_Sym sym; for (i = 0; i < ctx->sym_num; i++) { + int type = GELF_ST_TYPE(sym.st_info); + if (gelf_getsym(ctx->sym_tab, i, &sym) != &sym) continue; if (GELF_ST_BIND(sym.st_info) != STB_GLOBAL || - GELF_ST_TYPE(sym.st_info) != STT_NOTYPE || + (type != STT_NOTYPE && type != STT_OBJECT) || sym.st_shndx != ctx->sec_maps) continue; num++; @@ -1927,10 +1931,12 @@ static int bpf_map_verify_all_offs(struct bpf_elf_ctx *ctx, int end) * the table again. */ for (i = 0; i < ctx->sym_num; i++) { + int type = GELF_ST_TYPE(sym.st_info); + if (gelf_getsym(ctx->sym_tab, i, &sym) != &sym) continue; if (GELF_ST_BIND(sym.st_info) != STB_GLOBAL || - GELF_ST_TYPE(sym.st_info) != STT_NOTYPE || + (type != STT_NOTYPE && type != STT_OBJECT) || sym.st_shndx != ctx->sec_maps) continue; if (sym.st_value == off)