On Fri, Feb 8, 2019 at 9:13 AM Yonghong Song <y...@fb.com> wrote:
>
>
>
> On 2/7/19 6:55 PM, Andrii Nakryiko wrote:
> > This patch changes struct btf_ext to retain original data in sequential
> > block of memory, which makes it possible to expose
> > btf_ext__get_raw_data() interface, that's similar to
> > btf__get_raw_data(), allowing users of libbpf to get access to raw
> > representation of .BTF.ext section.
> >
> > Signed-off-by: Andrii Nakryiko <andr...@fb.com>
> > ---
> >   tools/lib/bpf/btf.c      | 85 +++++++++++++++++++++-------------------
> >   tools/lib/bpf/btf.h      |  2 +
> >   tools/lib/bpf/libbpf.map |  1 +
> >   3 files changed, 47 insertions(+), 41 deletions(-)
> >
> > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> > index 8730f6c3be9e..c87cc3d71b9f 100644
> > --- a/tools/lib/bpf/btf.c
> > +++ b/tools/lib/bpf/btf.c
> > @@ -41,9 +41,8 @@ struct btf {
> >
> >   struct btf_ext_info {
> >       /*
> > -      * info points to a deep copy of the individual info section
> > -      * (e.g. func_info and line_info) from the .BTF.ext.
> > -      * It does not include the __u32 rec_size.
> > +      * info points to the individual info section (e.g. func_info and
> > +      * line_info) from the .BTF.ext. It does not include the __u32 
> > rec_size.
> >        */
> >       void *info;
> >       __u32 rec_size;
> > @@ -51,8 +50,13 @@ struct btf_ext_info {
> >   };
> >
> >   struct btf_ext {
> > +     union {
> > +             struct btf_ext_header *hdr;
> > +             void *data;
> > +     };
> >       struct btf_ext_info func_info;
> >       struct btf_ext_info line_info;
> > +     __u32 data_size;
> >   };
> >
> >   struct btf_ext_info_sec {
> > @@ -603,19 +607,13 @@ struct btf_ext_sec_copy_param {
> >   };
> >
> >   static int btf_ext_copy_info(struct btf_ext *btf_ext,
> > -                          __u8 *data, __u32 data_size,
> >                            struct btf_ext_sec_copy_param *ext_sec)
>
> Overall looks good. Since we do not really "copy" info any more,
> rather we try to "setup" info based on btf_ext. Maybe changing
> all function and structure names with "_copy_" to "_setup_"?

Makes sense, will update.

>
> >   {
> > -     const struct btf_ext_header *hdr = (struct btf_ext_header *)data;
> >       const struct btf_ext_info_sec *sinfo;
> >       struct btf_ext_info *ext_info;
> >       __u32 info_left, record_size;
> >       /* The start of the info sec (including the __u32 record_size). */
> > -     const void *info;
> > -
> > -     /* data and data_size do not include btf_ext_header from now on */
> > -     data = data + hdr->hdr_len;
> > -     data_size -= hdr->hdr_len;
> > +     void *info;
> [...]

Reply via email to