[fpc-pascal] Shared libraries and threadvars

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Tue Jun 26 20:08:57 CEST 2012


Apologies for my lousy message threading, but some are vanishing in the 
spamtrap.

 >> OK, so to emphasise that: library B's data will be common,
 >> irrespective of the location of the calling routine. Does this
 >> apply if the load is being done at runtime, i.e. the program is
 >> using dl (or whatever) to load A and B, and A also uses dl to
 >> load B?
 >
 > It does not matter whether the library is loaded at program start
 > or at runtime. It's always the same mechanism with the exception
 > that in the first case your main function has not yet been called
 > (which normally doesn't matter either).

Just being cautious :-) One final question if I may: noting Ludo's 
example elsewhere:

 > In the project.lpr add the following code:
 >
 > Procedure qt_startup_hook;export;
 > Begin
 > End;
 >
 > Exports qt_startup_hook;

Can such an alternative entry point in the main unit be called by a 
shared library, i.e. either resolved at load time or with the main 
binary reopened like a library? Or is the only way to pass a 
main-program entry point to a shared library by using it as a parameter 
to a procedure?

I've used such things in a Windows-style .exe so a loader/binder would 
know how to generate absolute code for an embedded system, but have 
never tried exploiting it with a "real" OS.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list