lkml.org 
[lkml]   [2015]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH v6 10/32] bpf tools: Collect symbol table from SHT_SYMTAB section
    Date
    This patch collects symbols section. This section is useful when
    linking ELF maps.

    Signed-off-by: Wang Nan <wangnan0@huawei.com>
    Acked-by: Alexei Starovoitov <ast@plumgrid.com>
    ---
    tools/lib/bpf/libbpf.c | 10 ++++++++++
    1 file changed, 10 insertions(+)

    diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
    index 3315f00..77ad7d3 100644
    --- a/tools/lib/bpf/libbpf.c
    +++ b/tools/lib/bpf/libbpf.c
    @@ -94,6 +94,7 @@ struct bpf_object {
    size_t obj_buf_sz;
    Elf *elf;
    GElf_Ehdr ehdr;
    + Elf_Data *symbols;
    } efile;
    char path[];
    };
    @@ -135,6 +136,7 @@ static void bpf_object__elf_finish(struct bpf_object *obj)
    elf_end(obj->efile.elf);
    obj->efile.elf = NULL;
    }
    + obj->efile.symbols = NULL;
    zclose(obj->efile.fd);
    obj->efile.obj_buf = NULL;
    obj->efile.obj_buf_sz = 0;
    @@ -332,6 +334,14 @@ static int bpf_object__elf_collect(struct bpf_object *obj)
    else if (strcmp(name, "maps") == 0)
    err = bpf_object__init_maps(obj, data->d_buf,
    data->d_size);
    + else if (sh.sh_type == SHT_SYMTAB) {
    + if (obj->efile.symbols) {
    + pr_warning("bpf: multiple SYMTAB in %s\n",
    + obj->path);
    + err = -EEXIST;
    + } else
    + obj->efile.symbols = data;
    + }
    if (err)
    goto out;
    }
    --
    1.8.3.4


    \
     
     \ /
      Last update: 2015-06-09 08:21    [W:3.520 / U:0.324 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site