lkml.org 
[lkml]   [2015]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation
On 5/17/15 3:56 AM, Wang Nan wrote:
> This patch adds basic 'struct bpf_object' which will be used for eBPF
> object file loading. eBPF object files are compiled by LLVM as ELF
> format. In this patch, libelf is used to open those files, read EHDR
> and do basic validation according to e_type and e_machine.
>
> All elf related staffs are grouped together and reside in elf field of
> 'struct bpf_object'. bpf_obj_clear_elf() is introduced to clear it.
>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> ---
...
> +static void bpf_obj_clear_elf(struct bpf_object *obj)
> +{
> + if (!obj_elf_valid(obj))
> + return;
> +
> + if (obj->elf.elf) {
> + elf_end(obj->elf.elf);
> + obj->elf.elf = NULL;

the name of the function is odd.
'..clear_elf' ? Only because the field was named 'elf' ?
Also obj->elf.elf looks unbalanced.

may be bpf_obj_elf_finish() to match bpf_obj_elf_init()
and obj->efile.elf ?

> + }
> + if (obj->elf.fd >= 0) {
> + close(obj->elf.fd);

and the above will change to obj->efile.fd ?



\
 
 \ /
  Last update: 2015-05-18 20:41    [W:0.694 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site