summaryrefslogtreecommitdiff
path: root/tools/objtool/elf.c
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@kernel.org>2023-05-30 10:21:06 -0700
committerJosh Poimboeuf <jpoimboe@kernel.org>2023-06-07 10:03:21 -0700
commite4cbb9b81f1f7519c7ae3abda09cb15794022952 (patch)
treeb70dff6bc5c62979ac59ecaf4b5f87ca36ad6821 /tools/objtool/elf.c
parentbe9a4c116824c39720001db5bc45fe7528b26cff (diff)
objtool: Get rid of reloc->offset
Get the offset from the embedded GElf_Rel[a] struct. With allyesconfig + CONFIG_DEBUG_INFO: - Before: peak heap memory consumption: 43.83G - After: peak heap memory consumption: 42.10G Link: https://lore.kernel.org/r/2b9ec01178baa346a99522710bf2e82159412e3a.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.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 70c801254566..2b45460225d1 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -246,8 +246,9 @@ struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *se
if (reloc->sec != rsec)
continue;
- if (reloc->offset >= offset && reloc->offset < offset + len) {
- if (!r || reloc->offset < r->offset)
+ if (reloc_offset(reloc) >= offset &&
+ reloc_offset(reloc) < offset + len) {
+ if (!r || reloc_offset(reloc) < reloc_offset(r))
r = reloc;
}
}
@@ -830,11 +831,12 @@ static struct reloc *elf_init_reloc(struct elf *elf, struct section *rsec,
}
reloc->sec = rsec;
- reloc->offset = offset;
reloc->type = type;
reloc->sym = sym;
reloc->addend = addend;
+ reloc->rel.r_offset = offset;
+
if (elf_write_reloc(elf, reloc))
return NULL;
@@ -908,7 +910,6 @@ static int read_reloc(struct section *rsec, int i, struct reloc *reloc)
return -1;
}
- reloc->offset = reloc->rel.r_offset;
reloc->type = GELF_R_TYPE(reloc->rel.r_info);
reloc->addend = rela ? reloc->rela.r_addend : 0;
@@ -1230,7 +1231,6 @@ int elf_write_reloc(struct elf *elf, struct reloc *reloc)
struct section *rsec = reloc->sec;
int ret;
- reloc->rel.r_offset = reloc->offset;
reloc->rel.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type);
if (rsec->sh.sh_type == SHT_RELA) {