Sync with trunk (r48144)
authorJérôme Gardou <jerome.gardou@reactos.org>
Tue, 20 Jul 2010 22:15:42 +0000 (22:15 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Tue, 20 Jul 2010 22:15:42 +0000 (22:15 +0000)
svn path=/branches/reactos-yarotows/; revision=48150

32 files changed:
1  2 
base/applications/mscutils/eventvwr/lang/en-US.rc
base/shell/cmd/lang/de-DE.rc
base/shell/cmd/lang/ja-JP.rc
base/shell/cmd/lang/ru-RU.rc
boot/freeldr/bootsect/ext2.asm
boot/freeldr/bootsect/fat.asm
boot/freeldr/bootsect/fat32.asm
boot/freeldr/bootsect/isoboot.asm
boot/freeldr/bootsect/isobtrt.asm
boot/freeldr/freeldr/freeldr.rbuild
boot/freeldr/freeldr/freeldr_amd64.lnk
boot/freeldr/freeldr/freeldr_i386.lnk
boot/freeldr/freeldr/setupldr.rbuild
dll/cpl/access/resource.h
dll/cpl/intl/lang/ro-RO.rc
dll/cpl/sysdm/lang/ro-RO.rc
dll/win32/devmgr/lang/ro-RO.rc
dll/win32/msgina/lang/ro-RO.rc
drivers/bus/acpi/acpi.rbuild
include/psdk/rpcndr.h
include/psdk/sdkddkver.h
include/reactos/mingw-w64/sect_attribs.h
include/reactos/wine/commctrl.h
include/reactos/wine/ddk/compstui.h
include/reactos/wine/ddk/winddiui.h
include/reactos/wine/ddk/winsplp.h
lib/3rdparty/mingw/CRT_fp10.c
lib/3rdparty/mingw/CRT_fp8.c
lib/3rdparty/mingw/crtexe.c
lib/3rdparty/mingw/gs_support.c
lib/3rdparty/mingw/tlssup.c
ntoskrnl/ntoskrnl_amd64.lnk

@@@ -114,4 -114,4 +114,4 @@@ BEGI
      IDS_COLUMNUSER      "User"
      IDS_COLUMNCOMPUTER  "Computer"
      IDS_COLUMNEVENTDATA "Event Data"
- END
+ END
@@@ -1,4 -1,4 +1,4 @@@
/*
+ /*
   *  German language file by Klemens Friedl <frik85> 2005-06-03
   *  Update: frik85 2005-06-06
   */
@@@ -1,4 -1,4 +1,4 @@@
/*
+ /*
   * Japanese translation of CMD
   */
  #pragma code_page(65001)
@@@ -1,4 -1,4 +1,4 @@@
/*
+ /*
   * Russian language file by
   * Andrey Korotaev (unC0Rr@inbox.ru)
   * and
@@@ -438,9 -438,11 +438,11 @@@ LoadFreeLoader
  
          mov  dl,[BYTE bp+BootDrive]
                mov  dh,[BYTE bp+BootPartition]
-         push byte 0                                           ; We loaded at 0000:8000
-         push WORD 8000h                                       ; We will do a far return to 0000:8000h
-         retf                                                  ; Transfer control to FreeLoader
+               push 0                                          ; push segment (0x0000)
+               mov eax, [0x8000 + 0xA8]        ; load the RVA of the EntryPoint into eax
+               add eax, 0x8000                         ; RVA -> VA
+               push ax                                         ; push offset
+               retf                                            ; Transfer control to FreeLoader
  
  
  
@@@ -209,7 -209,11 +209,11 @@@ FoundFreeLoader
                ; because they contain a jump instruction to skip
                ; over the helper code in the FreeLoader image.
                ;jmp  0000:8003h
-               jmp  8003h
+               push 0                                          ; push segment (0x0000)
+               mov eax, [0x8000 + 0xA8]        ; load the RVA of the EntryPoint into eax
+               add eax, 0x8003                         ; RVA -> VA and skip 3 bytes (jump to fathelper code)
+               push ax                                         ; push offset
+               retf                                            ; Transfer control to FreeLoader
  
  
  
@@@ -387,10 -391,10 +391,10 @@@ NoCarryCHS
  
  
  msgDiskError db 'Disk error',0dh,0ah,0
- msgFreeLdr   db 'freeldr.sys not found',0dh,0ah,0
+ msgFreeLdr   db 'ldr not found',0dh,0ah,0
  ; Sorry, need the space...
  ;msgAnyKey    db 'Press any key to restart',0dh,0ah,0
- msgAnyKey    db 'Press any key',0dh,0ah,0
+ msgAnyKey    db 'Press a key',0dh,0ah,0
  filename     db 'FREELDR SYS'
  
          times 509-($-$$) db 0   ; Pad to 509 bytes
@@@ -390,11 -390,12 +390,12 @@@ LoadFile
  LoadFileDone:
          mov  dl,[BYTE bp+BootDrive]           ; Load boot drive into DL
                mov  dh,[BootPartition]                 ; Load boot partition into DH
-         xor  ax,ax
-         push ax                                       ; We loaded at 0000:8000
-         push WORD 8000h                       ; We will do a far return to 0000:8000h
-         retf                    ; Transfer control to ROSLDR
  
+               push 0                                          ; push segment (0x0000)
+               mov eax, [0x8000 + 0xA8]        ; load the RVA of the EntryPoint into eax
+               add eax, 0x8000                         ; RVA -> VA
+               push ax                                         ; push offset
+               retf                                            ; Transfer control to FreeLoader
  
  ; Returns the FAT entry for a given cluster number
  ; On entry EAX has cluster number
@@@ -373,7 -373,11 +373,11 @@@ get_fs_structures
  
        mov     dl, [DriveNo]                   ; dl = boot drive
        mov dh, 0                                       ; dh = boot partition
-       jmp     0:0x8000                        ; jump into OSLoader
+       push 0                                          ; push segment (0x0000)
+       mov eax, [0x8000 + 0xA8]        ; load the RVA of the EntryPoint into eax
+       add eax, 0x8000                         ; RVA -> VA
+       push ax                                         ; push offset
+       retf                                            ; Transfer control to ROSLDR
  
  
  
@@@ -922,38 -926,38 +926,38 @@@ pollchar_and_empty
  
  
  isolinux_banner       db CR, LF, 'Loading IsoBoot...', CR, LF, 0
- copyright_str db ' Copyright (C) 1994-2002 H. Peter Anvin', CR, LF, 0
+ copyright_str db ' (C) 1994-2002 H. Peter Anvin', CR, LF, 0
  presskey_msg  db 'Press any key to boot from CD', 0
  dot_msg               db '.',0
  
  %ifdef DEBUG_MESSAGES
- startup_msg:  db 'Starting up, DL = ', 0
- spec_ok_msg:  db 'Loaded spec packet OK, drive = ', 0
- secsize_msg:  db 'Sector size appears to be ', 0
- rootloc_msg:  db 'Root directory location: ', 0
- rootlen_msg:  db 'Root directory length: ', 0
- rootsect_msg: db 'Root directory length(sectors): ', 0
- fileloc_msg:  db 'SETUPLDR.SYS location: ', 0
- filelen_msg:  db 'SETUPLDR.SYS length: ', 0
- filesect_msg: db 'SETUPLDR.SYS length(sectors): ', 0
+ startup_msg:  db 'Startup, DL = ', 0
+ spec_ok_msg:  db 'packet OK, drive = ', 0
+ secsize_msg:  db 'size appears to be ', 0
+ rootloc_msg:  db 'Root dir loc: ', 0
+ rootlen_msg:  db 'Root dir len: ', 0
+ rootsect_msg: db 'Root dir len(sect): ', 0
+ fileloc_msg:  db 'SETUPLDR loc: ', 0
+ filelen_msg:  db 'SETUPLDR len: ', 0
+ filesect_msg: db 'SETUPLDR len(sect): ', 0
  findfail_msg: db 'Failed to find file!', 0
  startldr_msg: db 'Starting SETUPLDR.SYS', 0
  %endif
  
- nosecsize_msg:        db 'Failed to get sector size, assuming 0800', CR, LF, 0
- spec_err_msg: db 'Loading spec packet failed, trying to wing it...', CR, LF, 0
- maybe_msg:    db 'Found something at drive = ', 0
- alright_msg:  db 'Looks like it might be right, continuing...', CR, LF, 0
- nothing_msg:  db 'Failed to locate CD-ROM device; boot failed.', CR, LF, 0
+ nosecsize_msg:        db 'No sector size, assume 0800', CR, LF, 0
+ spec_err_msg: db 'Load spec failed, trying wing ...', CR, LF, 0
+ maybe_msg:    db 'Found smth at drive = ', 0
+ alright_msg:  db 'might be ok, continuing...', CR, LF, 0
+ nothing_msg:  db 'Failed locate CD-ROM; boot failed.', CR, LF, 0
  isolinux_str  db 'IsoBoot: ', 0
  crlf_msg      db CR, LF, 0
  diskerr_msg:  db 'Disk error ', 0
  ondrive_str:  db ', drive ', 0
- err_bootfailed        db CR, LF, 'Boot failed: press a key to retry...'
+ err_bootfailed        db CR, LF, 'failed..', 0
  isolinux_dir  db '\LOADER', 0
- no_dir_msg    db 'Could not find the LOADER directory.', CR, LF, 0
+ no_dir_msg    db 'LOADER dir not found.', CR, LF, 0
  isolinux_bin  db 'SETUPLDR.SYS', 0
- no_isolinux_msg       db 'Could not find SETUPLDR.SYS.', CR, LF, 0
+ no_isolinux_msg       db 'SETUPLDR not found.', CR, LF, 0
  
  ;
  ; El Torito spec packet
@@@ -345,7 -345,11 +345,11 @@@ get_fs_structures
  
        mov     dl, [DriveNo]                   ; dl = boot drive
        mov dh, 0                                       ; dh = boot partition
-       jmp     0:0x8000                        ; jump into OSLoader
+       push 0                                          ; push segment (0x0000)
+       mov eax, [0x8000 + 0xA8]        ; load the RVA of the EntryPoint into eax
+       add eax, 0x8000                         ; RVA -> VA
+       push ax                                         ; push offset
+       retf                                            ; Transfer control to ROSLDR
  
  
  
@@@ -1,8 -1,14 +1,14 @@@
  <?xml version="1.0"?>
+ <if property="ARCH" value="i386">
+       <property name="BASEADDRESS_FREELDR" value="0x8000" />
+ <endif>
  <!DOCTYPE group SYSTEM "../../../tools/rbuild/project.dtd">
  <group>
        <if property="ARCH" value="i386">
-               <module name="freeldr" type="bootloader">
+               <module name="freeldr" type="bootloader" baseaddress="$(BASEADDRESS_FREELDR)">
+                       <linkerscript>freeldr_$(ARCH).lnk</linkerscript>
                        <bootstrap installbase="loader" />
                        <library>freeldr_startup</library>
                        <library>freeldr_base64k</library>
@@@ -15,8 -21,9 +21,9 @@@
                        <library>rtl</library>
                        <library>libcntpr</library>
                        <group linkerset="ld">
-                               <linkerflag>-static</linkerflag>
-                               <linkerflag>-lgcc</linkerflag>
+                               <!-- linkerflag>-static</linkerflag -->
+                               <linkerflag>-nostartfiles</linkerflag>
                        </group>
                </module>
        </if>
index 0000000,bb677e8..bb677e8
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,57 +1,57 @@@
+ OUTPUT_FORMAT(pei-x86-64)
+ ENTRY(_mainCRTStartup)
+ SECTIONS
+ {
+   .text  __image_base__ + __section_alignment__  : 
+   {
+     __text_start__ = .;
+     *(.init)
+     *(.text)
+     *(SORT(.text$*))
+     *(.glue_7t)
+     *(.glue_7)
+      ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; 
+                       LONG (-1); *(.ctors); *(.ctor); LONG (0); 
+      ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; 
+                       LONG (-1); *(.dtors); *(.dtor);  LONG (0); 
+      *(.fini)
+     /* ??? Why is .gcc_exc here?  */
+      *(.gcc_exc)
+      __text_end__ = .;
+     *(.gcc_except_table)
+   }
+   init BLOCK(__section_alignment__) :
+   {
+     __init_start__ = . ;
+     *(init)
+     __init_end__ = . ;
+   }
+   .data BLOCK(__section_alignment__) : 
+   {
+     __data_start__ = . ;
+     *(.data)
+     *(.data2)
+     *(SORT(.data$*))
+     __data_end__ = . ;
+     __bss_start__ = . ;
+     *(.bss)
+     *(COMMON)
+     __bss_end__ = . ;
+   }
+   .rdata BLOCK(__section_alignment__) :
+   {
+     *(.rdata)
+     *(SORT(.rdata$*))
+     *(.eh_frame)
+   }
+   .stab BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     [ .stab ]
+   }
+   .stabstr BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     [ .stabstr ]
+   }
+ }
index 0000000,48b7b5d..48b7b5d
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,57 +1,57 @@@
+ OUTPUT_FORMAT(pei-i386)
+ ENTRY(_mainCRTStartup)
+ SECTIONS
+ {
+   .text  __image_base__ + __section_alignment__  : 
+   {
+     __text_start__ = .;
+     *(.init)
+     *(.text)
+     *(SORT(.text$*))
+     *(.glue_7t)
+     *(.glue_7)
+      ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; 
+                       LONG (-1); *(.ctors); *(.ctor); LONG (0); 
+      ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; 
+                       LONG (-1); *(.dtors); *(.dtor);  LONG (0); 
+      *(.fini)
+     /* ??? Why is .gcc_exc here?  */
+      *(.gcc_exc)
+      __text_end__ = .;
+     *(.gcc_except_table)
+   }
+   init BLOCK(__section_alignment__) :
+   {
+     __init_start__ = . ;
+     *(init)
+     __init_end__ = . ;
+   }
+   .data BLOCK(__section_alignment__) : 
+   {
+     __data_start__ = . ;
+     *(.data)
+     *(.data2)
+     *(SORT(.data$*))
+     __data_end__ = . ;
+     __bss_start__ = . ;
+     *(.bss)
+     *(COMMON)
+     __bss_end__ = . ;
+   }
+   .rdata BLOCK(__section_alignment__) :
+   {
+     *(.rdata)
+     *(SORT(.rdata$*))
+     *(.eh_frame)
+   }
+   .stab BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     [ .stab ]
+   }
+   .stabstr BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     [ .stabstr ]
+   }
+ }
@@@ -1,6 -1,7 +1,7 @@@
  <?xml version="1.0"?>
  <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
  <module name="setupldr" type="bootloader">
