Segmentation faults with static linking

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

 



Hi,

I am getting Segmentation faults when statically linking gcc-4.0.2
libraries on AIX 5.1 (RS/6000).  Below is the test program that simply
throws exceptions.

#include <cstdlib>
#include <iostream>

void sinser()
{
        try {
            throw 1;
            } catch (int e) {
              std::cerr  << "Exception caught: " << e;
              std::cerr << std::endl;
              throw;
            }
}

int main()
{
  try {
      sinser();
     }  catch (int e) {
      std::cerr  << "Exception caught: " << e;
      std::cerr << std::endl;
    }
}

When the program is dynamically linked (g++ -g catch.cc) the executable
works fine.  
The ldd output is:
/usr/local/lib/gcc/powerpc-ibm-aix5.1.0.0/4.0.3/../../../libgcc_s.a(shr.
o)
/usr/local/lib/gcc/powerpc-ibm-aix5.1.0.0/4.0.3/../../../libstdc++.a(lib
stdc++.so.6)
/usr/lib/libcrypt.a(shr.o)
/usr/lib/libc.a(shr.o)

When the gcc libraries are statically linked, either completely (g++ -g
-static catch.cc) or specifically (g++ -g -nodefaultlibs -Wl,-bdynamic
-lc -lcrypt -Wl,-bnoquiet -Wl,-bstatic -lgcc -lgcc_eh -lstdc++ catch.cc)
a Segmentation Fault occurs. The output is:

terminate called after throwing an instance of 'int'
Segmentation fault (core dumped)

The stack trace is:

Program terminated with signal 11, Segmentation fault.
#0  0x10059f08 in __cxa_begin_catch (exc_obj_in=<incomplete type>)
    at ../../../../../gcc-4.0.3/libstdc++-v3/libsupc++/eh_catch.cc:80
80      ../../../../../gcc-4.0.3/libstdc++-v3/libsupc++/eh_catch.cc: A
file or directory in the path name does not exist..
        in ../../../../../gcc-4.0.3/libstdc++-v3/libsupc++/eh_catch.cc

Is it possible to create an executable that throws exceptions and
statically links in the gcc libraries without Segmentation faults?

Cheers,
Jon




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux