Re: [arm-gnu] Getting linker data into a C structure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [arm-gnu] Getting linker data into a C structure
- To: arm-gnu@xxxxxxxxxxxxxxxx
- Subject: Re: [arm-gnu] Getting linker data into a C structure
- From: 42Bastian <list-bastian.schick@xxxxxxxxxxx>
- Date: Mon, 10 May 2010 16:04:17 +0200
Am 10.05.2010 15:55, schrieb Andrew Kohlsmith (mailing lists account):
> extern const uint32_t _etext, _data_len;
>
> But the compiler complains bitterly about this ("error: initializer element is
> not constant"). The solution that I have found in a couple of places online
> is this:
>
> extern const uint32_t _etext[], _data_len[];
A symbol defined in the linker script is an address.
const uint32_t _etext;
defines a variable/value. Remember, you need &_etext to get the address of
that variable.
> and then to cast them back to uint32_t in the structure initializer:
>
> const fw_struct_t fw_struct = {
> .checksum = 0, /* filled in by checksummer */
> .version = VERSION_CODE,
> .initdata_loc = (uint32_t)_etext,
Shouldn't this be a (char *) ?
> .initdata_len = (uint32_t)_data_len,
> };
>
> This looks wrong, it feels wrong, but it works beautifully. ld correctly
> supplies the values for the extern consts and life is good.
>
> Can anyone explain to me like I'm a six year old why on earth I need to
> specify the external constant integers as integer arrays? Why does GCC
Only if defined in the linker !
--
42Bastian
+
| http://www.sciopta.com
| Fastest direct message passing kernel.
| IEC61508 certified.
+