lkml.org 
[lkml]   [2022]   [Dec]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH v2 5/8] objtool: reduce memory usage of struct reloc
Use a smaller type for the relocation type and move it to a location in
the structure where it avoids wasted padding bytes.

Technically ELF could use up to four bytes for the type.
But until now only types up to number 43 have been defined.

Reduce the size of struct reloc on x86_64 from 120 to 112 bytes.
This structure is allocated a lot and never freed.

This reduces maximum memory usage while processing vmlinux.o from
3035668 KB to 2919716 KB (-3.8%) on my notebooks "localmodconfig".

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/objtool/elf.c | 3 +++
tools/objtool/include/objtool/elf.h | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index ee355beb0d82..182452adaa71 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -1474,5 +1474,8 @@ void elf_close(struct elf *elf)

void elf_reloc_set_type(struct reloc *reloc, int type)
{
+ if (type >= (1U << (8 * sizeof(reloc->type))))
+ WARN("reloc->type out of range: %d", type);
+
reloc->type = type;
}
diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
index 33ec6cf72325..2b5becad5a0a 100644
--- a/tools/objtool/include/objtool/elf.h
+++ b/tools/objtool/include/objtool/elf.h
@@ -77,10 +77,10 @@ struct reloc {
struct symbol *sym;
struct list_head sym_reloc_entry;
unsigned long offset;
- unsigned int type;
s64 addend;
int idx;
bool jump_table_start;
+ unsigned char type;
};

void elf_reloc_set_type(struct reloc *reloc, int type);
--
2.39.0

\
 
 \ /
  Last update: 2023-03-26 23:21    [W:0.275 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site