Skip to content

Commit 9f71fbc

Browse files
mkubecekPeter Zijlstra
authored andcommitted
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: 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
1 parent 06c2afb commit 9f71fbc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/objtool/elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ struct elf *elf_open_read(const char *name, int flags)
10051005
perror("malloc");
10061006
return NULL;
10071007
}
1008-
memset(elf, 0, offsetof(struct elf, sections));
1008+
memset(elf, 0, sizeof(*elf));
10091009

10101010
INIT_LIST_HEAD(&elf->sections);
10111011

0 commit comments

Comments
 (0)