MinGW

From OSDev.wiki
Revision as of 13:40, 6 January 2013 by Combuster (talk | contribs)
Jump to navigation Jump to search

MinGW (Minimalist GNU for Windows) is a port of several GNU utilities to the Windows console environment, including the GCC / binutils toolchain. It is less sophisticated than Cygwin, but more compact with a lower overhead. It is most widely used in conjunction with the Dev-C++ and CodeBlocks IDE.

OSDev

The factual accuracy of this article is disputed.
Please see the relevant discussion on the talk page.

You are encouraged to use Cygwin instead of MinGW for OSDeving. MinGW has a collection of issues that make it poorly suited for our needs:

  1. (GCC 2.95) ld -r -d ... doesn't get rid of all the common variables.
  2. (GCC 2.95) BSS size is stored in the wrong location of the section header, so MinGW does not correctly interoperate with NASM.
  3. ld -Ttext=NNN ... doesn't put the .text section at the correct address unless you also use the --image-base=0 option.
  4. Linker claims to support ELF, but says "PE operations on non PE file" if you try to use ELF.
  5. MinGW 'make' uses 'sh' as the shell if it finds 'sh' on the path. This is the Wrong Thing, as the SHELL and COMSPEC environment variables should be evaluated (like e.g. DJGPP 'make' does).

It is possible to create a Multiboot-kludge compatible kernel, though. If you are interested you can visit FreeDOS-32; its kernel can be compiled by MinGW.

/* The link script
 ( Note: the format should be "pe-i386" instead of
   "pei-i386" to ged rid of the "MZ" header. text
   and data sections should be close to each other. )
*/
OUTPUT_FORMAT("pe-i386")
ENTRY(start)
SECTIONS {
   .text :{
      *(.text)
   }

   .data ADDR(.text) + SIZEOF(.text) :{
      *(.data)
      *(.data2)
      *(.rdata)
      __data_end__ = . ;
   }

   .bss ADDR(.data) + SIZEOF(.data) : {
      *(.bss)
      *(COMMON)
      __bss_end__ = . ;
   }
}

See Also

Articles

Forum

External Links