flat assembler
Message board for the users of flat assembler.

Index > Main > x64 C compiler and fasm

Author
Thread Post new topic Reply to topic
Yug3sh



Joined: 23 Oct 2007
Posts: 6
Yug3sh 23 Oct 2007, 23:48
Hi,

Anyone know of a free x64 C compiler that can generate PE files linkable with FASM PE files?

I'm looking for a win32 version of the C compiler (i.e. runnable on windows).

I've tried downloading the win32 version of GCC (mingw version and cygwin), however neither of these seem to compile x64 PE binaries (maybe I used the wrong switches).

The compilers complained that generating x64 binaries was not compiled into the compiler (no pun intended).

Only a slightly other note, where can I find the latest PE spec that documents the x64 version of PE files?

TIA.
Post 23 Oct 2007, 23:48
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 24 Oct 2007, 00:00
Quote:
PE files linkable with FASM PE files

linkable how? you mean DLL?
Post 24 Oct 2007, 00:00
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Yug3sh



Joined: 23 Oct 2007
Posts: 6
Yug3sh 24 Oct 2007, 00:43
vid wrote:
Quote:
PE files linkable with FASM PE files

linkable how? you mean DLL?


No, a DLL is normally just a PE file.

I mean generate an OMF (object file) with FASM and link it using the C compiler's linker with the appropriate C compiler generated object files to create an x64 PE file.
Post 24 Oct 2007, 00:43
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 24 Oct 2007, 00:46
OMF does not support 64 bits, only 32 bits.
As far as I know, FASM generates COFF object files but not OMF.


Last edited by bogdanontanu on 24 Oct 2007, 00:48; edited 1 time in total
Post 24 Oct 2007, 00:46
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 24 Oct 2007, 00:47
FASM doesn't generate OMF object files. It generates COFF object files (or more precisely, microsoft's version of COFF standard).

As to your main question, I don't know about free tools, sorry...
Post 24 Oct 2007, 00:47
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Yug3sh



Joined: 23 Oct 2007
Posts: 6
Yug3sh 24 Oct 2007, 03:02
Thanks for the responses. I guess I'll have to find the COFF specifications for 64 bit and keep hunting for a free x64 C compiler.
Post 24 Oct 2007, 03:02
View user's profile Send private message Reply with quote
Xorpd!



Joined: 21 Dec 2006
Posts: 161
Xorpd! 24 Oct 2007, 04:09
There are so many x64 C compilers. You can get one from Microsoft's website -- when you download MSVC++ 5.0 Express Edition there is also an SDK or something they offer as well, and the AMD64 version has a 64-bit C compiler. There is also a 64-bit gcc; I could dig up the reference if you would like. Intel lets you download a 30-day trial of their C++ compiler, I think. Some of the other commercial vendors may have C++ and trial periods, as well. Fasm will link OK with any of these. If you want to use ld.exe instead of link.exe to link the gcc object files you may need to decorate the names in FASM. If you encounter problems use dumpbin.exe to see what names the two sides want.
Post 24 Oct 2007, 04:09
View user's profile Send private message Visit poster's website Reply with quote
Yug3sh



Joined: 23 Oct 2007
Posts: 6
Yug3sh 24 Oct 2007, 04:14
Xorpd! wrote:
There are so many x64 C compilers. You can get one from Microsoft's website -- when you download MSVC++ 5.0 Express Edition there is also an SDK or something they offer as well, and the AMD64 version has a 64-bit C compiler. There is also a 64-bit gcc; I could dig up the reference if you would like. Intel lets you download a 30-day trial of their C++ compiler, I think. Some of the other commercial vendors may have C++ and trial periods, as well. Fasm will link OK with any of these. If you want to use ld.exe instead of link.exe to link the gcc object files you may need to decorate the names in FASM. If you encounter problems use dumpbin.exe to see what names the two sides want.


