mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Josh Poimboeuf" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: objtool/core] objtool: Get rid of reloc->idx
Date: Fri, 09 Jun 2023 07:47:31 -0000	[thread overview]
Message-ID: <168629685158.404.4699012820536375293.tip-bot2@tip-bot2> (raw)
In-Reply-To: <7351d2ebad0519027db14a32f6204af84952574a.1685464332.git.jpoimboe@kernel.org>

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     be9a4c116824c39720001db5bc45fe7528b26cff
Gitweb:        https://git.kernel.org/tip/be9a4c116824c39720001db5bc45fe7528b26cff
Author:        Josh Poimboeuf <jpoimboe@kernel.org>
AuthorDate:    Tue, 30 May 2023 10:21:05 -07:00
Committer:     Josh Poimboeuf <jpoimboe@kernel.org>
CommitterDate: Wed, 07 Jun 2023 10:03:21 -07:00

objtool: Get rid of reloc->idx

Use the array offset to calculate the reloc index.

With allyesconfig + CONFIG_DEBUG_INFO:

- Before: peak heap memory consumption: 45.56G
- After:  peak heap memory consumption: 43.83G

Link: https://lore.kernel.org/r/7351d2ebad0519027db14a32f6204af84952574a.1685464332.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/elf.c                 |  6 ++----
 tools/objtool/include/objtool/elf.h | 10 +++++++---
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 19ac53a..70c8012 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -829,7 +829,6 @@ static struct reloc *elf_init_reloc(struct elf *elf, struct section *rsec,
 		return NULL;
 	}
 
-	reloc->idx = reloc_idx;
 	reloc->sec = rsec;
 	reloc->offset = offset;
 	reloc->type = type;
@@ -954,7 +953,6 @@ static int read_relocs(struct elf *elf)
 				return -1;
 
 			reloc->sec = rsec;
-			reloc->idx = i;
 			symndx = GELF_R_SYM(reloc->rel.r_info);
 			reloc->sym = sym = find_symbol_by_index(elf, symndx);
 			if (!reloc->sym) {
@@ -1237,9 +1235,9 @@ int elf_write_reloc(struct elf *elf, struct reloc *reloc)
 
 	if (rsec->sh.sh_type == SHT_RELA) {
 		reloc->rela.r_addend = reloc->addend;
-		ret = gelf_update_rela(rsec->data, reloc->idx, &reloc->rela);
+		ret = gelf_update_rela(rsec->data, reloc_idx(reloc), &reloc->rela);
 	} else {
-		ret = gelf_update_rel(rsec->data, reloc->idx, &reloc->rel);
+		ret = gelf_update_rel(rsec->data, reloc_idx(reloc), &reloc->rel);
 	}
 
 	if (!ret) {
diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
index a09da20..2a14da6 100644
--- a/tools/objtool/include/objtool/elf.h
+++ b/tools/objtool/include/objtool/elf.h
@@ -76,9 +76,8 @@ struct reloc {
 	struct symbol *sym;
 	struct list_head sym_reloc_entry;
 	unsigned long offset;
-	unsigned int type;
 	s64 addend;
-	int idx;
+	unsigned int type;
 	bool jump_table_start;
 };
 
@@ -200,6 +199,11 @@ static inline unsigned int sec_num_entries(struct section *sec)
 	return sec->sh.sh_size / sec->sh.sh_entsize;
 }
 
+static inline unsigned int reloc_idx(struct reloc *reloc)
+{
+	return reloc - reloc->sec->relocs;
+}
+
 #define for_each_sec(file, sec)						\
 	list_for_each_entry(sec, &file->elf->sections, list)
 
@@ -219,7 +223,7 @@ static inline unsigned int sec_num_entries(struct section *sec)
 		     __i++, reloc++)
 
 #define for_each_reloc_from(rsec, reloc)				\
-	for (int __i = reloc->idx;					\
+	for (int __i = reloc_idx(reloc);				\
 	     __i < sec_num_entries(rsec);				\
 	     __i++, reloc++)
 

  reply	other threads:[~2023-06-09  7:48 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 ` [PATCH 10/22] objtool: Add for_each_reloc() Josh Poimboeuf
2023-06-09  7:47   ` [tip: objtool/core] " 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-bot2 for Josh Poimboeuf [this message]
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=168629685158.404.4699012820536375293.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.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®