I have investigated the issue a bit. It seems it's a uClibc++ fault as my test program linked against libstdc++ catches all exceptions as expected whereas the same program linked against uClibc++ terminates after throwing the very first exception.
uClibc++ however doesn't implement exception handling itself. It
declares all required functions and
copies/steals their implementations from libstdc++ by extracting required object files from libsupc++.a and libgcc_eh.a (see src/abi folder). So the implementation is actually exactly the same as that contained in libstdc++. I assume that uClibc++ doesn't initialize some internal structures or whatever and that's the reason it doesn't work. I however didn't manage yet to find out what exactly is going wrong.
gdb produces the following output:
Code:
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "mipsel-linux-uclibc"...
(gdb) run
Starting program: /var/media/ftp/uStor01/excepttest
Starting exception testing
Throwing out of range
terminate called after throwing an instance of 'std::out_of_range'
what(): This is text
Program received signal SIGABRT, Aborted.
0x2ab1c694 in kill () from /lib/libc.so.0
(gdb) bt
#0 0x2ab1c694 in kill () from /lib/libc.so.0
#1 0x2ab5f968 in abort () from /lib/libc.so.0
#2 0x2aaec6dc in __gnu_cxx::__verbose_terminate_handler () from ./libuClibc++.so.0
#3 0x2aaea0b4 in __cxxabiv1::__terminate () from ./libuClibc++.so.0
#4 0x2aaea118 in std::terminate () from ./libuClibc++.so.0
#5 0x2aaea2ec in __cxa_throw () from ./libuClibc++.so.0
#6 0x00400ed8 in main (argc=<value optimized out>, argv=<value optimized out>) at excepttest.c:13
(gdb)
I should probably compile gcc or at least libsupc++ and libgcc_eh with debug information enabled to get more information as reading gcc's source code alone doesn't bring me any further as all this unwind/exception stuff is absolutely new to me...
I already contacted the maintainer of uClibc++, let's see what he suggests.
For those of you who'd like to investigate the issue by themselves here is the
link that might be interesting. Also take a look at the source code of gcc in particular at that located in libstdc++-v3/libsupc++.
p.s. I have already looked at openwrt and incorporated some patches from them but it still doesn't solve the issue.