ruby-changes:33226
From: naruse <ko1@a...>
Date: Mon, 10 Mar 2014 12:20:59 +0900 (JST)
Subject: [ruby-changes:33226] naruse:r45305 (trunk): * configure.in: always check dladdr(1).
naruse 2014-03-10 12:20:53 +0900 (Mon, 10 Mar 2014) New Revision: 45305 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45305 Log: * 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. Modified files: trunk/ChangeLog trunk/addr2line.c trunk/configure.in Index: configure.in =================================================================== --- configure.in (revision 45304) +++ configure.in (revision 45305) @@ -1897,6 +1897,7 @@ AC_CHECK_FUNCS(cosh) https://github.com/ruby/ruby/blob/trunk/configure.in#L1897 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 https://github.com/ruby/ruby/blob/trunk/configure.in#L2947 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 Index: ChangeLog =================================================================== --- ChangeLog (revision 45304) +++ ChangeLog (revision 45305) @@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Mar 10 12:14:26 2014 NARUSE, Yui <naruse@r...> + + * 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@g...> * test/ruby/test_enumerator.rb (test_iterators): fix test for hash Index: addr2line.c =================================================================== --- addr2line.c (revision 45304) +++ addr2line.c (revision 45305) @@ -514,6 +514,14 @@ fill_lines(int num_traces, void **traces https://github.com/ruby/ruby/blob/trunk/addr2line.c#L514 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; } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/