summaryrefslogtreecommitdiff
path: root/tools/objtool/elf.c
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@kernel.org>2023-05-30 10:21:05 -0700
committerJosh Poimboeuf <jpoimboe@kernel.org>2023-06-07 10:03:21 -0700
commitbe9a4c116824c39720001db5bc45fe7528b26cff (patch)
treebaceb62de9286ebccbf559a181020ab002ab5cdf /tools/objtool/elf.c
parentebcef730a19ba7ca446169f391d2e51722d68043 (diff)
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>
Diffstat (limited to 'tools/objtool/elf.c')
-rw-r--r--tools/objtool/elf.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 19ac53ad76ee..70c801254566 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) {