Index: test/fiddle/test_handle.rb =================================================================== --- test/fiddle/test_handle.rb (revision 46310) +++ test/fiddle/test_handle.rb (working copy) @@ -153,22 +153,37 @@ handle = Handle::NEXT refute_nil handle['malloc'] rescue - # BSD - # - # If dlsym() is called with the special handle RTLD_NEXT, then the search - # for the symbol is limited to the shared objects which were loaded after - # the one issuing the call to dlsym(). Thus, if the function is called - # from the main program, all the shared libraries are searched. If it is - # called from a shared library, all subsequent shared libraries are - # searched. RTLD_NEXT is useful for implementing wrappers around library - # functions. For example, a wrapper function getpid() could access the - # "real" getpid() with dlsym(RTLD_NEXT, "getpid"). (Actually, the dlfunc() - # interface, below, should be used, since getpid() is a function and not a - # data object.) - # --- FreeBSD 8.0 dlsym(3) - require 'objspace' - handle = Handle::NEXT - refute_nil handle['Init_objspace'] + begin + # BSD + # + # If dlsym() is called with the special handle RTLD_NEXT, then the search + # for the symbol is limited to the shared objects which were loaded after + # the one issuing the call to dlsym(). Thus, if the function is called + # from the main program, all the shared libraries are searched. If it is + # called from a shared library, all subsequent shared libraries are + # searched. RTLD_NEXT is useful for implementing wrappers around library + # functions. For example, a wrapper function getpid() could access the + # "real" getpid() with dlsym(RTLD_NEXT, "getpid"). (Actually, the dlfunc() + # interface, below, should be used, since getpid() is a function and not a + # data object.) + # --- FreeBSD 8.0 dlsym(3) + require 'objspace' + handle = Handle::NEXT + refute_nil handle['Init_objspace'] + rescue + # AIX + # + # The behavior of AIX for RTLD_NEXT is the same as that of BSD. + # However, the problem is that on AIX, Ruby's extension libraries do not + # export their symbols, because they are loaded not by dlopen(3)/dlsym(3) + # but by load(3) (See dln.c). This means 'Init_objspace' is not the search + # target of RTLD_NEXT and the test above results in nil. + # Fortunately, on AIX, helper.rb creates and loads a dummy shared library, + # libaixdltest.so, which contains 'strcpy' and some other functions, + # so we can take advantage of it for testing RTLD_NEXT. + handle = Handle::NEXT + refute_nil handle['strcpy'] + end end end unless /mswin|mingw/ =~ RUBY_PLATFORM