Re: [PATCH bpf-next v3 10/15] libbpf: replace elf_state->st_ops_* fields with SEC_ST_OPS sec_type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 4, 2024 at 2:52 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
>
> The next patch would add two new section names for struct_ops maps.
> To make working with multiple struct_ops sections more convenient:
> - remove fields like elf_state->st_ops_{shndx,link_shndx};
> - mark section descriptions hosting struct_ops as
>   elf_sec_desc->sec_type == SEC_ST_OPS;
>
> After these changes struct_ops sections could be processed uniformly
> by iterating bpf_object->efile.secs entries.
>
> Signed-off-by: Eduard Zingerman <eddyz87@xxxxxxxxx>
> ---
>  tools/lib/bpf/libbpf.c | 62 ++++++++++++++++++++++--------------------
>  1 file changed, 33 insertions(+), 29 deletions(-)
>

Makes sense and a good generalization!

Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>

[...]

> @@ -1268,7 +1266,7 @@ static int bpf_object__init_kern_struct_ops_maps(struct bpf_object *obj)
>  }
>
>  static int init_struct_ops_maps(struct bpf_object *obj, const char *sec_name,
> -                               int shndx, Elf_Data *data, __u32 map_flags)
> +                               int shndx, Elf_Data *data)
>  {
>         const struct btf_type *type, *datasec;
>         const struct btf_var_secinfo *vsi;
> @@ -1330,7 +1328,8 @@ static int init_struct_ops_maps(struct bpf_object *obj, const char *sec_name,
>                 map->def.key_size = sizeof(int);
>                 map->def.value_size = type->size;
>                 map->def.max_entries = 1;
> -               map->def.map_flags = map_flags;
> +               map->def.map_flags = strcmp(sec_name, STRUCT_OPS_LINK_SEC) == 0
> +                                  ? BPF_F_LINK : 0;

Does it fit in under 100 characters? if yes, please keep on a single line

>
>                 map->st_ops = calloc(1, sizeof(*map->st_ops));
>                 if (!map->st_ops)

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux