btf_loader: Initialize function->lexblock.tags to fix segfault in pdwtags

pdwtags -F btf vmlinux

Was segfaulting when trying to iterate on the function main lexblock,
which was zeroed instead of INIT_LIST_HEAD'ed, fix it.

This also made pfunct misbehave when used with BTF. pahole unnafected as
it doesn't try to go thru functions in most cases.

Fixes: ccf3eebfcd ("btf_loader: Add support for BTF_KIND_FUNC")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2020-10-02 16:07:16 -03:00
parent c815d26689
commit aee6808c47
1 changed files with 1 additions and 0 deletions

View File

@ -97,6 +97,7 @@ static int create_new_function(struct btf_elf *btfe, struct btf_type *tp, uint64
func->btf = 1;
func->proto.tag.tag = DW_TAG_subprogram;
func->proto.tag.type = type_id;
INIT_LIST_HEAD(&func->lexblock.tags);
func->name = name;
cu__add_tag_with_id(btfe->priv, &func->proto.tag, id);