<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>__init_array_start placed in RAM?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/7106/__init_array_start-placed-in-ram</link><description>Hi,
I&amp;#39;m just debugging, why global C++ object c&amp;#39;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</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 19 May 2015 06:07:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/7106/__init_array_start-placed-in-ram" /><item><title>RE: __init_array_start placed in RAM?</title><link>https://devzone.nordicsemi.com/thread/25105?ContentTypeID=1</link><pubDate>Tue, 19 May 2015 06:07:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f61b8e1-c474-41eb-9232-797be2f3fc90</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Ok, just tested it and it works like a charm :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: __init_array_start placed in RAM?</title><link>https://devzone.nordicsemi.com/thread/25108?ContentTypeID=1</link><pubDate>Tue, 19 May 2015 05:52:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a88efff-456b-4a8d-9440-1f1bdf109a81</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;I don&amp;#39;t think that function pointers can&amp;#39;t be called if they are constants that are placed in ROM. At least the STM32 CMSIS linker script places the vectors into flash. Maybe I should just try to fix the linker script and see what happens ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: __init_array_start placed in RAM?</title><link>https://devzone.nordicsemi.com/thread/25107?ContentTypeID=1</link><pubDate>Tue, 19 May 2015 05:42:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:926c10b2-c0d0-4844-a038-9983f8d18a89</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;There should be two parts to is, one piece allocated in RAM, the other piece allocated in flash which is where you&amp;#39;d expect to copy the pointers from to initialise them. Since these pointers are function pointers they don&amp;#39;t need to be copied at all, they can be called from flash directly, so the RAM is at best wasted and at worse incorrect - depends what crt0 does.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: __init_array_start placed in RAM?</title><link>https://devzone.nordicsemi.com/thread/25106?ContentTypeID=1</link><pubDate>Tue, 19 May 2015 05:37:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86330cff-deae-4921-8d91-2f092773ef8f</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;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&amp;#39;s not much, but this function pointers are not going to be changed during startup, so need for them to be placed into RAM.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: __init_array_start placed in RAM?</title><link>https://devzone.nordicsemi.com/thread/25104?ContentTypeID=1</link><pubDate>Tue, 19 May 2015 01:38:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29793267-fe2b-426a-8a58-63334e90c387</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;.. let me try that answer again ..&lt;/p&gt;
&lt;p&gt;The AT( __etext ) means the actual addresses are placed into flash because that&amp;#39;s where etext is pointing at the time that section is linked. I would expect gcc&amp;#39;s crt0 to run the pre/init/post functions from flash using the symbols __preinit_array_start .. etc.&lt;/p&gt;
&lt;p&gt;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&amp;#39;t going to be copied over. That would seem to waste RAM although it should still work.&lt;/p&gt;
&lt;p&gt;I&amp;#39;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.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>