Is there a way to link objects that have been compiled with GCC without disabling SSE instructions, statically to a Delphi program (Windows x86_64)?
Embarcadero's Delphi compiler has supported COFF object format at least since Delphi XE2. However, there seems to be a serious limitation: If SSE instructions aren't disabled with gcc's -mno-sse2, there's a good chance to get access violations. More specifically, gcc places constants in .rdata section that is ignored by Delphi. (Tested with XE5, XE7, 10.1, 10.2, 10.3)
With GCC 8.2 the thing got even more difficult: Until now, it was enough to disable SSE2.
The following code, when compiled with gcc 8.2.1, results in SSE instructions even if -mno-sse2 is given as an option:
unsigned *pIndexTable;
...
// Initialize index values
for (int i = 0; i < count; i++) {
*pIndexTable = i;
pIndexTable++;
}
Objdump output:
*pIndexTable = i;
a56: 0f 28 05 00 00 00 00 movaps xmm0,XMMWORD PTR [rip+0x0] # a5d <GenerateTable+0x79d> a59: R_X86_64_PC32 .rdata
a5d: c1 e8 02 shr eax,0x2
a60: 0f 11 04 9d 00 00 00 00 movups XMMWORD PTR [rbx*4+0x0],xmm0
If SSE is totally disabled with -mno-sse, things get even more broken: SSE is a part of x86_64 ABI.