From nobody Sun Feb 8 07:14:30 2026 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 4D5C71CFED2; Tue, 3 Sep 2024 04:00:34 +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=1725336034; cv=none; b=UkjE8SBPwAy34RQf8OFQws1DhAhpzboRustniazYJ7UOMrIltYzV5ofljUY4vnH69GrvX1ilUqmRPHlvPBxTGs/aWCX4IeIg9ue0biwerCx5i4wCrXToDTzydh3cofFce9CT6BlZX3RpdCoXNXKPc3huiRedQTMFqHktGh0TDJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725336034; c=relaxed/simple; bh=9dCrDC0dI0bCabg/XMOLC9FAJQvbJGfs6BK4o9Tsleo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AtHFHbmuRAS9DZm3pKqaCZ81iNr0FRrHNg0izhBccea4sOxiinWsEHL3R5wCHdgP6Pi9z5tMc4fSUqV7KFBkHDJRBWG4NZppF8wWZoFzoKZ03GDug/Zcz4Y8QZmZhn4+cfYRushlFai02Irhhrn6TiTwicsGSkWZeXT0oKw4bS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aF0Kp2+/; 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="aF0Kp2+/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9135C4CECA; Tue, 3 Sep 2024 04:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725336034; bh=9dCrDC0dI0bCabg/XMOLC9FAJQvbJGfs6BK4o9Tsleo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aF0Kp2+/G7I1VUa+hQVsLmLjc2DnkozVD1qomYO2Wk+DAUVM3T0naSgQavELeSTzt CM9OLiAFtg7ryc8qyeuYuoQxNFp/srOhGTPikmxdySORRzeAd+lYNGaQtpYb+PeCpW zNv0G6rkKXpHtsv2lnrSjrV8P1N4QZyqUgcYO63riVGcdsnM956P4q6JD44ErGxgTF JQD4kpWqupqgaCWUvzVzSx1UKurCB8lqgZDkgjT+e06FKBcLakfyGi3svhGYLoZ2Fs dcNX0c9x6Ji8IY14Qc4KWgfYasQDmvcqaqNMkZkOLgzQCTLr2ibxddaNWHGY6WFOD7 NLPsUehmFHYCQ== From: Josh Poimboeuf To: live-patching@vger.kernel.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Miroslav Benes , Petr Mladek , Joe Lawrence , Jiri Kosina , Peter Zijlstra , Marcos Paulo de Souza , Song Liu Subject: [RFC 10/31] objtool: Use 'struct elf' in elf macros Date: Mon, 2 Sep 2024 20:59:53 -0700 Message-ID: X-Mailer: git-send-email 2.45.2 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. 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 a813a6194c61..06e7b3f5481d 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -107,7 +107,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) \ @@ -374,7 +374,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; @@ -899,7 +899,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 @@ -915,7 +915,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 @@ -2198,7 +2198,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 @@ -2534,7 +2534,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 @@ -2579,7 +2579,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.")) { sec->rodata =3D true; @@ -4198,7 +4198,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 @@ -4289,7 +4289,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 @@ -4458,7 +4458,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) @@ -4645,7 +4645,7 @@ static int disas_warned_funcs(struct objtool_file *fi= le) 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 a027fc34d605..7524510b5565 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -296,16 +296,16 @@ static inline void set_reloc_type(struct elf *elf, st= ruct reloc *reloc, unsigned mark_sec_changed(elf, reloc->sec, true); } =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.45.2