Global Constructor Not Called

Asked by Xavier Hosxe

Hello,

I'm using GCC ARM Embedded 4.6-2012-q2 with the FEZ cerb40 board (STM32F405RG).
Those cortex-m4 chips are really fantastic.
Thanks a lot for working on this compiler...
Everything works fine...
Almost everything.

I'm currently blocked with a problem.
I don't have my C++ global constructor called.
If the object instantiation is done inside the main() function It's OK.
But if put it outside... the constructor is not called.

Do i miss something in the startup assembly code ?
Any URL that would explain that ?

Thanks for your help,

Xavier

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Xavier Hosxe
Solved:
Last query:
Last reply:
Revision history for this message
Joey Ye (jinyun-ye) said :
#1

Xavier,

Thanks for using this toolchain. Since you didn't share command line or source code I have to guess what happenned. One possible reason can be init_array are removed by gc-sections.

Did you use --gc-sections in linker command line? What linker script are you using?

- Joey

Revision history for this message
Xavier Hosxe (xavier-hosxe) said :
#2

Joey,

Thanks for your answer. And sorry for the missing files.
I use the linker script provided in the reamde.txt.
Bu i adapted a startup assembly file provided by the STM32F4 library.

And your answer helped me finding a solution to my problem in 5 minutes this morning.

The problem is that ofter copying flash to ram, it directly branched to my main function...
Instead of branching to '_start'.

Now it works -)

Xavier