From nobody Tue Dec 16 12:38:43 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F30226FA42; Fri, 9 May 2025 20:18:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746821882; cv=none; b=c3I0T9BlbgHP3DmRzj/kc17mhrraf4foZQ7ERvLa9c2MTlyG7X3ffrNAWXivqVw2oRRn2y6xxJ3bd9HKjVdHKIQjzDcWunjIH3r3LO+UmoxRinGM+BuKUXJOpoW4GnsL7tIuYqO79cEkhj9mZdB1hfmiU5P4A+S2O4tO6lehpDc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746821882; c=relaxed/simple; bh=30eLE6xSDMB9ljZcmYDvILgYPcifP1so4H1h7z0aDvg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=axu6/9dHTQ/00/XjAKb5LsTyomjlt6g/9n+cEpgB8x1QtSRfqavTHaNGAuSe6AtyJJVdWoV5aUXaaQuhgKIuMnHu6uM8aSj6y/zZDpSzX+wATJTw4tWdcVTsiHfuLQTQQYUH8Ov0uDj9y+uKO2KFlKQSoGWA6JiwMhT4jjJIOqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RCjDocGY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RCjDocGY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C8DAC4CEEF; Fri, 9 May 2025 20:18:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746821882; bh=30eLE6xSDMB9ljZcmYDvILgYPcifP1so4H1h7z0aDvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RCjDocGY6wtU7QuY9SLLU+3LX6HKM455N3xV53/lxn2oBgMRRdjGR4uI4LEyf17+E bW/sjjry87Jwv+4zkfPKL0FIOdAzLOEueOABo8njXXQuiWJ2S/gTAJOyW58CvdSktm Ugmzn4xbX1KIbroGkfv9MMHfKVgnNOivMn7uzdWpP3f53jHfCafqKDwRpdlNiH4l/g bx4cjWNjGcn65Vwl/4sxWy4YyfT23J4ksxBc2c66LMuU2vNjvepZLP7otUpdpu1wqm D+tBM9cGVJjRpi8RzrswdPNSYLzOx4DPpP1o/Nr3wK4zY0oaHsuI/gJd0DOoc/bi7Y 1eki/ALcxwbRw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Petr Mladek , Miroslav Benes , Joe Lawrence , live-patching@vger.kernel.org, Song Liu , laokz , Jiri Kosina , Marcos Paulo de Souza , Weinan Liu , Fazla Mehrab , Chen Zhongjin , Puranjay Mohan Subject: [PATCH v2 25/62] objtool: Convert elf iterator macros to use 'struct elf' Date: Fri, 9 May 2025 13:16:49 -0700 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 'struct objtool_file' is specific to the check code and doesn't belong in the elf code which is supposed to be objtool_file-agnostic. Convert the elf iterator macros to use 'struct elf' instead. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 22 +++++++++++----------- tools/objtool/include/objtool/elf.h | 8 ++++---- tools/objtool/orc_gen.c | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 8a87c38516fc..c6884620e49d 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -106,7 +106,7 @@ static struct instruction *prev_insn_same_sym(struct ob= jtool_file *file, #define for_each_insn(file, insn) \ for (struct section *__sec, *__fake =3D (struct section *)1; \ __fake; __fake =3D NULL) \ - for_each_sec(file, __sec) \ + for_each_sec(file->elf, __sec) \ sec_for_each_insn(file, __sec, insn) =20 #define func_for_each_insn(file, func, insn) \ @@ -429,7 +429,7 @@ static int decode_instructions(struct objtool_file *fil= e) struct instruction *insn; int ret; =20 - for_each_sec(file, sec) { + for_each_sec(file->elf, sec) { struct instruction *insns =3D NULL; u8 prev_len =3D 0; u8 idx =3D 0; @@ -859,7 +859,7 @@ static int create_cfi_sections(struct objtool_file *fil= e) } =20 idx =3D 0; - for_each_sym(file, sym) { + for_each_sym(file->elf, sym) { if (sym->type !=3D STT_FUNC) continue; =20 @@ -875,7 +875,7 @@ static int create_cfi_sections(struct objtool_file *fil= e) return -1; =20 idx =3D 0; - for_each_sym(file, sym) { + for_each_sym(file->elf, sym) { if (sym->type !=3D STT_FUNC) continue; =20 @@ -2165,7 +2165,7 @@ static int add_jump_table_alts(struct objtool_file *f= ile) if (!file->rodata) return 0; =20 - for_each_sym(file, func) { + for_each_sym(file->elf, func) { if (func->type !=3D STT_FUNC) continue; =20 @@ -2471,7 +2471,7 @@ static int classify_symbols(struct objtool_file *file) { struct symbol *func; =20 - for_each_sym(file, func) { + for_each_sym(file->elf, func) { if (func->type =3D=3D STT_NOTYPE && strstarts(func->name, ".L")) func->local_label =3D true; =20 @@ -2516,7 +2516,7 @@ static void mark_rodata(struct objtool_file *file) * * .rodata.str1.* sections are ignored; they don't contain jump tables. */ - for_each_sec(file, sec) { + for_each_sec(file->elf, sec) { if ((!strncmp(sec->name, ".rodata", 7) && !strstr(sec->name, ".str1.")) || !strncmp(sec->name, ".data.rel.ro", 12)) { @@ -4178,7 +4178,7 @@ static int add_prefix_symbols(struct objtool_file *fi= le) struct section *sec; struct symbol *func; =20 - for_each_sec(file, sec) { + for_each_sec(file->elf, sec) { if (!(sec->sh.sh_flags & SHF_EXECINSTR)) continue; =20 @@ -4270,7 +4270,7 @@ static int validate_functions(struct objtool_file *fi= le) struct section *sec; int warnings =3D 0; =20 - for_each_sec(file, sec) { + for_each_sec(file->elf, sec) { if (!(sec->sh.sh_flags & SHF_EXECINSTR)) continue; =20 @@ -4449,7 +4449,7 @@ static int validate_ibt(struct objtool_file *file) for_each_insn(file, insn) warnings +=3D validate_ibt_insn(file, insn); =20 - for_each_sec(file, sec) { + for_each_sec(file->elf, sec) { =20 /* Already done by validate_ibt_insn() */ if (sec->sh.sh_flags & SHF_EXECINSTR) @@ -4610,7 +4610,7 @@ static void disas_warned_funcs(struct objtool_file *f= ile) struct symbol *sym; char *funcs =3D NULL, *tmp; =20 - for_each_sym(file, sym) { + for_each_sym(file->elf, sym) { if (sym->warned) { if (!funcs) { funcs =3D malloc(strlen(sym->name) + 1); diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/ob= jtool/elf.h index 0f9adfe8e852..fcea9338c687 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -324,16 +324,16 @@ static inline void set_sym_next_reloc(struct reloc *r= eloc, struct reloc *next) reloc->_sym_next_reloc =3D (unsigned long)next | bit; } =20 -#define for_each_sec(file, sec) \ - list_for_each_entry(sec, &file->elf->sections, list) +#define for_each_sec(elf, sec) \ + list_for_each_entry(sec, &elf->sections, list) =20 #define sec_for_each_sym(sec, sym) \ list_for_each_entry(sym, &sec->symbol_list, list) =20 -#define for_each_sym(file, sym) \ +#define for_each_sym(elf, sym) \ for (struct section *__sec, *__fake =3D (struct section *)1; \ __fake; __fake =3D NULL) \ - for_each_sec(file, __sec) \ + for_each_sec(elf, __sec) \ sec_for_each_sym(__sec, sym) =20 #define for_each_reloc(rsec, reloc) \ diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c index 922e6aac7cea..6eff3d6a125c 100644 --- a/tools/objtool/orc_gen.c +++ b/tools/objtool/orc_gen.c @@ -57,7 +57,7 @@ int orc_create(struct objtool_file *file) =20 /* Build a deduplicated list of ORC entries: */ INIT_LIST_HEAD(&orc_list); - for_each_sec(file, sec) { + for_each_sec(file->elf, sec) { struct orc_entry orc, prev_orc =3D {0}; struct instruction *insn; bool empty =3D true; --=20 2.49.0