catch handlers not working on linux

I discovered that fundamental exception handling is not functioning for me when building code for i386 linux and ppc linux. The programs terminate with unhanded exception errors when there are clearly catch handlers provided. I’m stepping through the assembly to see what might be going wrong, but I don’t yet have a clue yet why it is failing to find the catch handlers. Anyone have any useful insight into what might be happening? This is pretty fundamental functionality to be failing. I have a sneaky suspicion the problem lies in the interaction between clang and the binutils since it works fine if I target darwin with Apple’s clang.

compiler invocation:

ecc-g++ -target ppc-ellcc-linux test.cpp -o test.exe -lc++ -lUnwind -m32

ecc-g++ -target i386-ellcc-linux test.cpp -o test.exe -lc++ -lUnwind

clang version:

ecc-g++ --version
clang version 3.5 (trunk)
Target: ecc
Thread model: posix

sample that fails:


int main(int, char**)

throw std::exception();
catch(std::exception& e)
return -1;

return 0;

After a few hours of digging and tracing through the assembly code, the problem appears to be in the libunwind implementation used by ellcc and has nothing to do with the code generated by llvm. The getcontext function does not appear to be behaving correctly.