diff options
author | Alan Maguire <alan.maguire@oracle.com> | 2023-02-21 15:48:41 +0000 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-02-28 12:48:52 -0300 |
commit | 5851040e2468ba044bb88cb8ca48bdeb4b364991 (patch) | |
tree | 5b9ac6e057d26d90bd997bdf7a0ff1d872d7644c | |
parent | 721ca66d5be462b28ba07a79e72d48e5e5a6959e (diff) | |
download | pahole-5851040e2468ba044bb88cb8ca48bdeb4b364991.tar.gz |
dwarf_loader: Fix parameter location retrieval for location lists
dwarf_getlocation() does not work for location lists; use
dwarf_getlocations() instead. For parameters we are only interested in
the first expr - the location on function entry.
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Tested-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Hao Luo <haoluo@google.com>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: KP Singh <kpsingh@chromium.org>
Cc: Kui-Feng Lee <sinquersw@gmail.com>
Cc: Martin KaFai Lau <martin.lau@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stanislav Fomichev <sdf@google.com>
Cc: Timo Beckers <timo@incline.eu>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/1676994522-1557-3-git-send-email-alan.maguire@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | dwarf_loader.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/dwarf_loader.c b/dwarf_loader.c index 73e36704..17f2e6e2 100644 --- a/dwarf_loader.c +++ b/dwarf_loader.c @@ -8,6 +8,7 @@ #include <dirent.h> #include <dwarf.h> #include <elfutils/libdwfl.h> +#include <elfutils/version.h> #include <errno.h> #include <fcntl.h> #include <fnmatch.h> @@ -1073,6 +1074,7 @@ static struct parameter *parameter__new(Dwarf_Die *die, struct cu *cu, struct parameter *parm = tag__alloc(cu, sizeof(*parm)); if (parm != NULL) { + Dwarf_Addr base, start, end; bool has_const_value; Dwarf_Attribute attr; struct location loc; @@ -1115,10 +1117,18 @@ static struct parameter *parameter__new(Dwarf_Die *die, struct cu *cu, * between these parameter representations. See * ftype__recode_dwarf_types() below for how this is handled. */ - parm->has_loc = dwarf_attr(die, DW_AT_location, &attr) != NULL; has_const_value = dwarf_attr(die, DW_AT_const_value, &attr) != NULL; + parm->has_loc = dwarf_attr(die, DW_AT_location, &attr) != NULL; + /* dwarf_getlocations() handles location lists; here we are + * only interested in the first expr. + */ if (parm->has_loc && - attr_location(die, &loc.expr, &loc.exprlen) == 0 && +#if _ELFUTILS_PREREQ(0, 157) + dwarf_getlocations(&attr, 0, &base, &start, &end, + &loc.expr, &loc.exprlen) > 0 && +#else + dwarf_getlocation(&attr, &loc.expr, &loc.exprlen) == 0 && +#endif loc.exprlen != 0) { int expected_reg = cu->register_params[param_idx]; Dwarf_Op *expr = loc.expr; |