All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii@kernel.org>
To: <dwarves@vger.kernel.org>, <acme@kernel.org>, <bpf@vger.kernel.org>
Cc: <andrii@kernel.org>, <kernel-team@fb.com>
Subject: [PATCH dwarves 1/4] btf_encoder: fix array index type numbering
Date: Thu, 5 Nov 2020 21:25:46 -0800	[thread overview]
Message-ID: <20201106052549.3782099-2-andrii@kernel.org> (raw)
In-Reply-To: <20201106052549.3782099-1-andrii@kernel.org>

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>
---
 btf_encoder.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/btf_encoder.c b/btf_encoder.c
index 4c92908beab2..b3e47f172bb3 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -358,22 +358,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);
 
-- 
2.24.1


  reply	other threads:[~2020-11-06  5:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-06  5:25 [PATCH dwarves 0/4] Add split BTF support to pahole Andrii Nakryiko
2020-11-06  5:25 ` Andrii Nakryiko [this message]
2020-11-06  5:25 ` [PATCH dwarves 2/4] libbtf: improve variable naming and error reporting when writing out BTF Andrii Nakryiko
2020-11-06  5:25 ` [PATCH dwarves 3/4] libbpf: update libbpf submodlue reference to latest master Andrii Nakryiko
2020-11-06  5:25 ` [PATCH dwarves 4/4] btf: add support for split BTF loading and encoding Andrii Nakryiko
2020-11-11 11:56   ` Arnaldo Carvalho de Melo
2020-11-11 12:19     ` Arnaldo Carvalho de Melo
2020-11-11 18:29       ` Andrii Nakryiko
2020-11-11 18:32         ` Arnaldo
2020-11-13 11:35         ` Arnaldo Carvalho de Melo
2020-11-11 18:27     ` Andrii Nakryiko
2020-11-11 18:34       ` Arnaldo
2020-11-11 18:50         ` Andrii Nakryiko
2020-11-10 23:34 ` [PATCH dwarves 0/4] Add split BTF support to pahole Andrii Nakryiko
2020-11-11  0:29   ` Arnaldo
2020-11-11  0:35     ` Andrii Nakryiko
2020-11-11  0:38       ` Arnaldo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201106052549.3782099-2-andrii@kernel.org \
    --to=andrii@kernel.org \
    --cc=acme@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=kernel-team@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.