[fpc-devel] Re: Exporting from Elf okay?

L505 fpc505 at z505.com
Mon Aug 8 07:33:43 CEST 2005

| > Okay, I researched the topic. Of course, yes, you can export functions from an
| > on linux. But freepascal doesn't seem to like it just yet.
| How do you intend to use the exported symbols of an stand-alone
| executable?
| As a shared library, or how else?

A shared library can call functions from the executable that it is running from. Two way
communication is very important to me.

| Perhaps Linux and Windows executable files are not too different. On

They aren't really, is what I found, after reseaching them.

| Windows the file format (MZ) is the same for DLLs and EXE files, the
| main difference is the invocation through the WinMain or LibMain entry
| points. On Linux the shared libraries may have a similar implementation,
| so that the exported symbols can be used only with shared library
| modules.

Functions can be used in executables in linux by calling the -export-dynamic or -E with
the linker (LD), but it isn't working yet with freepascal. Works with GCC (also
called -rdynamic).

In windows, you can either get the handle of the exe using getmodule, and then
getprocaddress(exehandle, 'myproc')or you can just call statically
 procedure myproc; external 'myprogram.exe'; (instead of mylibrary.dll ).

I asked some GCC guys "can an elf executable export functions?" and they sort of laughed
at me. They do it all the time, and they wondered why I was asking such an obvious
question. But I honestly think a lot of people don't know you can do this.

Without being able to export functions form an executable, I find it's sort of like having
a client without a server. Why have a client without a server? To me, it is essential for
the executable to export functions.. (this is where the true power can be squeezed out of
plug-in systems - Lazarus RB Edition relies on this and would never work without
it...unless I used sockets, interprocess communication, or something similar.)


More information about the fpc-devel mailing list