This question and your related RTLD_GLOBAL question concern the semantics of a dynamic loader allowing undefined characters in shared libraries that it loads. I was hoping to find an explicit link to the documentation that would explain what you see, but I could not do it. However, I can make an observation that can explain what is happening.
If we run verbosity, we will see that the python library is trying to load two shared libraries before the failure:
bash-3.2$ PYTHONVERBOSE=1 ./main 2>&1 | grep -i dlopen dlopen(".../python2.7/lib-dynload/_locale.so", 2); dlopen(".../python2.7/lib-dynload/_ctypes.so", 2);
Given that the former succeeds, we know that usually the dynamic loader resolves undefined characters against the namespace of the calling library. And actually, as you noticed in the comments on your other question, this even works when there are two versions of the python library, i.e. dlopen() executed by python libraries according to their respective namespaces. So far it sounds the way you want. But why is _ctypes.so not loading?
We know that _PyModule_GetDict is the symbol that _locale.so called so as not to load into your other question; and that he obviously works here. We also know that the _PyBuffer_Type character _PyBuffer_Type not work here. What is the difference between these two characters? Search them in python library:
bash-3.2$ nm libpython2.7.dylib | grep _PyModule_GetDict 00000000000502c0 T _PyModule_GetDict bash-3.2$ nm libpython2.7.dylib | grep _PyBuffer_Type 0000000000154f90 D _PyBuffer_Type
_PyModule_GetDict is a Text (code) character, while _PyBuffer_Type is a Data character.
Therefore, based on this empirical data, I suspect that the dynamic loader will allow undefined characters against RTLD_LOCAL code characters of the calling library, but not RTLD_LOCAL data characters. Perhaps someone may point to an explicit link.
source share