flat assembler
Message board for the users of flat assembler.

Index > Linux > How to create a shared object, and how to import simbol

Author
Thread Post new topic Reply to topic
jorge



Joined: 09 Apr 2008
Posts: 9
jorge 26 May 2008, 19:26
I need to know how to create a shared object with FASM and how to export simbols.I need to know too, how to import simbol from other shared object. If any people have any example to show I'm would be very pleasure
Post 26 May 2008, 19:26
View user's profile Send private message Reply with quote
gunblade



Joined: 19 Feb 2004
Posts: 209
gunblade 27 May 2008, 19:22
Shared objects are quite simple.

First, you have to use Format ELF

then exports are defined using:

Code:
public function_name    


where function_name is defined somewhere in the code as a regular label

importing functions is done using:

Code:
extrn function_name    


where function_name is defined in the shared object you are going to link with.

then you can fasm the code, to generate a .o ELF shared object file

this can then be linked in with other objects using ld, example:

Code:
ld -o testbinary test1.o test2.o test3.o    


This should work fine if all dependancies are defined.

(If you were talking about shared libraries (.so files), then im not sure how to do that, I think its just done using extrn, then you have to link using libtool instead of ld (or ld -shared), im not 100% sure, and i havent tried it. But you could look up linuxassembly.org or similar for a tutorial on it, even if its for nasm, its easy to convert)
Post 27 May 2008, 19:22
View user's profile Send private message Reply with quote
jorge



Joined: 09 Apr 2008
Posts: 9
jorge 28 May 2008, 20:56
There are any poibility to use the macrointruccion "proc" in this format and is posible to create this so only with FASM.
Post 28 May 2008, 20:56
View user's profile Send private message Reply with quote
jorge



Joined: 09 Apr 2008
Posts: 9
jorge 28 May 2008, 20:56
There are any poibility to use the macrointruccion "proc" in this format and is posible to create this so only with FASM.
Post 28 May 2008, 20:56
View user's profile Send private message Reply with quote
gunblade



Joined: 19 Feb 2004
Posts: 209
gunblade 28 May 2008, 21:25
I believe proc should work fine if you include only the proc.inc file (not the full win32a.inc), you just have to make sure theres nothing windows-specific, but proc shouldnt be, its just extending the labels/ret.

As for purely only fasm, I dont think its possible, theres been several threads about it before in the board (if you want to search), but im pretty sure theres no way to link with fasm (and it indeed shouldnt, its an assembler, not a linker). Using ld isnt hard, and pretty much all linux distro's will have it, as its part of binutils. So only _very_ trimmed down distros not aimed at development may not have it.
Post 28 May 2008, 21:25
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 15 Jun 2008, 18:20
Post 15 Jun 2008, 18:20
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.