libbpf.c (765a34130ea506fafefe179bdfa47da296016d92) | libbpf.c (aaf6886d9b53d34f0a3d2f577ddc1224026d12ab) |
---|---|
1// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) 2 3/* 4 * Common eBPF ELF object loading operations. 5 * 6 * Copyright (C) 2013-2015 Alexei Starovoitov <ast@kernel.org> 7 * Copyright (C) 2015 Wang Nan <wangnan0@huawei.com> 8 * Copyright (C) 2015 Huawei Inc. --- 3047 unchanged lines hidden (view full) --- 3056 if (err) 3057 break; 3058 } 3059 } 3060 3061 return libbpf_err(err); 3062} 3063 | 1// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) 2 3/* 4 * Common eBPF ELF object loading operations. 5 * 6 * Copyright (C) 2013-2015 Alexei Starovoitov <ast@kernel.org> 7 * Copyright (C) 2015 Wang Nan <wangnan0@huawei.com> 8 * Copyright (C) 2015 Huawei Inc. --- 3047 unchanged lines hidden (view full) --- 3056 if (err) 3057 break; 3058 } 3059 } 3060 3061 return libbpf_err(err); 3062} 3063 |
3064int btf__finalize_data(struct bpf_object *obj, struct btf *btf) 3065{ 3066 return btf_finalize_data(obj, btf); 3067} 3068 | |
3069static int bpf_object__finalize_btf(struct bpf_object *obj) 3070{ 3071 int err; 3072 3073 if (!obj->btf) 3074 return 0; 3075 3076 err = btf_finalize_data(obj, obj->btf); --- 1315 unchanged lines hidden (view full) --- 4392 4393 prog->nr_reloc++; 4394 } 4395 return 0; 4396} 4397 4398static int bpf_map_find_btf_info(struct bpf_object *obj, struct bpf_map *map) 4399{ | 3064static int bpf_object__finalize_btf(struct bpf_object *obj) 3065{ 3066 int err; 3067 3068 if (!obj->btf) 3069 return 0; 3070 3071 err = btf_finalize_data(obj, obj->btf); --- 1315 unchanged lines hidden (view full) --- 4387 4388 prog->nr_reloc++; 4389 } 4390 return 0; 4391} 4392 4393static int bpf_map_find_btf_info(struct bpf_object *obj, struct bpf_map *map) 4394{ |
4400 struct bpf_map_def *def = &map->def; 4401 __u32 key_type_id = 0, value_type_id = 0; 4402 int ret; | 4395 int id; |
4403 4404 if (!obj->btf) 4405 return -ENOENT; 4406 4407 /* if it's BTF-defined map, we don't need to search for type IDs. 4408 * For struct_ops map, it does not need btf_key_type_id and 4409 * btf_value_type_id. 4410 */ | 4396 4397 if (!obj->btf) 4398 return -ENOENT; 4399 4400 /* if it's BTF-defined map, we don't need to search for type IDs. 4401 * For struct_ops map, it does not need btf_key_type_id and 4402 * btf_value_type_id. 4403 */ |
4411 if (map->sec_idx == obj->efile.btf_maps_shndx || 4412 bpf_map__is_struct_ops(map)) | 4404 if (map->sec_idx == obj->efile.btf_maps_shndx || bpf_map__is_struct_ops(map)) |
4413 return 0; 4414 | 4405 return 0; 4406 |
4415 if (!bpf_map__is_internal(map)) { 4416 pr_warn("Use of BPF_ANNOTATE_KV_PAIR is deprecated, use BTF-defined maps in .maps section instead\n"); 4417#pragma GCC diagnostic push 4418#pragma GCC diagnostic ignored "-Wdeprecated-declarations" 4419 ret = btf__get_map_kv_tids(obj->btf, map->name, def->key_size, 4420 def->value_size, &key_type_id, 4421 &value_type_id); 4422#pragma GCC diagnostic pop 4423 } else { 4424 /* 4425 * LLVM annotates global data differently in BTF, that is, 4426 * only as '.data', '.bss' or '.rodata'. 4427 */ 4428 ret = btf__find_by_name(obj->btf, map->real_name); 4429 } 4430 if (ret < 0) 4431 return ret; | 4407 /* 4408 * LLVM annotates global data differently in BTF, that is, 4409 * only as '.data', '.bss' or '.rodata'. 4410 */ 4411 if (!bpf_map__is_internal(map)) 4412 return -ENOENT; |
4432 | 4413 |
4433 map->btf_key_type_id = key_type_id; 4434 map->btf_value_type_id = bpf_map__is_internal(map) ? 4435 ret : value_type_id; | 4414 id = btf__find_by_name(obj->btf, map->real_name); 4415 if (id < 0) 4416 return id; 4417 4418 map->btf_key_type_id = 0; 4419 map->btf_value_type_id = id; |
4436 return 0; 4437} 4438 4439static int bpf_get_map_info_from_fdinfo(int fd, struct bpf_map_info *info) 4440{ 4441 char file[PATH_MAX], buff[4096]; 4442 FILE *fp; 4443 __u32 val; --- 8788 unchanged lines hidden --- | 4420 return 0; 4421} 4422 4423static int bpf_get_map_info_from_fdinfo(int fd, struct bpf_map_info *info) 4424{ 4425 char file[PATH_MAX], buff[4096]; 4426 FILE *fp; 4427 __u32 val; --- 8788 unchanged lines hidden --- |