Thanks Xorpd. I believe the express edition of VC++ does not support generating x64 binaries without some hacking (installing the SDK and doing a couple other things).

I am using windows, so have tried the cygwin and mingw versions of GCC but couldn't generate x64 binaries for some reason. It seems as though those versions of GCC were built without x64 support.

I'd prefer to steer clear of trial versions.

If you have a link to a version of GCC that will run on windows and generate x64 binaries, then I would really appreciate it!!!
Post 24 Oct 2007, 04:14
View user's profile Send private message Reply with quote
Xorpd!



Joined: 21 Dec 2006
Posts: 161
Xorpd! 24 Oct 2007, 05:35
Installing the SDK isn't what I would consider hacking. I found 'cl.exe' at a couple of locations in my hard disk:

C:\WinDDK\6000\bin\x86\amd64\cl.exe
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin\win64\x86\AMD64\cl.exe

The first was from downloading some monster DDK from microsoft. It also had a more recent version of ml64.exe (cue boos) than the second, which I got with the SDK, as you surmised. You need the microsoft stuff to get their link.exe in any case. I'm not sure if ld.exe is interoperable with everything in Windows.

gfortran comes with gcc, as, and ld (but not g++). Experimental, use at your own risk.
Post 24 Oct 2007, 05:35
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 24 Oct 2007, 09:21
You could of course try rebuilding gcc + bintools yourself, but good luck with that - I'd suggest going for the Microsoft tools, after of course checking the SDK license to see if it's compatible with your needs.
Post 24 Oct 2007, 09:21
View user's profile Send private message Visit poster's website Reply with quote
Yug3sh



Joined: 23 Oct 2007
Posts: 6
Yug3sh 24 Oct 2007, 17:32
Xorpd! wrote:
Installing the SDK isn't what I would consider hacking. I found 'cl.exe' at a couple of locations in my hard disk:

C:\WinDDK\6000\bin\x86\amd64\cl.exe
C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin\win64\x86\AMD64\cl.exe

The first was from downloading some monster DDK from microsoft. It also had a more recent version of ml64.exe (cue boos) than the second, which I got with the SDK, as you surmised. You need the microsoft stuff to get their link.exe in any case. I'm not sure if ld.exe is interoperable with everything in Windows.

gfortran comes with gcc, as, and ld (but not g++). Experimental, use at your own risk.



Thanks Xorpd. I managed to get gcc to compile and link. For some reason, I can't just run gcc file.c and have it create me an .exe. I get an error:

ld: crt2.o: No such file: No such file or directory

My lib path is set correct. I can run gcc -c file.c and ld file.o and that works.

On a slightly different note, is there a way to use gcc to generate an elf binary and /or a flat binary (located to a specific address)?


Last edited by Yug3sh on 24 Oct 2007, 17:37; edited 1 time in total
Post 24 Oct 2007, 17:32
View user's profile Send private message Reply with quote
Yug3sh



Joined: 23 Oct 2007
Posts: 6
Yug3sh 24 Oct 2007, 17:34
f0dder wrote:
You could of course try rebuilding gcc + bintools yourself, but good luck with that - I'd suggest going for the Microsoft tools, after of course checking the SDK license to see if it's compatible with your needs.


Thanks F0dder. I've managed to get the version of gcc that Xorpd pointed me to to generate a 64 bit exe.

I'm not sure how open the MS license terms are, so would rather not use MS tools if I don't have to.

I've previously used OpenWatcom as my compiler, however it currently does not support generating x64 binaries.
Post 24 Oct 2007, 17:34
View user's profile Send private message Reply with quote
nocona



Joined: 04 Aug 2007
Posts: 35
nocona 27 Oct 2007, 04:17
Quote:

On a slightly different note, is there a way to use gcc to generate an elf binary and /or a flat binary (located to a specific address)?

i think you can, but that is the task for ld. try read the full ld doc on ld script.
Post 27 Oct 2007, 04:17
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.