Add _pei386_runtime_relocator support for dll's and executables.



git-svn-id: svn+ssh://svn.code.sf.net/p/mingw-w64/code/trunk@189 4407c894-4637-0410-b4f5-ada5f102cad1
diff --git a/mingw-w64-crt/ChangeLog b/mingw-w64-crt/ChangeLog
index 03ec856..90f02c6 100755
--- a/mingw-w64-crt/ChangeLog
+++ b/mingw-w64-crt/ChangeLog
@@ -1,3 +1,8 @@
+2007-10-22  20-40  <20-40@annonymous>
+
+	* crtexe.c: Add _pei386_runtime_relocator.
+	* crtdll.c: Likewise.
+
 2007-10-22  Kai Tietz  <kai.tietz@onevision.com>
 
 	* crtexe.c: Add exception handler basic routines.
diff --git a/mingw-w64-crt/crt64/crtdll.c b/mingw-w64-crt/crt64/crtdll.c
index e364ab2..88a8e46 100755
--- a/mingw-w64-crt/crt64/crtdll.c
+++ b/mingw-w64-crt/crt64/crtdll.c
@@ -26,6 +26,7 @@
 
 extern void __cdecl _initterm(_PVFV *,_PVFV *);
 extern void __main ();
+extern void _pei386_runtime_relocator (void);
 extern _CRTALLOC(".CRT$XIA") _PIFV __xi_a[];
 extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
 extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
@@ -173,6 +174,7 @@
 	if (! retcode)
 	  goto i__leave;
     }
+  _pei386_runtime_relocator ();
   if (retcode && dwReason == DLL_PROCESS_ATTACH)
     __main ();
   retcode = DllMain(hDllHandle,dwReason,lpreserved);
diff --git a/mingw-w64-crt/crt64/crtexe.c b/mingw-w64-crt/crt64/crtexe.c
index 5ef7b2a..cd11ca8 100755
--- a/mingw-w64-crt/crt64/crtexe.c
+++ b/mingw-w64-crt/crt64/crtexe.c
@@ -24,7 +24,7 @@
 #endif
 
 /* Hack, for bug in ld.  Will be removed soon.  */
-#define __ImageBase _ImageBase
+#define __ImageBase _image_base__
 /* This symbol is defined by ld.  */
 extern IMAGE_DOS_HEADER __ImageBase;
 
@@ -73,6 +73,7 @@
 static int has_cctor = 0;
 static _startupinfo startinfo;
 
+extern void _pei386_runtime_relocator (void);
 static CALLBACK long _gnu_exception_handler (EXCEPTION_POINTERS * exception_data);
 static LONG __mingw_vex(EXCEPTION_POINTERS * exception_data);
 
@@ -196,6 +197,7 @@
       __dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL);
     
     _CrtSetCheckCount (FALSE);
+    _pei386_runtime_relocator ();
     
     #ifdef _WIN64
     __asm__ __volatile__ (
diff --git a/mingw-w64-crt/crt64/pesect.c b/mingw-w64-crt/crt64/pesect.c
index e8558a0..ad85e72 100755
--- a/mingw-w64-crt/crt64/pesect.c
+++ b/mingw-w64-crt/crt64/pesect.c
@@ -4,7 +4,7 @@
 #error FIXME: Unsupported __ImageBase implementation.
 #else
 /* Hack, for bug in ld.  Will be removed soon.  */
-#define __ImageBase _ImageBase
+#define __ImageBase _image_base__
 /* This symbol is defined by the linker.  */
 extern IMAGE_DOS_HEADER __ImageBase;
 #endif