+       <linkerscript>freeldr_$(ARCH).lnk</linkerscript>
        <bootstrap installbase="loader" />
        <library>freeldr_startup</library>
        <library>freeldr_base64k</library>
@@@ -15,8 -16,9 +16,9 @@@
        <library>rtl</library>
        <library>libcntpr</library>
        <group linkerset="ld">
-               <linkerflag>-nostartfiles</linkerflag>
-               <linkerflag>-nostdlib</linkerflag>
-               <linkerflag>-lgcc</linkerflag>
+               <!-- linkerflag>-nostartfiles</linkerflag -->
+               <!-- linkerflag>-nostdlib</linkerflag -->
+               <!-- linkerflag>--strip-all</linkerflag -->
+               <linkerflag>-Tbss 0x50000</linkerflag>
        </group>
  </module>
@@@ -5,7 -5,7 +5,7 @@@
  #define PROPSHEETHEIGHT 228
  #define PROPSHEETPADDING(x)  (x+x+x+x+x+x)
  #define SYSTEM_COLUMN   (18*PROPSHEETPADDING)
- #define LABELLINE(x)  (x+x+x+2+x+x+x+x+x+x)
+ #define LABELLINE(x)  (x+x+x+x+x+x+x+x+x+2)
  
  
  #define ICONSIZE        16
