EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Rowley: Accessing section start symbols from application code

Started by "jolyon.latham" October 6, 2008
Hello,

I have a complicated memory layout defined in my placement XML file.
Originally I had a corresponding header file with defines for each
section's address and size for use in the code. I would now like the
use symbols generated from the placement file so that I only need to
edit the memory map in one place.

For example, previously I had things like:

#define FLASH_BASE 0x01000000

Now I want to use:

#define FLASH_BASE __vectors_start__

The symbols work fine in crt0.s but within the main application code I
am unable to compile with errors such as:

'__ext_fast_start__' undeclared (first use in this function)

Are there any compiler options I need to include for it to be able to
resolve these symbols?

Also, if a section's Load option is set to "Yes", does the symbol name
become:

__section name_load_start__
?

Thanks for your help.

Jolyon

An Engineer's Guide to the LPC2100 Series

Hi,

you need an extern definition. Something like:

extern void * __vector_start__;

Add these to the header file where you have your defines. And don't
forget C adds an additional _ to the beginning of the variable name in
the object code. So you may need to play with the number of starting _:s.

Foltos

jolyon.latham wrote:
> Hello,
>
> I have a complicated memory layout defined in my placement XML file.
> Originally I had a corresponding header file with defines for each
> section's address and size for use in the code. I would now like the
> use symbols generated from the placement file so that I only need to
> edit the memory map in one place.
>
> For example, previously I had things like:
>
> #define FLASH_BASE 0x01000000
>
> Now I want to use:
>
> #define FLASH_BASE __vectors_start__
>
> The symbols work fine in crt0.s but within the main application code I
> am unable to compile with errors such as:
>
> '__ext_fast_start__' undeclared (first use in this function)
>
> Are there any compiler options I need to include for it to be able to
> resolve these symbols?
>
> Also, if a section's Load option is set to "Yes", does the symbol name
> become:
>
> __section name_load_start__
> ?
>
> Thanks for your help.
>
> Jolyon
>
>
Foltos,

Thanks for the reply. I have been trying to get it working without the
header file and just trying using the symbols directly in the code.
After your suggestion I tried:

int i = __stack_irq_end__;
int j = _stack_irq_end__;
int k = stack_irq_end__;

__stack_irq_end__ is used in crt0.s with no problems.

All 3 lines gave the "undeclared" error.

Jolyon.

--- In l..., Foltos wrote:
>
> Hi,
>
> you need an extern definition. Something like:
>
> extern void * __vector_start__;
>
> Add these to the header file where you have your defines. And don't
> forget C adds an additional _ to the beginning of the variable name
in
> the object code. So you may need to play with the number of starting
_:s.
>
> Foltos
>
> jolyon.latham wrote:
> > Hello,
> >
> > I have a complicated memory layout defined in my placement XML
file.
> > Originally I had a corresponding header file with defines for each
> > section's address and size for use in the code. I would now like
the
> > use symbols generated from the placement file so that I only need
to
> > edit the memory map in one place.
> >
> > For example, previously I had things like:
> >
> > #define FLASH_BASE 0x01000000
> >
> > Now I want to use:
> >
> > #define FLASH_BASE __vectors_start__
> >
> > The symbols work fine in crt0.s but within the main application
code I
> > am unable to compile with errors such as:
> >
> > '__ext_fast_start__' undeclared (first use in this function)
> >
> > Are there any compiler options I need to include for it to be able
to
> > resolve these symbols?
> >
> > Also, if a section's Load option is set to "Yes", does the symbol
name
> > become:
> >
> > __section name_load_start__
> > ?
> >
> > Thanks for your help.
> >
> > Jolyon
> >
> >
> >
> >
> >
> >
Hi,

> Foltos,
>
> Thanks for the reply. I have been trying to get it working without the
> header file and just trying using the symbols directly in the code.
> After your suggestion I tried:
>
> int i = __stack_irq_end__;
> int j = _stack_irq_end__;
> int k = stack_irq_end__;
>
> __stack_irq_end__ is used in crt0.s with no problems.

extern unsigned __stack_irq_end__[];

void do_stuff()
{
int *p = __stack_irq_end__;
}

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors

Thanks a lot!

--- In l..., "Paul Curtis" wrote:
>
> Hi,
>
> > Foltos,
> >
> > Thanks for the reply. I have been trying to get it working without
the
> > header file and just trying using the symbols directly in the
code.
> > After your suggestion I tried:
> >
> > int i = __stack_irq_end__;
> > int j = _stack_irq_end__;
> > int k = stack_irq_end__;
> >
> > __stack_irq_end__ is used in crt0.s with no problems.
>
> extern unsigned __stack_irq_end__[];
>
> void do_stuff()
> {
> int *p = __stack_irq_end__;
> }
>
> --
> Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
> CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors
>

Hi,

did you added the extern stuff?

extern void * __stack_irq_end__ ;
extern void * _stack_irq_end__;
extern void * stack_irq_end__;

Otherwise the C compiler will not known what these identifiers are.

jolyon.latham wrote:
> Foltos,
>
> Thanks for the reply. I have been trying to get it working without the
> header file and just trying using the symbols directly in the code.
> After your suggestion I tried:
>
> int i = __stack_irq_end__;
> int j = _stack_irq_end__;
> int k = stack_irq_end__;
>
> __stack_irq_end__ is used in crt0.s with no problems.
>
> All 3 lines gave the "undeclared" error.
>
> Jolyon.
>
> --- In l..., Foltos wrote:
>
>> Hi,
>>
>> you need an extern definition. Something like:
>>
>> extern void * __vector_start__;
>>
>> Add these to the header file where you have your defines. And don't
>> forget C adds an additional _ to the beginning of the variable name
>>
> in
>
>> the object code. So you may need to play with the number of starting
>>
> _:s.
>
>> Foltos
>>
>> jolyon.latham wrote:
>>
>>> Hello,
>>>
>>> I have a complicated memory layout defined in my placement XML
>>>
> file.
>
>>> Originally I had a corresponding header file with defines for each
>>> section's address and size for use in the code. I would now like
>>>
> the
>
>>> use symbols generated from the placement file so that I only need
>>>
> to
>
>>> edit the memory map in one place.
>>>
>>> For example, previously I had things like:
>>>
>>> #define FLASH_BASE 0x01000000
>>>
>>> Now I want to use:
>>>
>>> #define FLASH_BASE __vectors_start__
>>>
>>> The symbols work fine in crt0.s but within the main application
>>>
> code I
>
>>> am unable to compile with errors such as:
>>>
>>> '__ext_fast_start__' undeclared (first use in this function)
>>>
>>> Are there any compiler options I need to include for it to be able
>>>
> to
>
>>> resolve these symbols?
>>>
>>> Also, if a section's Load option is set to "Yes", does the symbol
>>>
> name
>
>>> become:
>>>
>>> __section name_load_start__
>>> ?
>>>
>>> Thanks for your help.
>>>
>>> Jolyon
>>>
>>>
>>>
>>>
>>>
>>>

The 2024 Embedded Online Conference