Skip to content
Browse files

* 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
  • Loading branch information...
1 parent 3727e06 commit be7cc583704ad9d3d5b1395cd516cc1b6e3584b9 @nurse nurse committed Mar 10, 2014
Showing with 20 additions and 1 deletion.
  1. +11 −0 ChangeLog
  2. +8 −0 addr2line.c
  3. +1 −1 configure.in
View
11 ChangeLog
@@ -1,3 +1,14 @@
+Mon Mar 10 12:14:26 2014 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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.
+
Mon Mar 10 10:51:17 2014 ksss <co000ri@gmail.com>
* test/ruby/test_enumerator.rb (test_iterators): fix test for hash
View
8 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;
}
}
View
2 configure.in
@@ -1897,6 +1897,7 @@ AC_CHECK_FUNCS(cosh)
AC_CHECK_FUNCS(daemon)
AC_CHECK_FUNCS(dl_iterate_phdr)
AC_CHECK_FUNCS(dlopen)
+AC_CHECK_FUNCS(dladdr)
AC_CHECK_FUNCS(dup)
AC_CHECK_FUNCS(dup3)
AC_CHECK_FUNCS(eaccess)
@@ -2946,7 +2947,6 @@ else
DLEXT=so])
fi
if test "$rb_cv_dlopen:$load_relative" = yes:yes; then
- AC_CHECK_FUNCS(dladdr)
if test "$ac_cv_func_dladdr" = yes; then
LOAD_RELATIVE=1
fi

0 comments on commit be7cc58

Please sign in to comment.
Something went wrong with that request. Please try again.