Carsten Fuchs <[EMAIL PROTECTED]> writes: > I'd be very grateful for any advice about this problem or any help to > understand what causes it!
The program crashes because (as can be seen in your "info shared" output), libGL.so.1 is loaded before your dso.so, and because it *defines* a (non-writable) .text symbol glActiveStencilFaceEXT(). The rules for UNIX symbol resolution are that the first instance of a symbol "wins", and all subsequent uses of that symbol bind to that first definition. This allows one to redefine e.g. malloc(), and have all calls to malloc() from other DSOs go to that "custom definition". So here is what happens: 1. 0x4009b69c glActiveStencilFaceEXT .text definition in libGL 2. 0xNNNNNNNN glActiveStencilFaceEXT=NULL; .bss definition in dso.so; ignored void GetRenderer() { glActiveStencilFaceEXT= ...; // 3. here you *intend* to assign value to symbol 2, // but the linker binds reference to "glActiveStencilFaceEXT" // to symbol 1, because it came *first* } Since symbol 1 is in a non-writable .text section, you loose. In effect, your crash is equivalent to: extern int *malloc; int main() { int i; malloc = &i; return 0; } Naturally, if you localize all symbols in dso with a linker script, then at point 3 the reference is to local glActiveStencilFaceEXT, and you win. The -Bsymbolic has much the same effect. If you symply rename "glActiveStencilFaceEXT" to e.g. "pGlActiveStencilFaceEXT" at points 2 and 3, the problem will also go away. You may also wish to run your (crashing) test like this: LD_DEBUG=symbols,bindings ./test 2>&1 | grep glActiveStencilFaceEXT and study the output. Cheers, -- In order to understand recursion you must first understand recursion. Remove /-nsp/ for email. _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus