Intel® Compiler and Xcode* 3.2.2 linker - binary runtime crash with switch statement


Problem :
Compiling the following test case with the Intel ® C++ Composer XE for 64 bit will result in a segmentation fault when the 64bit binary is run on a 32bit kernel.

struct Tester {
void test(int i) {
// Five cases to trigger branch table optimisation.
switch(i) {
case 1: break;
case 2: break; 
case 3: break;
case 4: break; 
case 5: break;

int main() {
Tester tester;

Environment :
Mac OS* X 10.6.3, Mac OS X 10.6.4, Xcode 3.2.2, Xcode 3.2.3, Xcode 3.2.4 Intel C++ compiler and Intel ® C++ Composer XE.

Root Cause :

The problem is in the linker from Xcode 3.2.2, Xcode 3.2.3, Xcode 3.2.4 which has a bug with resolving relocations for symbols with names that start with 'L'.

By convention assembler suppresses all symbols with name starts with 'L' so when using gcc or (icc with -use_asm option) the linker will not see these symbols.

This problem might also show up in fortran CASE construct.

Resolution :

Current status, this problem with the 11.1 compiler is a result of a bug in the linker that comes with Xcode 3.2.2, 3.2.3, 3.2.4.

The work arounds are:

1) Use Xcode 3.2.1 with 11.1 compiler.
2) Use 11.1 compiler with the option -use-asm with Xcode 3.2.2, 3.2.3, 3.2.4.
It should fix most cases but there are some cases when even generating object file through external assembler L* symbols still may appear in object file. Those cases are usually constant string literals placed in cstring section
3) Use Intel Composer XE.

We are not planning to work around this linker bug in the 11.1 compiler due to the complexity of the workaround which might reduce the stability of the 11.1 product.

For reference, the support issue number is DPD200156500.


For more complete information about compiler optimizations, see our Optimization Notice.