]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - lib/bpf.c
bpf: check map symbol type properly with newer llvm compiler
[mirror_iproute2.git] / lib / bpf.c
index d093d0bd86eae7336f39c36efefe924a7317d27d..45f279fa4a416a52d3131b3ffe407ae2a9562d47 100644 (file)
--- 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)