* 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
This commit is contained in:
naruse 2014-03-10 03:20:53 +00:00
Родитель 3727e06606
Коммит be7cc58370
3 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -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> Mon Mar 10 10:51:17 2014 ksss <co000ri@gmail.com>
* test/ruby/test_enumerator.rb (test_iterators): fix test for hash * test/ruby/test_enumerator.rb (test_iterators): fix test for hash

Просмотреть файл

@ -514,6 +514,14 @@ fill_lines(int num_traces, void **traces, char **syms, int check_debuglink,
size_t len; size_t len;
if (get_path_from_symbol(syms[i], &path, &len) && if (get_path_from_symbol(syms[i], &path, &len) &&
!strncmp(path, binary_filename, 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; lines[i].line = -1;
} }
} }

Просмотреть файл

@ -1897,6 +1897,7 @@ AC_CHECK_FUNCS(cosh)
AC_CHECK_FUNCS(daemon) AC_CHECK_FUNCS(daemon)
AC_CHECK_FUNCS(dl_iterate_phdr) AC_CHECK_FUNCS(dl_iterate_phdr)
AC_CHECK_FUNCS(dlopen) AC_CHECK_FUNCS(dlopen)
AC_CHECK_FUNCS(dladdr)
AC_CHECK_FUNCS(dup) AC_CHECK_FUNCS(dup)
AC_CHECK_FUNCS(dup3) AC_CHECK_FUNCS(dup3)
AC_CHECK_FUNCS(eaccess) AC_CHECK_FUNCS(eaccess)
@ -2946,7 +2947,6 @@ else
DLEXT=so]) DLEXT=so])
fi fi
if test "$rb_cv_dlopen:$load_relative" = yes:yes; then if test "$rb_cv_dlopen:$load_relative" = yes:yes; then
AC_CHECK_FUNCS(dladdr)
if test "$ac_cv_func_dladdr" = yes; then if test "$ac_cv_func_dladdr" = yes; then
LOAD_RELATIVE=1 LOAD_RELATIVE=1
fi fi