summaryrefslogtreecommitdiff
path: root/addr2line.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-10 03:20:53 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-10 03:20:53 (GMT)
commitbe7cc583704ad9d3d5b1395cd516cc1b6e3584b9 (patch)
tree2b04950dc6f8aa90b2733da423226619e710233c /addr2line.c
parent3727e06606a3b54b0837e197e4b1424642b391fd (diff)
* configure.in: always check dladdr(1).
* addr2line.c (fill_lines): show the line number in C backtrace if ruby is built without --enable-shared (PIE) on Linux. patch is originally by Shinichiro Hamaji https://twitter.com/shinh/status/441957774264504321 NOTE: ld doesn't insert __executable_start for PIE. dladdr(3)'s argument must be a function pointer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'addr2line.c')
-rw-r--r--addr2line.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/addr2line.c b/addr2line.c
index 92ff6b1..9493cf1 100644
--- a/addr2line.c
+++ b/addr2line.c
@@ -514,6 +514,14 @@ fill_lines(int num_traces, void **traces, char **syms, int check_debuglink,
size_t len;
if (get_path_from_symbol(syms[i], &path, &len) &&
!strncmp(path, binary_filename, len)) {
+#if defined(HAVE_DLADDR) && defined(__pie__) && defined(__linux__)
+ if (ehdr->e_type == ET_DYN && lines[i].base_addr == 0) {
+ Dl_info info;
+ if (dladdr(fill_lines, &info)) {
+ lines[i].base_addr = (unsigned long)info.dli_fbase;
+ }
+ }
+#endif
lines[i].line = -1;
}
}