mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@kernel.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Miroslav Benes <mbenes@suse.cz>
Subject: [PATCH 10/22] objtool: Add for_each_reloc()
Date: Tue, 30 May 2023 10:21:02 -0700	[thread overview]
Message-ID: <dbfcb1037d8b958e52d097b67829c4c6811c24bb.1685464332.git.jpoimboe@kernel.org> (raw)
In-Reply-To: <cover.1685464332.git.jpoimboe@kernel.org>

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/check.c               | 24 ++++++++++++------------
 tools/objtool/include/objtool/elf.h |  6 ++++++
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 88f54bb1b01c..1355e6fec7d6 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -590,7 +590,7 @@ static int add_dead_ends(struct objtool_file *file)
 	if (!rsec)
 		goto reachable;
 
-	list_for_each_entry(reloc, &rsec->reloc_list, list) {
+	for_each_reloc(rsec, reloc) {
 		if (reloc->sym->type != STT_SECTION) {
 			WARN("unexpected relocation symbol type in %s", rsec->name);
 			return -1;
@@ -625,7 +625,7 @@ static int add_dead_ends(struct objtool_file *file)
 	if (!rsec)
 		return 0;
 
-	list_for_each_entry(reloc, &rsec->reloc_list, list) {
+	for_each_reloc(rsec, reloc) {
 		if (reloc->sym->type != STT_SECTION) {
 			WARN("unexpected relocation symbol type in %s", rsec->name);
 			return -1;
@@ -1018,7 +1018,7 @@ static void add_ignores(struct objtool_file *file)
 	if (!rsec)
 		return;
 
-	list_for_each_entry(reloc, &rsec->reloc_list, list) {
+	for_each_reloc(rsec, reloc) {
 		switch (reloc->sym->type) {
 		case STT_FUNC:
 			func = reloc->sym;
@@ -1259,7 +1259,7 @@ static int add_ignore_alternatives(struct objtool_file *file)
 	if (!rsec)
 		return 0;
 
-	list_for_each_entry(reloc, &rsec->reloc_list, list) {
+	for_each_reloc(rsec, reloc) {
 		if (reloc->sym->type != STT_SECTION) {
 			WARN("unexpected relocation symbol type in %s", rsec->name);
 			return -1;
@@ -1990,7 +1990,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
 	 * Each @reloc is a switch table relocation which points to the target
 	 * instruction.
 	 */
-	list_for_each_entry_from(reloc, &table->sec->reloc_list, list) {
+	for_each_reloc_from(table->sec, reloc) {
 
 		/* Check for the end of the table: */
 		if (reloc != table && reloc->jump_table_start)
@@ -2264,7 +2264,7 @@ static int read_noendbr_hints(struct objtool_file *file)
 	if (!rsec)
 		return 0;
 
-	list_for_each_entry(reloc, &rsec->reloc_list, list) {
+	for_each_reloc(rsec, reloc) {
 		insn = find_insn(file, reloc->sym->sec, reloc->sym->offset + reloc->addend);
 		if (!insn) {
 			WARN("bad .discard.noendbr entry");
@@ -2287,7 +2287,7 @@ static int read_retpoline_hints(struct objtool_file *file)
 	if (!rsec)
 		return 0;
 
-	list_for_each_entry(reloc, &rsec->reloc_list, list) {
+	for_each_reloc(rsec, reloc) {
 		if (reloc->sym->type != STT_SECTION) {
 			WARN("unexpected relocation symbol type in %s", rsec->name);
 			return -1;
@@ -2323,7 +2323,7 @@ static int read_instr_hints(struct objtool_file *file)
 	if (!rsec)
 		return 0;
 
-	list_for_each_entry(reloc, &rsec->reloc_list, list) {
+	for_each_reloc(rsec, reloc) {
 		if (reloc->sym->type != STT_SECTION) {
 			WARN("unexpected relocation symbol type in %s", rsec->name);
 			return -1;
@@ -2342,7 +2342,7 @@ static int read_instr_hints(struct objtool_file *file)
 	if (!rsec)
 		return 0;
 
-	list_for_each_entry(reloc, &rsec->reloc_list, list) {
+	for_each_reloc(rsec, reloc) {
 		if (reloc->sym->type != STT_SECTION) {
 			WARN("unexpected relocation symbol type in %s", rsec->name);
 			return -1;
@@ -2370,7 +2370,7 @@ static int read_validate_unret_hints(struct objtool_file *file)
 	if (!rsec)
 		return 0;
 
-	list_for_each_entry(reloc, &rsec->reloc_list, list) {
+	for_each_reloc(rsec, reloc) {
 		if (reloc->sym->type != STT_SECTION) {
 			WARN("unexpected relocation symbol type in %s", rsec->name);
 			return -1;
@@ -2398,7 +2398,7 @@ static int read_intra_function_calls(struct objtool_file *file)
 	if (!rsec)
 		return 0;
 
-	list_for_each_entry(reloc, &rsec->reloc_list, list) {
+	for_each_reloc(rsec, reloc) {
 		unsigned long dest_off;
 
 		if (reloc->sym->type != STT_SECTION) {
@@ -4395,7 +4395,7 @@ static int validate_ibt(struct objtool_file *file)
 		    strstr(sec->name, "__patchable_function_entries"))
 			continue;
 
-		list_for_each_entry(reloc, &sec->rsec->reloc_list, list)
+		for_each_reloc(sec->rsec, reloc)
 			warnings += validate_ibt_data_reloc(file, reloc);
 	}
 
diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
index 74f63934afd3..a938cb1d4172 100644
--- a/tools/objtool/include/objtool/elf.h
+++ b/tools/objtool/include/objtool/elf.h
@@ -209,6 +209,12 @@ static inline void mark_sec_changed(struct elf *elf, struct section *sec,
 		for_each_sec(file, __sec)				\
 			sec_for_each_sym(__sec, sym)
 
+#define for_each_reloc(rsec, reloc)					\
+	list_for_each_entry(reloc, &rsec->reloc_list, list)
+
+#define for_each_reloc_from(rsec, reloc)				\
+	list_for_each_entry_from(reloc, &rsec->reloc_list, list)
+
 #define OFFSET_STRIDE_BITS	4
 #define OFFSET_STRIDE		(1UL << OFFSET_STRIDE_BITS)
 #define OFFSET_STRIDE_MASK	(~(OFFSET_STRIDE - 1))
-- 
2.40.1


  parent reply	other threads:[~2023-05-30 17:22 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30 17:20 [PATCH 00/22] objtool: Reduce memory usage with CONFIG_DEBUG_INFO Josh Poimboeuf
2023-05-30 17:20 ` [PATCH 01/22] objtool: Tidy elf.h Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:20 ` [PATCH 02/22] objtool: Remove flags argument from elf_create_section() Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:20 ` [PATCH 03/22] objtool: Improve reloc naming Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:20 ` [PATCH 04/22] objtool: Consolidate rel/rela handling Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:20 ` [PATCH 05/22] objtool: Fix reloc_hash size Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:20 ` [PATCH 06/22] objtool: Add mark_sec_changed() Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:20 ` [PATCH 07/22] objtool: Add elf_create_section_pair() Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 08/22] objtool: Keep GElf_Rel[a] structs synced Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 09/22] objtool: Don't free memory in elf_close() Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` Josh Poimboeuf [this message]
2023-06-09  7:47   ` [tip: objtool/core] objtool: Add for_each_reloc() tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 11/22] objtool: Allocate relocs in advance for new rela sections Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 12/22] objtool: Get rid of reloc->list Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 13/22] objtool: Get rid of reloc->idx Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 14/22] objtool: Get rid of reloc->offset Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 15/22] objtool: Get rid of reloc->type Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 16/22] objtool: Get rid of reloc->addend Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 17/22] objtool: Get rid of reloc->jump_table_start Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 18/22] objtool: Shrink reloc->sym_reloc_entry Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 19/22] objtool: Shrink elf hash nodes Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 20/22] objtool: Get rid of reloc->rel[a] Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 21/22] objtool: Free insns when done Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2023-05-30 17:21 ` [PATCH 22/22] objtool: Skip reading DWARF section data Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf

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=dbfcb1037d8b958e52d097b67829c4c6811c24bb.1685464332.git.jpoimboe@kernel.org \
    --to=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®