Array size depending on symbol address



Hello,

I am running my code on an embedded platform without OS. I have defined some
data in a section called .eeprom. The section is defined by the linker
script and starts at address zero. The symbol __eeprom_end is defined by the
linker script as well, and lies at the end of this section. The address of
__eeprom_end is thus equal to the number of bytes in the .eeprom section.

My problem : I want to declare an array in .bss with the same size of this
section. My naive approch was :

extern void *_eeprom;
char eeprom_shadow[(int)&_eeprom_end];

This fails miserably, ofcourse : the compiler doesn't know the address of
__eeprom before the linker is done, so it can not declare the array.

Is there a trick to allocate the memory for this array at compile time ? I'd
rather not use malloc() and friends, since I am working on a platform with a
very small amount of memory, and don't like using dynamic memory here.

Thanks,


--
:wq
^X^Cy^K^X^C^C^C^C
.



Relevant Pages

  • Re: Array size depending on symbol address
    ... >I am running my code on an embedded platform without OS. ... >__eeprom before the linker is done, so it can not declare the array. ... >very small amount of memory, and don't like using dynamic memory here. ...
    (comp.lang.c)
  • Re: Array size depending on symbol address
    ... I want to declare an array in .bss with the same size of this ... >>very small amount of memory, and don't like using dynamic memory here. ... > which can change the size of the .eeprom section AGAIN, ... declare some variables with attributes to place them in the .eeprom section, ...
    (comp.lang.c)
  • Re: PIC and EEPROM modules
    ... EEPROM than I have on the chip. ... The tunes are stored in the memory. ...
    (sci.electronics.design)
  • Re: Memory selection for an embedded system
    ... and high density per dollar, but it requires a refresh circuit which ... one device, which for most embedded systems, unless you call pentium ... often times used as ROM while EEPROM is ... The choice of which type of memory you select depends on the goal of ...
    (comp.arch.embedded)
  • Re: Datalogger with Flash
    ... the begining of the memory, and thats ok with the eeprom, but with the ... the message that im writing its 16 Bytes Long. ... If your moving up to a flash part, ... You are already over writting 16 bytes in a full eeprom. ...
    (comp.arch.embedded)