[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

Re: RE>C++ linked with other languages



Zortech C++ on MS-DOS and OS/2 has a totally clean solution to this
that requires no post-link pass, works with standard system linkers, 
interfaces cleanly with other languages, and is even allows other languages
to define their own code to be called at program initialisation and
termination time.

Unfortunately, the technique relies on a facility of the Intel relocatable
and object module format that isn't present in most other, less
structured, relocatables.  At compile time, the compiler just creates
a segment named XI or XIF that contains pointers to all the static
constructors and another called XC or XCF containing pointers to
the static destructors.  By defining such a segment of your own, you
can have ANY function called at these times.

Intel/Microsoft compatible linkers collect all data with identical
segment names into one common segment in the output executable file.
At runtime, the startup code just looks up these segments by
name and walks through them calling the functions they point to.
(The structure of the object file preserves segment names, as well as
a lot of other information.)

For once, segmented architecture makes something simpler!