btf_encoder: Fix array index type numbering

Take into account type ID offset, accumulated from previous CUs, when
calculating a new type ID for the generated array index type.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Andrii Nakryiko 2020-11-05 21:25:46 -08:00 committed by Arnaldo Carvalho de Melo
parent 9fa3a100f7
commit 94a7535939
1 changed files with 6 additions and 6 deletions

View File

@ -611,22 +611,22 @@ int cu__encode_btf(struct cu *cu, int verbose, bool force,
printf("File %s:\n", btfe->filename);
}
btf_elf__verbose = verbose;
btf_elf__force = force;
type_id_off = btf__get_nr_types(btfe->btf);
if (!has_index_type) {
/* cu__find_base_type_by_name() takes "type_id_t *id" */
type_id_t id;
if (cu__find_base_type_by_name(cu, "int", &id)) {
has_index_type = true;
array_index_id = id;
array_index_id = type_id_off + id;
} else {
has_index_type = false;
array_index_id = cu->types_table.nr_entries;
array_index_id = type_id_off + cu->types_table.nr_entries;
}
}
btf_elf__verbose = verbose;
btf_elf__force = force;
type_id_off = btf__get_nr_types(btfe->btf);
cu__for_each_type(cu, core_id, pos) {
int32_t btf_type_id = tag__encode_btf(cu, pos, core_id, btfe, array_index_id, type_id_off);