diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-09 15:06:22 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-09 15:06:22 +0000 |
| commit | 89e21a0c2f00811f8ed5c3af9a3b2efee985502c (patch) | |
| tree | 7ff256303c85a4e69cfee1e09d6b3137dfbbced2 /ruby.c | |
| parent | ed21868b28d33576e8f0da5214f8efdc0ad9ce99 (diff) | |
| download | ruby-89e21a0c2f00811f8ed5c3af9a3b2efee985502c.tar.gz ruby-89e21a0c2f00811f8ed5c3af9a3b2efee985502c.tar.xz ruby-89e21a0c2f00811f8ed5c3af9a3b2efee985502c.zip | |
* configure.in (load_relative): new option to enable load path
relative to libruby_so.
* ruby.c (ruby_init_loadpath_safe): added the case using dladdr().
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
| -rw-r--r-- | ruby.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -26,6 +26,9 @@ #ifdef __hpux #include <sys/pstat.h> #endif +#if defined(LOAD_RELATIVE) && defined(HAVE_DLADDR) +#include <dlfcn.h> +#endif #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -352,10 +355,16 @@ ruby_init_loadpath_safe(int safe_level) char *p; int rest; + libpath[0] = '\0'; #if defined _WIN32 || defined __CYGWIN__ GetModuleFileName(libruby, libpath, sizeof libpath); #elif defined(__EMX__) _execname(libpath, sizeof(libpath) - 1); +#elif defined(HAVE_DLADDR) + Dl_info dli; + if (dladdr(ruby_init_loadpath_safe, &dli)) { + strlcpy(libpath, dli.dli_fname, sizeof(libpath)); + } #endif libpath[sizeof(libpath) - 1] = '\0'; |
