> Register dump:
>  CS:0023 SS:002b DS:002b ES:002b FS:0257 GS:0000
>  EIP:496706f8 ESP:49646944 EBP:4eb610a0 EFLAGS:00010297(  R- 
> 00  I S -A-P1C)
>  EAX:0041b6e2 EBX:00000000 ECX:49646948 EDX:49646944
>  ESI:4eb610a0 EDI:00000000
[snip]
> Backtrace:
> =>0 0x496706f8 (_init+0x13d4) (ebp=4eb610a0)
> 
> 0x496706f8 (_init+0x13d4):  jmp *0x4f0(%ebx)
> 
> Hope this helps....

Hmm, EBX is 0. That shouldn't happend. This is perhaps
because the GOT must be reloaded in EBX before the call.

Perhaps it worked for me by pure luck. A previous
function had set EBX to the GOT. Not very unlikely though.

Anyway, this new version works for me as well.

Index: wine/dlls/opengl32/make_opengl_norm
===================================================================
RCS file: /home/wine/wine/dlls/opengl32/make_opengl_norm,v
retrieving revision 1.2
diff -u -u -r1.2 make_opengl_norm
--- wine/dlls/opengl32/make_opengl_norm 2000/05/18 00:07:53     1.2
+++ wine/dlls/opengl32/make_opengl_norm 2000/05/20 10:30:06
@@ -1,5 +1,9 @@
 #!/usr/bin/perl -w
 
+my $i386 = 1;
+my $critical_section = 1;
+my $pic = 1;
+
 print "
 /* Auto-generated file... Do not edit ! */
 
@@ -9,10 +13,64 @@
 
 ";
 
+print '#define THUNK_STDCALL_TO_CDECL(stdcall_name, cdecl_name, argsize)' .
" \\\n";
+print '  asm("\t.globl\t" #stdcall_name "\n"' . " \\\n";
+print '    "\t.type\t" #stdcall_name ", @function\n"' . " \\\n";
+print '    #stdcall_name ":\n"' . " \\\n";
+print '    "\tmovl (%esp), %eax\n"' . " \\\n";
+print '    "\tleal " #argsize "(%esp), %edx\n"' . " \\\n";
+print '    "." #stdcall_name ":\n"' . " \\\n";
+print '    "\tmovl (%edx), %ecx\n"' . " \\\n";
+print '    "\tmovl %eax, (%edx)\n"' . " \\\n";
+print '    "\tmovl %ecx, %eax\n"' . " \\\n";
+print '    "\tsubl $4, %edx\n"' . " \\\n";
+print '    "\tleal (%esp), %ecx\n"' . " \\\n";
+print '    "\tcmpl %ecx, %edx\n"' . " \\\n";
+print '    "\tjge ." #stdcall_name "\n"' . " \\\n";
+if($critical_section) {
+    if($pic) {
+       print '    "\tcall ." #stdcall_name ".getgot.enter\n"' . " \\\n";
+       print '    "." #stdcall_name ".getgot.enter:\n"' . " \\\n";
+       print '    "\tpopl %ebx\n"' . " \\\n";
+       print '    "\taddl $_GLOBAL_OFFSET_TABLE_+[.-." #stdcall_name
".getgot.enter], %ebx\n"' . " \\\n";
+       print '    "\tpushl X11DRV_CritSection@GOT(%ebx)\n"' . " \\\n";
+       print '    "\tcall EnterCriticalSection@PLT\n"' . " \\\n";
+    } else {
+       print '    "\tpushl $X11DRV_CritSection\n"' . " \\\n";
+       print '    "\tcall EnterCriticalSection\n"' . " \\\n";
+    }
+}
+if($pic) {
+    print '    "\tcall ." #stdcall_name ".getgot.call\n"' . " \\\n";
+    print '    "." #stdcall_name ".getgot.call:\n"' . " \\\n";
+    print '    "\tpopl %ebx\n"' . " \\\n";
+    print '    "\taddl $_GLOBAL_OFFSET_TABLE_+[.-." #stdcall_name
".getgot.call], %ebx\n"' . " \\\n";
+    print '    "\tcall " #cdecl_name "@PLT\n"' . " \\\n";
+} else {
+    print '    "\tcall " #cdecl_name "\n"' . " \\\n";
+}
+if($critical_section) {
+    if($pic) {
+       print '    "\tcall ." #stdcall_name ".getgot.leave\n"' . " \\\n";
+       print '    "." #stdcall_name ".getgot.leave:\n"' . " \\\n";
+       print '    "\tpopl %ebx\n"' . " \\\n";
+       print '    "\taddl $_GLOBAL_OFFSET_TABLE_+[.-." #stdcall_name
".getgot.leave], %ebx\n"' . " \\\n";
+       print '    "\tpushl X11DRV_CritSection@GOT(%ebx)\n"' . " \\\n";
+       print '    "\tcall LeaveCriticalSection@PLT\n"' . " \\\n";
+    } else {
+       print '    "\tpushl $X11DRV_CritSection\n"' . " \\\n";
+       print '    "\tcall LeaveCriticalSection\n"' . " \\\n";
+    }
+}
+print '    "\taddl $" #argsize ", %esp\n"' . " \\\n";
+print '    "\tret\n"' . " \\\n";
+print '    "\t.size\t" #stdcall_name  ", .-" #stdcall_name "\n"' . " \\\n";
+print '  );' . "\n";
+
 #
 # Now, the functions from the include file
 #
