Looks like ld doesn't like specifying "-fno-leading-underscore" for anything else...
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 26 Mar 2010 08:58:45 +0000 (08:58 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 26 Mar 2010 08:58:45 +0000 (08:58 +0000)
Since we have switched to non-prefixed symbols, we need to deal with 2 kinds of symbols that the compiler doesn't handle for us. 1.) __image_base__ is still defined the same way by ld, but since gcc doesn't give us an underscore anymore, we need to specify it on our own. 2.) __MINGW_IMP_SYMBOL, which is a hacky way of declaring a symbol dllimport, by prefixing it with __imp_ also needs special treatment. Fix these issues by adding appropriate macros to _mingw.h and removing the broken and duplicate definitions from multiple .c files.

svn path=/branches/ros-amd64-bringup/; revision=46460

reactos/ReactOS-amd64.rbuild
reactos/include/crt/_mingw.h
reactos/lib/3rdparty/mingw/crt_handler.c
reactos/lib/3rdparty/mingw/crtexe.c
reactos/lib/3rdparty/mingw/pesect.c
reactos/lib/3rdparty/mingw/pseudo-reloc.c

index 4faae30..6d9f864 100644 (file)
@@ -28,6 +28,7 @@
                        <compilerflag>-ftracer</compilerflag>
                        <compilerflag>-momit-leaf-frame-pointer</compilerflag>
                </if>
+               <compilerflag>-fms-extensions</compilerflag>
                <compilerflag>-mpreferred-stack-boundary=4</compilerflag>
                <compilerflag compiler="midl">-m64 --win64</compilerflag>
                <!-- compilerflag compiler="cc,cxx">-gstabs+</compilerflag -->
@@ -44,6 +45,7 @@
                <linkerflag>--unique=.eh_frame</linkerflag>
                <linkerflag>-static</linkerflag>
                <linkerflag>-fno-leading-underscore</linkerflag>
+               <linkerflag>-shared</linkerflag>
                <linkerflag>--exclude-all-symbols</linkerflag>
        </group>
 
index d5b9d37..2ee41f2 100644 (file)
@@ -197,15 +197,33 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case.  */
 #define _CRT_UNUSED(x) (void)x
 #endif
 
+#if defined(__x86__)
 #define __MINGW_USE_UNDERSCORE_PREFIX 1
+#else
+#define __MINGW_USE_UNDERSCORE_PREFIX 0
+#endif
 
 #if __MINGW_USE_UNDERSCORE_PREFIX == 0
-#define __MINGW_IMP_SYMBOL(sym)        _imp_##sym
+#define __MINGW_IMP_SYMBOL(sym)        __imp_##sym
 #define __MINGW_USYMBOL(sym) sym
 #else
 #define __MINGW_IMP_SYMBOL(sym)        _imp__##sym
 #define __MINGW_USYMBOL(sym) _##sym
 #endif
 
+#if defined(__x86__)
+/* Hack, for bug in ld.  Will be removed soon.  */
+#define __ImageBase _image_base__
+/* This symbol is defined by the linker.  */
+extern char __ImageBase;
+#elif defined(__x86_64__)
+/* Hack, for bug in ld.  Will be removed soon.  */
+#define __ImageBase __image_base__
+/* This symbol is defined by the linker.  */
+extern char __ImageBase;
+#else
+#error FIXME: Unsupported __ImageBase implementation.
+#endif
+
 #endif /* !_INC_MINGW */
 
index b87e14e..19fee7c 100644 (file)
 #include <signal.h>
 #include <stdio.h>
 
-#if defined (_WIN64) && defined (__ia64__)
-#error FIXME: Unsupported __ImageBase implementation.
-#else
-#define __ImageBase _image_base__
-/* This symbol is defined by the linker.  */
-extern IMAGE_DOS_HEADER __ImageBase;
-#endif
-
 #pragma pack(push,1)
 typedef struct _UNWIND_INFO {
   BYTE VersionAndFlags;
index 409b76b..9834cb2 100644 (file)
@@ -32,11 +32,6 @@ extern char *** __MINGW_IMP_SYMBOL(__initenv);
 #define __initenv (* __MINGW_IMP_SYMBOL(__initenv))
 #endif
 
-/* Hack, for bug in ld.  Will be removed soon.  */
-#define __ImageBase _image_base__
-/* This symbol is defined by ld.  */
-extern IMAGE_DOS_HEADER __ImageBase;
-
 extern void _fpreset (void);
 #define SPACECHAR _T(' ')
 #define DQUOTECHAR _T('\"')
index 2e835f2..c51a6d2 100644 (file)
@@ -7,15 +7,6 @@
 #include <windows.h>
 #include <string.h>
 
-#if defined (_WIN64) && defined (__ia64__)
-#error FIXME: Unsupported __ImageBase implementation.
-#else
-/* Hack, for bug in ld.  Will be removed soon.  */
-#define __ImageBase _image_base__
-/* This symbol is defined by the linker.  */
-extern IMAGE_DOS_HEADER __ImageBase;
-#endif
-
 BOOL _ValidateImageBase (PBYTE);
 
 BOOL
index 8b5de51..ea0ea8a 100644 (file)
@@ -16,7 +16,6 @@
 
 extern char __RUNTIME_PSEUDO_RELOC_LIST__;
 extern char __RUNTIME_PSEUDO_RELOC_LIST_END__;
-extern char _image_base__;
 
 typedef struct {
   DWORD addend;
@@ -162,5 +161,5 @@ _pei386_runtime_relocator (void)
   if (was_init)
     return;
   ++was_init;
-  do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,&__RUNTIME_PSEUDO_RELOC_LIST_END__,&_image_base__);
+  do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,&__RUNTIME_PSEUDO_RELOC_LIST_END__,&__ImageBase);
 }