flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Linux > .o for linking with gcc?

Author
Thread Post new topic Reply to topic
roxaz



Joined: 27 Jul 2008
Posts: 25
.o for linking with gcc?
Can fasm produce .o for linking it with gcc on linux? I am not sure how COFF is different from MS COFF but neither works. Im writing hoping i missed something in docs.
Post 10 Jul 2015, 12:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 14854
Location: Lost in translation
I expect you need ELF format, not COFF.
Post 10 Jul 2015, 12:51
View user's profile Send private message Visit poster's website Reply with quote
alkap



Joined: 18 Feb 2015
Posts: 39
Location: Dnipro, Ukraine
Re: .o for linking with gcc?

roxaz wrote:
Can fasm produce .o for linking it with gcc on linux? I am not sure how COFF is different from MS COFF but neither works. Im writing hoping i missed something in docs.



The 'examples/elfobj' directory of the fasm distribution has instructions on how to generate '.o' files:

Code:

/path/to/fasm/examples/elfobj/msgdemo.asm:4,7
; compile the program using commands like:
;   fasm msgdemo.asm msgdemo.o
;   fasm writemsg.asm writemsg.o
;   ld msgdemo.o writemsg.o -o msgdemo


Post 10 Jul 2015, 16:25
View user's profile Send private message Send e-mail Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 616
Without more information, it's tricky to determine the cause. In addition to above, you may need to match your architecture if the default is 64bit by using "format ELF64". There's also the issue of linking: C style is basically just name matching but C++ style requires a matching prototype "hash", which you will have to adapt according to your particular compilation. i.e.

Code:
public my_function

is fine for C regardless of the prototype but for C++ you might need:

Code:
public my_function as '?my_fuction1@@YAXPAD@Z'

This hash can be obtained by doing a readelf on intermediate object of your C/C++ code.

Agner Fog's volume 5 here: http://www.agner.org/optimize/ details both the hashing and general ABI (if you were seeing run time failures it could suggest a calling mismatch)
Post 10 Jul 2015, 20:23
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 260
Location: Australia
I just did a recent post about integrating my fasm library with gcc, with x86_64 at least, all that is required is

Code:
format ELF64
section '.text' executable align 16
public somesymbol
somesymbol:




See https://2ton.com.au/rants_and_musings/gcc_integration.html for working examples of this.

Cheers
Post 10 Jul 2015, 21:40
View user's profile Send private message Reply with quote
roxaz



Joined: 27 Jul 2008
Posts: 25
indeed "format ELF64 " is exactly what i needed. i got confused thinking ELF64 must be .so while ELF64 executable must be.. executable.

thank you!
Post 11 Jul 2015, 06:52
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.