OMF, COFF and the 32-bit/64-bit Delphi or C++ compilers
Posted by jpluimers on 2020/01/29
Via [WayBack] As far as I can tell (and documentation on that is reaaaaaaly hard to find), dcc64 can link in .obj files in OMF and COFF format. Bcc64 uses LLVM chain and therefore produces ELF .o files… – Primož Gabrijelčič – Google+:
David Heffernan:
dcc32
doescoff
andomf
,dcc64
onlycoff
and later he commented:
One of the difficulties with linking objects is the handling of exceptions. The 64 bit exception model is table based, in contrast to the stack based 32 bit model.
I don’t think that the exception tables are written correctly for code linked in objects. If exceptions are raised then this can lead to abnormal process termination. Process just disappears. Poof!
One common way that this happens is floating point exceptions that are by default unmasked by the Delphi RTL. I have found it necessary to mask them when calling into any linked object code to avoid exceptions being raised.
And compiling with cl can be a bit of a game. It’s stack checking options need to be disabled. And there are a few other key switches that help. And then there’s the forward declaration trick to help the one pass compiler cope with C objects that are expected to be linked in a separate step.
Anyway, it can be quite a challenge at times, but I’ve yet to find a plain self contained C library that has defeated me!
–jeroen
Alexandre Machado said
These are my personal findings after almost a month struggling with all Delphi versions x64-capable:
– Delphi x64 can link in COFF obj files (from XE2 and up)
– Delphi x64 from 10.1 Berlin and up can link in ELF64 files
– Delphi x86 must link in OMF obj files
jpluimers said
Thanks for the extra information!