-open(INC, "/usr/X11R6/include/GL/gl.h") || die "Could not open GL/gl.h";
+open(INC, "/usr/include/GL/gl.h") || die "Could not open GL/gl.h";
 while ($line = <INC>) {
     if ($line =~ /GLAPI.*GLAPIENTRY/) {
        # Start of a function declaration
@@ -22,9 +80,11 @@
        if (($name !~ /(MESA|PGI|ARB|EXT)/) ||
            ($name =~ /MultiTexCoord/) ||
            ($name =~ /ActiveTextureARB/)) {
+
            print
"/***********************************************************************\n"
;
            print " *\t\t$name\n";
            print " */\n";
+           print "\n/* " if $i386;
            print "$ret WINAPI wine_$name(";
            @rargs = ();
            @names = ();
@@ -61,32 +121,41 @@
            foreach (@rargs) {
                print ", $_";
            }
-           print ") {\n";
-           if ($ret !~ /void/) {
-               print "  $ret ret;\n";
-           }
-           print "  ENTER_GL();\n";
-           if ($ret !~ /void/) {
-               print "  ret = ";
+           if($i386) {
+               print ") */\n";
            } else {
-               print "  ";
+               print ") {\n";
            }
-           print "$name(";
-
-           $farg = shift @names;
-           if ($farg) {
-               print "$farg";
 
-               foreach (@names) {
-                   print ", $_";
+           if(!$i386) {
+               if ($ret !~ /void/) {
+                   print "  $ret ret;\n";
                }
+               print "  ENTER_GL();\n";
+               if ($ret !~ /void/) {
+                   print "  ret = ";
+               } else {
+                   print "  ";
+               }
+               print "$name(";
+               
+               $farg = shift @names;
+               if ($farg) {
+                   print "$farg";
+                   
+                   foreach (@names) {
+                       print ", $_";
+                   }
+               }
+               print ");\n";
+               print "  LEAVE_GL();\n";
+               if ($ret !~ /void/) {
+                   print "  return ret;\n";
+               }
+               print "}\n\n";
+           } else {
+               print "THUNK_STDCALL_TO_CDECL(wine_$name,$name," .
4*($#rargs+2) . ")\n\n";
            }
-           print ");\n";
-           print "  LEAVE_GL();\n";
-           if ($ret !~ /void/) {
-               print "  return ret;\n";
-           }
-           print "}\n\n";
        }
     }
 }





Reply via email to