This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: What is .init_array and how does it affext an arm-eabi build for bare metal?
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Rob Emanuele <poorarm at shoreis dot com>
- Cc: binutils at sourceware dot org
- Date: Fri, 23 Jan 2009 10:02:05 +0000
- Subject: Re: What is .init_array and how does it affext an arm-eabi build for bare metal?
- References: <c8284b5b0901221652y1b23087esb4f32b902804bfc5@mail.gmail.com>
On Thu, 2009-01-22 at 16:52 -0800, Rob Emanuele wrote:
> Hi all,
>
> I am building an application for a Cortex-m3 processor. When built
> the map file and executable show a section called .init_array located
> in the chip's main RAM. This section is not in my linker script.
> What is this section for? From what I can tell it is stdc++ related
> but I could use more information. The fact that this ends up in my
> main RAM concerns me as it will be uninitialized upon reset. If I was
> to add it to my linker script where should it live?
.init_array contains pointers to blocks of code that need to be executed
when an application is being initialized (before main() is called). Its
used for a number of things, but the primary use is in C++ for running
static constructors; a secondary use that is sometimes used is to
initialize IO systems in the C library.
If you are not using C++ you may (depending on your C library) be able
to live without it entirely; but you'd need to hack your startup code to
deal with this.
.init_array probably ends up in ram because its marked read/write --
that happens because in a dynamic linking environment the dynamic linker
has to fix up all the pointers it contains before it can be used. In a
static environment you might be able to get away with forcing it into a
read-only section.
R.