Skip to content

Commit

Permalink
objtool: initialize all of struct elf
Browse files Browse the repository at this point in the history
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: eb0481b ("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
  • Loading branch information
Michal Kubecek authored and Peter Zijlstra committed Jul 10, 2023
1 parent 06c2afb commit 9f71fbc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/objtool/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 9f71fbc

Please sign in to comment.