@@@ -1,4 -1,4 +1,4 @@@
LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
+ LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
  
  #pragma code_page(65001)
  
@@@ -1,4 -1,4 +1,4 @@@
LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
+ LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
  
  #pragma code_page(65001)
  
@@@ -1,4 -1,4 +1,4 @@@
// Romanian language resource file (Petru Dimitriu, 2009-07-15)
+ // Romanian language resource file (Petru Dimitriu, 2009-07-15)
  
  LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
  
@@@ -1,4 -1,4 +1,4 @@@
LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
+ LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
  
  #pragma code_page(65001)
  
        <xi:include href="compbatt/compbatt.rbuild" />
  </directory>
  
+ <if property="ARCH" value="i386">
+       <group compilerset="msc">
+               <define name="WIN32"/>
+       </group>
+ </if>
  
  <module name="acpi" type="kernelmodedriver" installbase="system32/drivers" installname="acpi.sys" allowwarnings="true">
        <bootstrap installbase="$(CDOUTPUT)" />
diff --combined include/psdk/rpcndr.h
@@@ -128,7 -128,7 +128,7 @@@ typedef unsigned char boolean
     (RpcExceptionCode() == RPC_X_BAD_STUB_DATA) || \
     (RpcExceptionCode() == RPC_S_INVALID_BOUND))
  
