Re: win32/linux executables

"Peter Cooper" <>
5 Jan 2002 01:47:03 -0500

          From comp.compilers

Related articles
win32/linux executables (2002-01-03)
Re: win32/linux executables (Fabrice Medio) (2002-01-05)
Re: win32/linux executables (Carsten Kuckuk) (2002-01-05)
Re: win32/linux executables (2002-01-05)
Re: win32/linux executables (Peter Cooper) (2002-01-05)
| List of all articles for this month |

From: "Peter Cooper" <>
Newsgroups: comp.compilers
Date: 5 Jan 2002 01:47:03 -0500
Organization: Compilers Central
References: 02-01-010
Keywords: code, linker
Posted-Date: 05 Jan 2002 01:47:03 EST


You seem to be saying that you want to make a compiler that will
create an EXE file. It's not quite that simple ;-) While you /could/
write a compiler that did that, in your situation it makes far more
sense to have a compiler and then a linker. Taking a really simplistic
view of things.. your compiler produces the object code, then you get
a linker that 'converts' that into an EXE for you.

Alternatively, your compiler could produce x86 asm (probably easier if
you're just starting out) which is then compiled in an assembler (say,
NASM) to object code which is then linked into an EXE.

The Win32+Assembler source page at
will probably help you a lot. It has links to assemblers, file
editors, and even linkers.. all ready for you to use.. so all you need
to focus on writing is the compiler!

But if you really want to know about PE/COFF etc...

> where do i start? intel's assembly specification ? windows APIs? any
> resource that would help me write a basic compiler would help. i can
> then try and expand that further and seek help as and when i get
> stuck.

In 1995, someone on comp.compilers asked about the PE file format and
got this response from Thomas de Lellis:

<<The PE specification can be ordered from Intel - ask for "TiS - Formats
Specification for Windows", Intel order number 241597-001.>>

Luckily you can find the information you need on the Web nowadays. ;-)
Weirdly enough, I've only just stumbled into this group, but recently
I've been doing a lot of OS development, and a lot of OS development
sites have the information that you require..

Executable files in Windows are in the 'PE' format, whether they're
regular windowed apps or not. The PE format is somewhat similar to the
Linux COFF executable file format in theory, but with some extra MS
junk thrown in. The following link has some *basic* info on the format
of PE files.

The definitive ('official') guide to the COFF format is at

The official guide to the PE format keeps jumping around MS's
site.. but there's an AMAZING document called 'Peering Inside the PE:
A Tour of the Win32 Portable Executable File Format' at:
l/msdn_peeringpe.asp That one document could probably teach you
everything you need to know.

The Windows IT Library provides a simple run-through of the main
concepts at

There are also some very old documents (1993) at but these are probably of little
use although since they cover the spec at an earlier date may be
easier to follow.

Peter Cooper

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.