objtool: initialize all of struct elf

Function elf_open_read() only zero initializes the initial part of
allocated struct elf; num_relocs member was recently added outside the
zeroed part so that it was left uninitialized, resulting in build failures
on some systems.

The partial initialization is a relic of times when struct elf had large
hash tables embedded. This is no longer the case so remove the trap and
initialize the whole structure instead.

Fixes: eb0481bbc4 ("objtool: Fix reloc_hash size")
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/20230629102051.42E8360467@lion.mk-sys.cz
This commit is contained in:
Michal Kubecek 2023-06-29 12:05:05 +02:00 committed by Peter Zijlstra
parent 06c2afb862
commit 9f71fbcde2
1 changed files with 1 additions and 1 deletions

View File

@ -1005,7 +1005,7 @@ struct elf *elf_open_read(const char *name, int flags)
perror("malloc");
return NULL;
}
memset(elf, 0, offsetof(struct elf, sections));
memset(elf, 0, sizeof(*elf));
INIT_LIST_HEAD(&elf->sections);