Dear group,
attached please find a very small program that reproducibly crashes on a
Debian Sarge and two distinct kubuntu 5.10 systems.
The crash does *not* occur when the line with the comment in the
Makefile is modified, so that either the "linker-script" *or* the
"-Wl,-Bsymbolic" statement is added to the link command line.
The problem is that I don't understand why this is so, but would love to
learn the background and understand the reason for the crash, when
neither the linker script nor the -Bsymbolic flag enters the link
command line.
(I've bought and currently read the "Loaders and Linkers" book by John
R. Levine, but my assembly skills are limited and so I make positive but
slow progress.)
Below I'm including a session log trying to debug the crash. I've
inserted newlines for clarity, and must add that I'm not able to
interprete all of the output.
I'd be very grateful for any advice about this problem or any help to
understand what causes it!
Thank you very much, and best regards,
Carsten
[EMAIL PROTECTED]:/mnt/WinD/System/Linux/TestCrash2$ make
g++ -Wall -g -c test.cpp -o test.o
g++ test.o -lGL -o test
g++ -fPIC -Wall -g -c dso.cpp -o dso.o
g++ -shared dso.o -o dso.so # linker-script # -Wl,-Bsymbolic
[EMAIL PROTECTED]:/mnt/WinD/System/Linux/TestCrash2$ ./test
1: Beginning...
2: glActiveStencilFaceEXT = 0x4009b69c
Ungültiger Maschinenbefehl
[EMAIL PROTECTED]:/mnt/WinD/System/Linux/TestCrash2$ gdb ./test
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-linux"...Using host libthread_db
library "/lib/tls/libthread_db.so.1".
(gdb) run
Starting program: /mnt/WinD/System/Linux/TestCrash2/test
1: Beginning...
2: glActiveStencilFaceEXT = 0x4009b69c
Program received signal SIGILL, Illegal instruction.
0x4009b6a0 in glActiveStencilFaceEXT () from /usr/X11R6/lib/libGL.so.1
(gdb) list
1 #include <stdio.h>
2 #include <dlfcn.h>
3
4
5 extern "C" { typedef void (*GetRendererT)(); }
6
7
8 int main(int ArgC, const char* ArgV[])
9 {
10 void* RendererDLL=dlopen("./dso.so", RTLD_NOW);
(gdb) where
#0 0x4009b6a0 in glActiveStencilFaceEXT () from /usr/X11R6/lib/libGL.so.1
#1 0x00200206 in ?? ()
#2 0x40b7e8e1 in GetRenderer () at dso.cpp:14
#3 0x08048700 in main (ArgC=1, ArgV=0xbffff854) at test.cpp:16
(gdb) bt full
#0 0x4009b6a0 in glActiveStencilFaceEXT () from /usr/X11R6/lib/libGL.so.1
No symbol table info available.
#1 0x00200206 in ?? ()
No symbol table info available.
#2 0x40b7e8e1 in GetRenderer () at dso.cpp:14
No locals.
#3 0x08048700 in main (ArgC=1, ArgV=0xbffff854) at test.cpp:16
RendererDLL = (void *) 0x804a360
GetRenderer = 0x40b7e874 <GetRenderer>
(gdb) x/4i $pc
0x4009b6a0 <glActiveStencilFaceEXT+4>: (bad)
0x4009b6a1 <glActiveStencilFaceEXT+5>: (bad)
0x4009b6a2 <glActiveStencilFaceEXT+6>: jmp *0xaf0(%eax)
0x4009b6a8 <glActiveStencilFaceEXT+12>: int3
(gdb) x/10i $pc-15
0x4009b691 <glVertexAttribs4hvNV+21>: int3
0x4009b692 <glVertexAttribs4hvNV+22>: int3
0x4009b693 <glVertexAttribs4hvNV+23>: int3
0x4009b694 <glVertexAttribs4hvNV+24>: int3
0x4009b695 <glVertexAttribs4hvNV+25>: int3
0x4009b696 <glVertexAttribs4hvNV+26>: int3
0x4009b697 <glVertexAttribs4hvNV+27>: int3
0x4009b698 <glVertexAttribs4hvNV+28>: int3
0x4009b699 <glVertexAttribs4hvNV+29>: int3
0x4009b69a <glVertexAttribs4hvNV+30>: int3
(gdb) info registers
eax 0x4009b69d 1074378397
ecx 0x402aee00 1076555264
edx 0x927 2343
ebx 0x40b7fb40 1085799232
esp 0xbffff788 0xbffff788
ebp 0xbffff7a8 0xbffff7a8
esi 0x4009b69c 1074378396
edi 0xbffff85c -1073743780
eip 0x4009b6a0 0x4009b6a0
eflags 0x210202 2163202
cs 0x73 115
ss 0x7b 123
ds 0x7b 123
es 0x7b 123
fs 0x0 0
gs 0x33 51
(gdb) info shared
From To Syms Read Shared Object Library
0x4004abb0 0x4007a4da Yes /usr/X11R6/lib/libGL.so.1
0x400da180 0x40136b60 Yes /usr/lib/libstdc++.so.5
0x4015c530 0x40174020 Yes /lib/tls/libm.so.6
0x4017c810 0x40181b20 Yes /lib/libgcc_s.so.1
0x40199760 0x40291168 Yes /lib/tls/libc.so.6
0x402b9eb0 0x402badc0 Yes /lib/tls/libdl.so.2
0x403708c0 0x40936afc Yes /usr/lib/libGLcore.so.1
0x40a0d310 0x40a0d368 Yes /usr/lib/tls/libnvidia-tls.so.1
0x40a12990 0x40a1c490 Yes /usr/X11R6/lib/libXext.so.6
0x40a2f4a0 0x40a9fa20 Yes /usr/X11R6/lib/libX11.so.6
0x40000c00 0x40011eaf Yes /lib/ld-linux.so.2
0x40b7e780 0x40b7e940 Yes ./dso.so
(gdb) quit
The program is running. Exit anyway? (y or n) y
all: test dso.so
test: test.o
g++ $+ -lGL -o $@
dso.so: dso.o
g++ -shared $+ -o $@ # linker-script # -Wl,-Bsymbolic
dso.o : dso.cpp
g++ -fPIC -Wall -g -c $< -o $@
%.o : %.cpp
g++ -Wall -g -c $< -o $@
clean:
rm -f $(shell find . -name "*~")
rm -f $(shell find . -name "test")
rm -f $(shell find . -name "*.o")
rm -f $(shell find . -name "*.so")
#include <stdio.h>
#define GLX_GLXEXT_LEGACY
#include <GL/glx.h>
PFNGLACTIVESTENCILFACEEXTPROC glActiveStencilFaceEXT=NULL;
extern "C" void GetRenderer()
{
printf("1: Beginning...\n");
glActiveStencilFaceEXT=(PFNGLACTIVESTENCILFACEEXTPROC)glXGetProcAddressARB((const GLubyte*)"glActiveStencilFaceEXT");
printf("2: glActiveStencilFaceEXT = %p\n", glActiveStencilFaceEXT);
if (glActiveStencilFaceEXT!=NULL) glActiveStencilFaceEXT(GL_FRONT);
printf("3: Still here? (I never see this on my machine.)\n");
}
VERSION { MyVersion { global: GetRenderer; local: *; }; }
#include <stdio.h>
#include <dlfcn.h>
extern "C" { typedef void (*GetRendererT)(); }
int main(int ArgC, const char* ArgV[])
{
void* RendererDLL=dlopen("./dso.so", RTLD_NOW);
if (!RendererDLL) { printf("%s\n", dlerror()); return 1; }
GetRendererT GetRenderer=(GetRendererT)dlsym(RendererDLL, "GetRenderer");
if (!GetRenderer) { printf("Could not get the address of the GetRenderer() function.\n"); dlclose(RendererDLL); return 1; }
GetRenderer();
printf("Success!\n");
dlclose(RendererDLL);
return 0;
}
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus