lkml.org 
[lkml]   [2015]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH v4 10/29] bpf tools: Collect map definitions from 'maps' section
On Wed, May 27, 2015 at 05:19:45AM +0000, Wang Nan wrote:
> If maps are used by eBPF programs, corresponding object file(s) should
> contain a section named 'map'. Which contains map definitions. This
> patch copies the data of the whole section. Map data parsing should be
> acted just before map loading.
>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> ---
...
> +static int
> +bpf_object__init_maps(struct bpf_object *obj, void *data,
> + size_t size)
> +{
> + if (size == 0) {
> + pr_debug("%s doesn't need map definition\n",
> + obj->path);
> + return 0;
> + }
> +
> + obj->maps_buf = malloc(size);
> + if (!obj->maps_buf) {
> + pr_warning("malloc maps failed: %s\n", obj->path);
> + return -ENOMEM;
> + }
> +
> + obj->maps_buf_sz = size;
> + memcpy(obj->maps_buf, data, size);

why copy it? To create maps and apply fixups to instructions
relo sections are needed anyway, so elf has to be open while
this section is being processed. So why copy?



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