[PATCH 00/22] objtool: Reduce memory usage with CONFIG_DEBUG_INFO

From: Josh Poimboeuf
Date: Tue May 30 2023 - 13:21:38 EST

DWARF uses a LOT of relocations, causing objtool to need a LOT of memory
for processing vmlinux.o.

In the worst case of an allyesconfig+CONFIG_DEBUG_INFO kernel, DWARF
creates almost 200 million relocations, ballooning objtool's peak heap
usage to 53GB. These patches reduce that to 25GB.

On a distro-type kernel with kernel IBT enabled, they reduce objtool's
peak heap usage from 4.2GB to 2.8GB.

They also improve the runtime significantly (from 2m50s to 1m54s on my
system with allyesconfig+CONFIG_DEBUG_INFO), though most of that comes
from fixing the size calculation for reloc_hash.

Josh Poimboeuf (22):
objtool: Tidy elf.h
objtool: Remove flags argument from elf_create_section()
objtool: Improve reloc naming
objtool: Consolidate rel/rela handling
objtool: Fix reloc_hash size
objtool: Add mark_sec_changed()
objtool: Add elf_create_section_pair()
objtool: Keep GElf_Rel[a] structs synced
objtool: Don't free memory in elf_close()
objtool: Add for_each_reloc()
objtool: Allocate relocs in advance for new rela sections
objtool: Get rid of reloc->list
objtool: Get rid of reloc->idx
objtool: Get rid of reloc->offset
objtool: Get rid of reloc->type
objtool: Get rid of reloc->addend
objtool: Get rid of reloc->jump_table_start
objtool: Shrink reloc->sym_reloc_entry
objtool: Shrink elf hash nodes
objtool: Get rid of reloc->rel[a]
objtool: Free insns when done
objtool: Skip reading DWARF section data

tools/objtool/arch/powerpc/include/arch/elf.h | 11 +-
tools/objtool/arch/x86/decode.c | 6 +-
tools/objtool/arch/x86/include/arch/elf.h | 11 +-
tools/objtool/arch/x86/special.c | 6 +-
tools/objtool/check.c | 429 +++++++-------
tools/objtool/elf.c | 537 +++++++-----------
tools/objtool/include/objtool/elf.h | 326 ++++++++---
tools/objtool/orc_gen.c | 8 +-
tools/objtool/special.c | 4 +-
9 files changed, 698 insertions(+), 640 deletions(-)