Project

General

Profile

Bug #9928 ยป test_NEXT_for_aix.patch

ReiOdaira (Rei Odaira), 06/10/2014 08:00 PM

View differences:

test/fiddle/test_handle.rb (working copy)
153 153
        handle = Handle::NEXT
154 154
        refute_nil handle['malloc']
155 155
      rescue
156
        # BSD
157
        #
158
        # If dlsym() is called with the special handle RTLD_NEXT, then the search
159
        # for the symbol is limited to the shared objects which were loaded after
160
        # the one issuing the call to dlsym().  Thus, if the function is called
161
        # from the main program, all the shared libraries are searched.  If it is
162
        # called from a shared library, all subsequent shared libraries are
163
        # searched.  RTLD_NEXT is useful for implementing wrappers around library
164
        # functions.  For example, a wrapper function getpid() could access the
165
        # "real" getpid() with dlsym(RTLD_NEXT, "getpid").  (Actually, the dlfunc()
166
        # interface, below, should be used, since getpid() is a function and not a
167
        # data object.)
168
        # --- FreeBSD 8.0 dlsym(3)
169
        require 'objspace'
170
        handle = Handle::NEXT
171
        refute_nil handle['Init_objspace']
156
        begin
157
          # BSD
158
          #
159
          # If dlsym() is called with the special handle RTLD_NEXT, then the search
160
          # for the symbol is limited to the shared objects which were loaded after
161
          # the one issuing the call to dlsym().  Thus, if the function is called
162
          # from the main program, all the shared libraries are searched.  If it is
163
          # called from a shared library, all subsequent shared libraries are
164
          # searched.  RTLD_NEXT is useful for implementing wrappers around library
165
          # functions.  For example, a wrapper function getpid() could access the
166
          # "real" getpid() with dlsym(RTLD_NEXT, "getpid").  (Actually, the dlfunc()
167
          # interface, below, should be used, since getpid() is a function and not a
168
          # data object.)
169
          # --- FreeBSD 8.0 dlsym(3)
170
          require 'objspace'
171
          handle = Handle::NEXT
172
          refute_nil handle['Init_objspace']
173
        rescue
174
          # AIX
175
          #
176
          # The behavior of AIX for RTLD_NEXT is the same as that of BSD.
177
          # However, the problem is that on AIX, Ruby's extension libraries do not
178
          # export their symbols, because they are loaded not by dlopen(3)/dlsym(3)
179
          # but by load(3) (See dln.c).  This means 'Init_objspace' is not the search
180
          # target of RTLD_NEXT and the test above results in nil.
181
          # Fortunately, on AIX, helper.rb creates and loads a dummy shared library,
182
          # libaixdltest.so, which contains 'strcpy' and some other functions,
183
          # so we can take advantage of it for testing RTLD_NEXT.
184
          handle = Handle::NEXT
185
          refute_nil handle['strcpy']
186
        end
172 187
      end
173 188
    end unless /mswin|mingw/ =~ RUBY_PLATFORM
174 189