| Date | Mon, 18 May 2015 11:06:01 -0700 | From | Alexei Starovoitov <> | Subject | Re: [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 ?
|