- typedef struct
+ typedef struct tagNDR_SCONTEXT
  {
    void *pad[2];
    void *userContext;
diff --combined include/psdk/sdkddkver.h
@@@ -100,9 -100,9 +100,9 @@@ Abstract
  #define NTDDI_WIN7                          0x06010000
  
  /* Version Fields in NTDDI_VERSION */
- #define OSVERSION_MASK                      0xFFFF0000
- #define SPVERSION_MASK                      0x0000FF00
- #define SUBVERSION_MASK                     0x000000FF
+ #define OSVERSION_MASK                      0xFFFF0000UL
+ #define SPVERSION_MASK                      0x0000FF00UL
+ #define SUBVERSION_MASK                     0x000000FFUL
  
  /* Macros to Extract Version Fields From NTDDI_VERSION */
  #define OSVER(Version)                      ((Version) & OSVERSION_MASK)
@@@ -4,13 -4,14 +4,14 @@@
   * No warranty is given; refer to the file DISCLAIMER.PD within this package.
   */
  
- #if defined (__ia64__) || defined (__x86_64)
+ #if defined(_MSC_VER)
+ #if defined(_M_IA64) || defined(_M_AMD64)
  #define _ATTRIBUTES
  #else
  #define _ATTRIBUTES shared
  #endif
  
- #if defined(_MSC_VER)
  /* Reference list of existing section for msvcrt.  */
  #pragma section(".CRTMP$XCA",long,_ATTRIBUTES)
  #pragma section(".CRTMP$XCZ",long,_ATTRIBUTES)
  #pragma section(".rtc$IZZ",long,read)
  #pragma section(".rtc$TAA",long,read)
  #pragma section(".rtc$TZZ",long,read)
+ /* for tlssup.c: */
  #pragma section(".tls",long,read,write)
+ #pragma section(".tls$AAA",long,read,write)
  #pragma section(".tls$ZZZ",long,read,write)
- #endif
+ #endif /* _MSC_VER */
  
  #if defined(_MSC_VER)
  #define _CRTALLOC(x) __declspec(allocate(x))
  #elif defined(__GNUC__)
  #define _CRTALLOC(x) __attribute__ ((section (x) ))
  #else
- #error
+ #error Your compiler is not supported.
  #endif
@@@ -10,7 -10,7 +10,7 @@@
  #define _WIN32_IE 0x0501
  #endif
  
- #include_next <commctrl.h>
+ #include <psdk/commctrl.h>
  
  #undef DPA_GetPtr
  LPVOID WINAPI DPA_GetPtr(HDPA, INT);
@@@ -1,2 -1,2 +1,2 @@@
  
- #include_next <compstui.h>
+ #include <psdk/compstui.h>
@@@ -1,2 -1,2 +1,2 @@@
  
- #include_next <winddiui.h>
+ #include <psdk/winddiui.h>
@@@ -1,2 -1,2 +1,2 @@@
  
- #include_next <winsplp.h>
+ #include <psdk/winsplp.h>
@@@ -7,16 -7,18 +7,18 @@@
  void _fpreset (void);
  
  void _fpreset (void)
- { 
+ {
  #ifdef __GNUC__
-     __asm__ ("fninit" );
- #else
-     __asm fninit;
+   __asm__ ("fninit");
+ #else /* msvc: */
+   __asm fninit;
  #endif
  }
  
  #ifdef __GNUC__
  void __attribute__ ((alias ("_fpreset"))) fpreset(void);
  #else
- void fpreset(void) { _fpreset(); }
+ void fpreset(void) {
+     _fpreset();
+ }
  #endif
@@@ -17,5 -17,7 +17,7 @@@ void _fpreset (void
  #ifdef __GNUC__
  void __attribute__ ((alias ("_fpreset"))) fpreset(void);
  #else
- void fpreset(void) { _fpreset(); }
+ void fpreset(void) {
+     _fpreset();
+ }
  #endif
@@@ -20,6 -20,7 +20,7 @@@
  #include <tchar.h>
  #include <sect_attribs.h>
  #include <locale.h>
+ #include <intrin.h>
  
  #ifndef __winitenv
  extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
@@@ -51,7 -52,11 +52,11 @@@ extern int * __MINGW_IMP_SYMBOL(_commod
  #define _commode (* __MINGW_IMP_SYMBOL(_commode))
  extern int _dowildcard;
  
+ #if defined(__GNUC__)
  int _MINGW_INSTALL_DEBUG_MATHERR __attribute__((weak)) = 0;
+ #else
+ int _MINGW_INSTALL_DEBUG_MATHERR = 0;
+ #endif
  extern int __defaultmatherr;
  extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *);
  
@@@ -88,19 -88,25 +88,25 @@@ __security_init_cookie (void
    __security_cookie_complement = ~cookie;
  }
  
+ #if defined(__GNUC__) /* wrap msvc intrinsics onto gcc builtins */
+ #undef  _ReturnAddress
+ #undef  _AddressOfReturnAddress
+ #define _ReturnAddress()              __builtin_return_address(0)
+ #define _AddressOfReturnAddress()     __builtin_frame_address (0)
+ #endif /* __GNUC__ */
  __declspec(noreturn) void __cdecl __report_gsfailure (ULONGLONG);
  
  __declspec(noreturn) void __cdecl
  __report_gsfailure (ULONGLONG StackCookie)
  {
-   volatile UINT_PTR cookie[2];
+   volatile UINT_PTR __UNUSED_PARAM(cookie[2]);
  #ifdef _WIN64
    ULONG64 controlPC, imgBase, establisherFrame;
    PRUNTIME_FUNCTION fctEntry;
    PVOID hndData;
- #endif
  
- #ifdef _WIN64
    RtlCaptureContext (&GS_ContextRecord);
    controlPC = GS_ContextRecord.Rip;
    fctEntry = RtlLookupFunctionEntry (controlPC, &imgBase, NULL);
                        &GS_ContextRecord, &hndData, &establisherFrame, NULL);
      }
    else
- #endif
+ #endif /* _WIN64 */
      {
- #ifdef __GNUC__
- #ifdef _WIN64
-       GS_ContextRecord.Rip = (ULONGLONG) __builtin_return_address (0);
-       GS_ContextRecord.Rsp = (ULONGLONG) __builtin_frame_address (0) + 8;
- #else
-       GS_ContextRecord.Eip = (DWORD) __builtin_return_address (0);
-       GS_ContextRecord.Esp = (DWORD) __builtin_frame_address (0) + 4;
- #endif
- #else
  #ifdef _WIN64
        GS_ContextRecord.Rip = (ULONGLONG) _ReturnAddress();
-       GS_ContextRecord.Rsp = (ULONGLONG) _AddressOfReturnAddress();
+       GS_ContextRecord.Rsp = (ULONGLONG) _AddressOfReturnAddress() + 8;
  #else
        GS_ContextRecord.Eip = (DWORD) _ReturnAddress();
-       GS_ContextRecord.Esp = (DWORD) _AddressOfReturnAddress();
- #endif
- #endif
+       GS_ContextRecord.Esp = (DWORD) _AddressOfReturnAddress() + 4;
+ #endif /* _WIN64 */
      }
  
  #ifdef _WIN64
  #else
    GS_ExceptionRecord.ExceptionAddress = (PVOID) GS_ContextRecord.Eip;
    GS_ContextRecord.Ecx = StackCookie;
- #endif
+ #endif /* _WIN64 */
    GS_ExceptionRecord.ExceptionCode = STATUS_STACK_BUFFER_OVERRUN;
    GS_ExceptionRecord.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
    cookie[0] = __security_cookie;
    TerminateProcess (GetCurrentProcess (), STATUS_STACK_BUFFER_OVERRUN);
    abort();
  }
  #undef CRTDLL
  #endif
  
+ #include <sect_attribs.h>
+ #ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
+ #endif
  #include <windows.h>
  #include <stdio.h>
  #include <memory.h>
  #include <malloc.h>
- #ifndef _CRTALLOC
- #define _CRTALLOC(x) __attribute__ ((section (x) ))
+ #ifndef _WIN64
+ #include <stdlib.h> /* for _winmajor */
  #endif
  
  #ifndef __INTERNAL_FUNC_DEFINED
  #define __INTERNAL_FUNC_DEFINED
  typedef void (__cdecl *_PVFV)(void);
  typedef int (__cdecl *_PIFV)(void);
  typedef void (__cdecl *_PVFI)(int);
+ typedef void (__cdecl *_PVFV)(void);
+ typedef int (__cdecl *_PIFV)(void);
+ typedef void (__cdecl *_PVFI)(int);
  #endif
  
  extern WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved);
