kendryte / kendryte-freertos-sdk

This project is no longer maintained Not recommended for product development.
Apache License 2.0
201 stars 67 forks source link

Increase alignment of eh_frame from 8 to 32 bytes #66

Closed nmaitland closed 3 years ago

nmaitland commented 3 years ago

Fixes #65

Fixes fatal sys_exit when exceptions are throw from C++ code.

minux commented 3 years ago

is this alignment the real cause? because .eh_frame section shouldn't need anything more than pointer alignment.

nmaitland commented 3 years ago

@minux I had originally posted an alternative fix, where I manually moved the crtend.o file to the end of the linker command line. However I couldn't see how to make this a default part of the build chain and changing alignment of eh_frame seemed to also fix. I appreciate your input... https://github.com/sipeed/platform-kendryte210/issues/32#issue-709019100

minux commented 3 years ago

crtend.o and crtn.o should usually be the last two object files linked, and these are usually added by the g++ driver. I'm not sure why the SDK manually links them in, perhaps the compiler builtin spec file is wrong.

Anyway, for the current approach of manually linking these files, I think the correct fix is to fix https://github.com/kendryte/kendryte-freertos-sdk/blob/45a5b641a8456b9d3623435946a92c6c2503d228/cmake/toolchain.cmake#L43 so that it places \"${CRTEND_OBJ}\" \"${CRTN_OBJ}\" after . please also fix https://github.com/kendryte/kendryte-freertos-sdk/blob/45a5b641a8456b9d3623435946a92c6c2503d228/cmake/toolchain.cmake#L46 for the same problem.

Thanks for working on this.

nmaitland commented 3 years ago

Thanks for your comments and info. I've actually been using platformio for my builds up to now and as I'm new to this platform I hadn't realised that this uses a different build chain to the core kendryte-freertos-sdk project (scons vs cmake). So I've now checked and confirm that my test works fine when built in the SDK cmake tools, and just fails with platformio.

I've now raised a ticket in https://github.com/sipeed/platform-kendryte210. Tx for helping me out here and sorry for causing unnecessary effort.