[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libunwind-devel] [PATCH] elf: Follow .gnu_debuglink when resolving func
From: |
Dave Watson |
Subject: |
[Libunwind-devel] [PATCH] elf: Follow .gnu_debuglink when resolving function names |
Date: |
Sat, 4 Feb 2017 12:15:57 -0800 |
User-agent: |
Mutt/1.6.0 (2016-04-01) |
Currently we only look at the current image to resolve function names,
which requires debug info. Often the debug info is split to a different
file. os-linux.c does look in some distro's path in /usr/lib/debug%s,
this diff will also follow the commonly used .gnu_debuglink section.
---
src/elfxx.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/elfxx.c b/src/elfxx.c
index 25bd5a2..7b05f3f 100644
--- a/src/elfxx.c
+++ b/src/elfxx.c
@@ -312,11 +312,27 @@ elf_w (get_proc_name) (unw_addr_space_t as, pid_t pid,
unw_word_t ip,
unsigned long segbase, mapoff;
struct elf_image ei;
int ret;
+ Elf_W (Shdr) *shdr;
ret = tdep_get_elf_image (&ei, pid, ip, &segbase, &mapoff, NULL, 0);
if (ret < 0)
return ret;
+ shdr = elf_w (find_section) (&ei, ".gnu_debuglink");
+ if (shdr) {
+ char debug_path[PATH_MAX];
+ char *link = ((uint8_t *) ei.image) + shdr->sh_offset;
+ size_t link_len = shdr->sh_size;
+
+ strncpy(debug_path, link, link_len);
+ Debug(1, "Found debuglink section, following %s len %i\n", debug_path,
link_len);
+ munmap (ei.image, ei.size);
+
+ ret = elf_map_image(&ei, debug_path);
+ if (ret < 0)
+ return ret;
+ }
+
ret = elf_w (get_proc_name_in_image) (as, &ei, segbase, mapoff, ip, buf,
buf_len, offp);
munmap (ei.image, ei.size);
--
2.8.0-rc2
- [Libunwind-devel] [PATCH] elf: Follow .gnu_debuglink when resolving function names,
Dave Watson <=