@@@ -209,5 -214,5 +214,5 @@@ _CRTALLOC(".CRT$XLD") PIMAGE_TLS_CALLBA
  
  
  int mingw_initltsdrot_force = 0;
- int mingw_initltsdyn_force=0;
+ int mingw_initltsdyn_force = 0;
  int mingw_initltssuo_force = 0;
index 0000000,c8ea8e4..c8ea8e4
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,174 +1,174 @@@
+ OUTPUT_FORMAT(pei-x86-64)
+ ENTRY(_mainCRTStartup)
+ SECTIONS
+ {
+   .text  __image_base__ + __section_alignment__  : 
+   {
+     __text_start__ = .;
+     *(.init)
+     *(.text)
+     *(SORT(.text$*))
+     *(.glue_7t)
+     *(.glue_7)
+      ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; 
+                       LONG (-1); *(.ctors); *(.ctor); LONG (0); 
+      ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; 
+                       LONG (-1); *(.dtors); *(.dtor);  LONG (0); 
+      *(.fini)
+     /* ??? Why is .gcc_exc here?  */
+      *(.gcc_exc)
+      __text_end__ = .;
+     *(.gcc_except_table)
+   }
+   init BLOCK(__section_alignment__) :
+   {
+     __init_start__ = . ;
+     *(init)
+     __init_end__ = . ;
+   }
+    /* The Cygwin32 library uses a section to avoid copying certain data
+      on fork.  This used to be named ".data".  The linker used
+      to include this between __data_start__ and __data_end__, but that
+      breaks building the cygwin32 dll.  Instead, we name the section
+      ".data_cygwin_nocopy" and explictly include it after __data_end__. */
+   .data BLOCK(__section_alignment__) : 
+   {
+     __data_start__ = . ;
+     *(.data)
+     *(.data2)
+     *(SORT(.data$*))
+     __data_end__ = . ;
+     *(.data_cygwin_nocopy)
+   }
+   .rdata BLOCK(__section_alignment__) :
+   {
+     *(.rdata)
+     *(SORT(.rdata$*))
+    /* For some reason mingw likes to merge it here. I don't! */
+    /* *(.eh_frame) */
+   }
+   .edata BLOCK(__section_alignment__) :
+   {
+     *(.edata)
+   }
+   /DISCARD/ :
+   {
+     *(.debug$S)
+     *(.debug$T)
+     *(.debug$F)
+     *(.drectve)
+   }
+   .idata BLOCK(__section_alignment__) :
+   {
+     /* This cannot currently be handled with grouped sections.
+       See pe.em:sort_sections.  */
+     SORT(*)(.idata$2)
+     SORT(*)(.idata$3)
+     /* These zeroes mark the end of the import list.  */
+     LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
+     SORT(*)(.idata$4) 
+     SORT(*)(.idata$5)
+     SORT(*)(.idata$6)
+     SORT(*)(.idata$7)
+   }
+   .CRT BLOCK(__section_alignment__) :
+   {                                   
+     *(SORT(.CRT$*))
+   }
+   .rsrc BLOCK(__section_alignment__) :
+   {                                   
+     *(.rsrc)
+     *(SORT(.rsrc$*))
+   }
+   .bss BLOCK(__section_alignment__) :
+   {
+     __bss_start__ = . ;
+     *(.bss)
+     *(COMMON)
+     __bss_end__ = . ;
+   }
+   .reloc BLOCK(__section_alignment__) :
+   {                                   
+     *(.reloc)
+      /* These zeroes mark the end of the reloc section.  */
+      LONG (0); LONG (0); LONG (0); LONG (0); LONG (0);
+   }
+   .stab BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     [ .stab ]
+   }
+   .stabstr BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     [ .stabstr ]
+   }
+   /* DWARF debug sections.
+      Symbols in the DWARF debugging sections are relative to the beginning
+      of the section.  Unlike other targets that fake this by putting the
+      section VMA at 0, the PE format will not allow it.  */
+   /* DWARF 1.1 and DWARF 2.  */
+   .debug_aranges BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_aranges)
+   }
+   .debug_pubnames BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_pubnames)
+   }
+   /* DWARF 2.  */
+   .debug_info BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_info) *(.gnu.linkonce.wi.*)
+   }
+   .debug_abbrev BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_abbrev)
+   }
+   .debug_line BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_line)
+   }
+   .debug_frame BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_frame)
+   }
+   .debug_str BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_str)
+   }
+   .debug_loc BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_loc)
+   }
+   .debug_macinfo BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_macinfo)
+   }
+   /* SGI/MIPS DWARF 2 extensions.  */
+   .debug_weaknames BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_weaknames)
+   }
+   .debug_funcnames BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_funcnames)
+   }
+   .debug_typenames BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_typenames)
+   }
+   .debug_varnames BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_varnames)
+   }
+   /* DWARF 3.  */
+   .debug_ranges BLOCK(__section_alignment__) (NOLOAD) :
+   {
+     *(.debug_ranges)
+   }
+   .eh_frame BLOCK(__section_alignment__) :
+   {
+     *(.eh_frame)
+   }
+ }