Exception handling on AIX5.3 with gcc 3.4.6

2008-03-20 Thread Shlom Marom
Hi guys,

I have some weird problem with exception handling on AIX (gcc 3.4.6
with AIX5.3), which I couldn't find any solution for in the web.

-
Problem description:
-
When throwing an exception of some derived object type, catch it,
re-throw it and then try to catch it by the base object, the program
gets segmentation fault instead of being caught by the relevant catch.
BUT, please not to the weirdest problem:
If I compiled the program with shared lib-gcc and with the pthread
libstdc++ - everything works fine and also the base exception is being
caught as it should.

*Attached here a very small cpp file that contains a simple, for your
convenient, although I will also paste the code in the email body…

-
The code:
-
#include 
void fun(void)
{
printf("in fun() - before throwing int...\n");
throw 1;
}
int main(void)
{
try
{
try
{
fun();
}
catch(int i)
{
printf("catch int exception: %d, and re-throw...\n", i);
throw;
}
}
catch (...)
{
   printf("the re-throw was caught...\n");
}
return 0;
}


Compilation (and link) commands:

Shared linking: gcc -o tester_shared main.cpp -pthread -I.
-shared-libgcc -L/usr/lib -ldl -lpthread -lstdc++
Static linking: gcc -o tester_static main.cpp -L/usr/lib/threads
-pthread -I. -static-libgcc -L/usr/lib -ldl -lpthread `gcc
-print-file-name=libstdc++.a` -O
*** `gcc -print-file-name=libstdc++.a` returns
/usr/local/lib/gcc/powerpc-ibm-aix5.3.0.0/3.4.6/../../../libstdc++.a


Executables ldd output:

Shared linking:

$ldd ./tester_shared
/usr/local/lib/gcc/powerpc-ibm-aix5.3.0.0/3.4.6/../../../libgcc_s_pthread.a(shr.o)
/usr/local/lib/gcc/powerpc-ibm-aix5.3.0.0/3.4.6/../../../pthread/libstdc++.a(libstdc++.so.6)
/usr/lib/libpthread.a(shr_xpg5.o)
/usr/lib/libpthread.a(shr_comm.o)
./tester_shared
/usr/lib/libcrypt.a(shr.o)
/usr/lib/libc.a(shr.o)

Static linking:

$ldd ./tester_static
/usr/lib/libpthread.a(shr_xpg5.o)
/usr/lib/libpthread.a(shr_comm.o)
./tester_static
/usr/lib/libcrypt.a(shr.o)
/usr/lib/libc.a(shr.o)


Executables output:

Shared linking:

in fun() - before throwing int...
catch int exception: 1, and re-throw...
the re-throw was caught...

Static linking:

in fun() - before throwing int...
catch int exception: 1, and re-throw...
Segmentation fault (core dumped)



My purpose:

I need to find a way to fully support exception handling and
statically link libgcc, since I don't want to distribute it with my
libs and executables, as part of my products



Notes:


1. The same problem happens when instead of re-throw int and catch
(...) , you re-trow derived and catch base...
2. The same code works fine on other UNIX os, such as Linux (RHEL,
Fedora, etc.…)


Thanks in advanced,

Shlom Marom
#include 

void fun(void)
{
printf("in fun() - before throwing int...\n");
throw 1;
}

int main(void)
{
try
{
try
{
fun();
}
catch(int i)
{
printf("catch int exception: %d, and re-throw...\n", i);
throw;
}
}
catch (...)
{
printf("the re-throw was caught...\n");
}
return 0;
}


collect2: ld returned 12 exit status

2008-07-24 Thread Shlom Marom
Hi,
I'm trying to compile and link a product that was already compiled and
linked successfully before, on AIX5.3 with gcc3.4.6, but I got the
following link err:
"collect2: ld returned 12 exit status"

Pls note that this happens to me only when not using  the strip flag
(-s) since I need the symbols for debugging...
=> I can link only the release version.

I didn't see any memory/space problem on my machine, but I'm whilling
to try evrything you suggest, since I'm stuck with this problem for
too long.


thank,
Pls send you respose ALSO to the following email address: [EMAIL PROTECTED]