C++ Exception Support on Baremetal aarch64-none-elf


I'm trying to build a baremetal application with C++ exception support with aarch64-none-elf.

The application is working, but when an exception is thrown, the code doesn't jump into the catch block.

It seems that the exception handling is missing, because when throwing an exception, the code stops at uw_update_context() and is not able to unwind.

When I check the map file, all sections regarding exception handling (eh_frame, eh_alloc, eh_catch and others) are discarded.

The commands I use to build and link look like this:

[ 25%] Building CXX object CMakeFiles/app.dir/main.cpp.obj
-D[some definitions]
-I[some includes] 
-c -
-o CMakeFiles/app.dir/main.cpp.obj 
-c /home/someuser/app/app/src/lvl1/main.cpp

[100%] Linking CXX executable bin/Debug/app
--entry Entry 
-T /home/someuser/app/app/cmake/toolchain/tda4vm-a72-mpu1_0-baremetal.lds 
/shortenedPath/ti.drv.uart.aa72fg /shortenedPath/ti.osal.aa72fg 
--start-group CMakeFiles/app.dir/main.cpp.obj --end-group 
--start-group -lstdc++ -lgcc -lm -lc -lrdimon --end-group 
-o bin/Debug/app.xa72fg 

If I add -fexceptions to the link flags, the linker tells me that this can only be used with -shared but then I get a lot of errors like dangerous relocation: unsupported relocation and relocation ... against symbol `end' which may bind externally can not be used when making a shared object; recompile with -fPIC.

If I add -fPIC to the compilation, the error is cc1plus: sorry, unimplemented: code model 'large' with '-fPIC'

Does this mean that exceptions on baremetal are not supported by this version of GCC?

How can I get the section for exception handling to not get discarded by the linker?

What am I missing? I'm thankful for every hint :)

Thanks in advance,


More questions in this forum