solaris, dlopen 加载动态库崩溃,请帮助分析多谢

solaris, dlopen 加载动态库崩溃,请帮助分析谢谢

solaris, dlopen 加载动态库崩溃,

崩溃时候的堆栈如下

  [1] _memcpy(0xfdae00, 0x1004000, 0x4a543b6d, 0x0, 0x4, 0xfffffffffffffff8), at 0x7fba0720 
  [2] std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__clone(0x7723750c, 0x0, 0x4a616e75, 0xf07b38, 0x7cf2125c, 0xf30cf0), at 0x7ccdaf60 
  [3] std::basic_string<char,std::char_traits<char>,std::allocator<char> >::reserve(0x7723750c, 0xe, 0xf30cf7, 0xf30cf8, 0xf30cf8, 0x0), at 0x7ccd51ac 
  [4] std::__copy<const char*,std::back_insert_iterator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,int>(0xffbfefb8, 0x77236bd3, 0x77236bd4, 0xffbfefb4, 0xffbfefb3, 0x1), at 0x771f3360 
  [5] std::_Init_timeinfo(0x772373c8, 0x77236a94, 0x77237470, 0x77236bcc, 0xe, 0x77232cc8), at 0x771f14a4 
  [6] std::_Locale_impl::make_classic_locale(0x772372d0, 0x772373b8, 0x77237470, 0x772375c0, 0x772375b4, 0x772375a8), at 0x771d8880 
  [7] std::locale::_S_initialize(0x1, 0x0, 0x77232cc8, 0x1a4, 0x599a0, 0x0), at 0x771d9344 
  [8] __SLIP.INIT_A(0x0, 0x29a350, 0x7a9a0000, 0x77212a68, 0xfffe7bd0, 0x772128a4), at 0x771beb68 
  [9] __STATIC_CONSTRUCTOR(0x0, 0x7aaeaf74, 0xfffdd7c0, 0x8, 0x13984, 0x7cf2125c), at 0x771bede4 
  [10] 0x77212994(0x0, 0x7faf1f30, 0x30, 0x7fb01fe8, 0x20000000, 0x40000000), at 0x77212994 
  [11] call_init(0x400000, 0x80000, 0x7fbee7c4, 0x7faf1558, 0xffffffff, 0x0), at 0x7fbc0254 
  [12] dlmopen_intn(0x7fbee0c4, 0xfff610, 0xd02, 0x7fb50d80, 0x0, 0x0), at 0x7fbc56d4 
  [13] dlmopen_check(0x7fbee0c4, 0xfff610, 0x102, 0x7fb50d80, 0xffbff33c, 0x0), at 0x7fbc5818 
  [14] _dlopen(0xfff610, 0x102, 0x29c6a9, 0x0, 0x0, 0x0), at 0x7fbc58d4 
=>[15] load_dynamic_library(), line 69 in "xxx.c"



其中 =>[15] load_dynamic_library(), line 69 in "xxx.c" 
的 load_dynamic_library 是我写的函数, 其中运行到如下的语句就崩溃了

libc = dlopen("**.so",RTLD_NOW|RTLD_GLOBAL);

我检查过 "**.so" 的路径是没有问题的,文件存在 ,

兄弟们帮助分析一下吧,谢谢











------解决方案--------------------
记得用 dlopen dlclose 之类的 应用程序 gcc 编译时 要加 一个编译选项 -rdynamic
------解决方案--------------------
你怎么编译的?
------解决方案--------------------
C/C++ code
       #include <stdio.h>
       #include <stdlib.h>
       #include <dlfcn.h>

       int
       main(int argc, char **argv)
       {
           void *handle;
           double (*cosine)(double);
           char *error;

           handle = dlopen("libm.so", RTLD_LAZY);
           if (!handle) {
               fprintf(stderr, "%s\n", dlerror());
               exit(EXIT_FAILURE);
           }

           dlerror();    /* Clear any existing error */

           /* Writing: cosine = (double (*)(double)) dlsym(handle, "cos");
              would seem more natural, but the C99 standard leaves
              casting from "void *" to a function pointer undefined.
              The assignment used below is the POSIX.1-2003 (Technical
              Corrigendum 1) workaround; see the Rationale for the
              POSIX specification of dlsym(). */

           *(void **) (&cosine) = dlsym(handle, "cos");

           if ((error = dlerror()) != NULL)  {
               fprintf(stderr, "%s\n", error);
               exit(EXIT_FAILURE);
           }

           printf("%f\n", (*cosine)(2.0));
           dlclose(handle);
           exit(EXIT_SUCCESS);
       }