[fpc-pascal] using a unit from an old version of fpc

Tomas Hajny XHajT03 at hajny.biz
Sun Oct 30 23:11:31 CET 2011

On 30 Oct 11, at 22:12, John Lee wrote:

> What is best way to do this - I have a unit from fpc 2.2 that I don't have
> the source for, that I want to use with code from a later version eg 2.4,
> 2.5.1 or 2.6. Can I access it via the use? Or just link to it?

Directly including it in the uses clause is not possible. Linking it 
might be possible with certain limitations, but it is fairly 
difficult and implies some amount of reverse engineering. There are 
several issues and gotchas:

1) I assume that you refer to a unit written in procedural language, 
not classes (plain linking would not be enough for the latter).

2) If you don't have even the interface part, you may try reproducing 
it using objdump and/or ppudump (you need to use ppudump from the FPC 
version used for compiling the .ppu file), but the type information 
may be difficult to retrieve if your unit was not compiled with debug 

3) The real problem stems from the fact that your compiled unit used 
the RTL from the respective FPC version and the current version 
exports mostly the same symbols but with sometimes slightly different 
behaviour. It might work if there were no important differences in 
the RTL parts used by that unit, but that is far from being 
guaranteed. If that does not work, it may be still feasible to 
disassemble the compiled unit and either modify it directly in 
assembly for proper working with the current RTL or including (some 
parts of) the RTL twice (once using the object files from the 
original FPC version and once for the current version) but all of 
that is rather difficult and implies very good understanding of low-
level stuff (like what can be combined and what not).


More information about the fpc-pascal mailing list