aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/objtool/include
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@kernel.org>2023-05-30 10:21:04 -0700
committerJosh Poimboeuf <jpoimboe@kernel.org>2023-06-07 10:03:20 -0700
commitebcef730a19ba7ca446169f391d2e51722d68043 (patch)
tree970acb1cad172cfd1c44fea5f6c0fe76d2381210 /tools/objtool/include
parentobjtool: Allocate relocs in advance for new rela sections (diff)
downloadwireguard-linux-ebcef730a19ba7ca446169f391d2e51722d68043.tar.xz
wireguard-linux-ebcef730a19ba7ca446169f391d2e51722d68043.zip
objtool: Get rid of reloc->list
Now that all relocs are allocated in an array, the linked list is no longer needed. With allyesconfig + CONFIG_DEBUG_INFO: - Before: peak heap memory consumption: 49.02G - After: peak heap memory consumption: 45.56G Link: https://lore.kernel.org/r/71e7a2c017dbc46bb497857ec97d67214f832d10.1685464332.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Diffstat (limited to 'tools/objtool/include')
-rw-r--r--tools/objtool/include/objtool/elf.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
index a938cb1d4172..a09da208ddb8 100644
--- a/tools/objtool/include/objtool/elf.h
+++ b/tools/objtool/include/objtool/elf.h
@@ -33,14 +33,13 @@ struct section {
GElf_Shdr sh;
struct rb_root_cached symbol_tree;
struct list_head symbol_list;
- struct list_head reloc_list;
struct section *base, *rsec;
struct symbol *sym;
Elf_Data *data;
char *name;
int idx;
bool _changed, text, rodata, noinstr, init, truncate;
- struct reloc *reloc_data;
+ struct reloc *relocs;
};
struct symbol {
@@ -68,7 +67,6 @@ struct symbol {
};
struct reloc {
- struct list_head list;
struct hlist_node hash;
union {
GElf_Rela rela;
@@ -197,6 +195,11 @@ static inline void mark_sec_changed(struct elf *elf, struct section *sec,
elf->changed |= changed;
}
+static inline unsigned int sec_num_entries(struct section *sec)
+{
+ return sec->sh.sh_size / sec->sh.sh_entsize;
+}
+
#define for_each_sec(file, sec) \
list_for_each_entry(sec, &file->elf->sections, list)
@@ -210,10 +213,15 @@ static inline void mark_sec_changed(struct elf *elf, struct section *sec,
sec_for_each_sym(__sec, sym)
#define for_each_reloc(rsec, reloc) \
- list_for_each_entry(reloc, &rsec->reloc_list, list)
+ for (int __i = 0, __fake = 1; __fake; __fake = 0) \
+ for (reloc = rsec->relocs; \
+ __i < sec_num_entries(rsec); \
+ __i++, reloc++)
#define for_each_reloc_from(rsec, reloc) \
- list_for_each_entry_from(reloc, &rsec->reloc_list, list)
+ for (int __i = reloc->idx; \
+ __i < sec_num_entries(rsec); \
+ __i++, reloc++)
#define OFFSET_STRIDE_BITS 4
#define OFFSET_STRIDE (1UL << OFFSET_STRIDE_BITS)