Version française
Home     About     Download     Resources     Contact us    
Browse thread
THREADED_CODE: Why CODE32 defined on x86-64?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Jones <rich@a...>
Subject: THREADED_CODE: Why CODE32 defined on x86-64?

Why is CODE32 defined on the x86-64 architecture?  This architecture
has 64 bit pointers, and it seems like it's only by luck that the
bytecode interpreter normally works.

In particular, if you have the interpreter in a shared library, or (I
assume) address-space randomization, then the jump table is located
above the 4GB boundary, and the bytecode interpreter segfaults as soon
as it tries to jump to the first instruction.

I had to apply the following patch to allow the bytecode interpreter
to work in a shared library:

--- ocaml-3.09.0.orig/configure 2005-09-24 10:19:09.000000000 +0100
+++ ocaml-3.09.0/configure      2005-11-16 14:59:56.000000000 +0000
@@ -291,9 +291,7 @@
     exe=".exe"
     ostype="Cygwin";;
   gcc*,x86_64-*-linux*)
-    bytecccompopts="-fno-defer-pop $gcc_warnings"
-    # Tell gcc that we can use 32-bit code addresses for threaded code
-    echo "#define ARCH_CODE32" >> m.h;;
+    bytecccompopts="-fno-defer-pop $gcc_warnings";;
   gcc*)
     bytecccompopts="-fno-defer-pop $gcc_warnings";;
 esac


Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com