This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

__init_array_start placed in RAM?

Hi, I'm just debugging, why global C++ object c'tor are not called when using gcc/newlib. I stombled over the fact that within the linker script, provided with the sdk 8.2, the .init_array sections of the objects are placed into RAM.

Why is this so? Why not placing this vector into flash?

kind regards, Torsten

Parents
  • .. let me try that answer again ..

    The AT( __etext ) means the actual addresses are placed into flash because that's where etext is pointing at the time that section is linked. I would expect gcc's crt0 to run the pre/init/post functions from flash using the symbols __preinit_array_start .. etc.

    However it does seem that those sections are also allocated space in RAM, much like initialised data which would be copied over, even though they aren't going to be copied over. That would seem to waste RAM although it should still work.

    I've always found it rather tricky to work out which crt0 gcc links in with various combinations of flags and libraries and usually end up looking at the ELF file to work out which it is.

  • From the mapfile, I can see that the .init_array sections are allocated to RAM. Why do you think it just seems like they are allocation RAM? I mean it's not much, but this function pointers are not going to be changed during startup, so need for them to be placed into RAM.

Reply Children
No Data
Related