This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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

Hi,

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
/home/someuser/ti/psdk_rtos_auto_j7_07_00_00_11/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/bin/aarch64-none-elf-g++ 
-D[some definitions]
-I[some includes] 
-g 
-MD 
-ffunction-sections 
-fdata-sections 
-c -
mcpu=cortex-a72+fp+simd 
-mabi=lp64 
-mcmodel=large 
-mstrict-align 
-fms-extensions 
-mfix-cortex-a53-835769 
-mfix-cortex-a53-843419
-pedantic 
-fexceptions 
-std=gnu++11 
-o CMakeFiles/app.dir/main.cpp.obj 
-c /home/someuser/app/app/src/lvl1/main.cpp


[100%] Linking CXX executable bin/Debug/app
/home/someuser/ti/psdk_rtos_auto_j7_07_00_00_11/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/bin/aarch64-none-elf-ld
--gc-sections 
-nostartfiles 
--build-id=none 
--entry Entry 
--start-group 
-T /home/someuser/app/app/cmake/toolchain/tda4vm-a72-mpu1_0-baremetal.lds 
-L/home/someuser/ti/psdk_rtos_auto_j7_07_00_00_11/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/lib  
-L/home/someuser/ti/psdk_rtos_auto_j7_07_00_00_11/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/aarch64-none-elf/lib  
-L/home/someuser/ti/psdk_rtos_auto_j7_07_00_00_11/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/lib/gcc/aarch64-none-elf/9.2.1  
/shortenedPath/ti.drv.uart.aa72fg /shortenedPath/ti.osal.aa72fg 
/shortenedPath/ti.csl.init.aa72fg 
/shortenedPath/sciclient.aa72fg 
/shortenedPath/ti.drv.i2c.aa72fg 
/shortenedPath/ti.csl.aa72fg 
/shortenedPath/ti.board.aa72fg  
--start-group CMakeFiles/app.dir/main.cpp.obj --end-group 
--start-group -lstdc++ -lgcc -lm -lc -lrdimon --end-group 
--end-group 
-o bin/Debug/app.xa72fg 
-Map=bin/Debug/app.map

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,

Simon