gcc - detection of memory section overflow in ld -


i have microcontroller project using gcc tool chain.

gcc version 4.7.4 20130913 (release) [arm/embedded-4_7-branch revision 202601] 

the controller has 512k flash memory. first 64k occupied bootloader , 448k remain project. defined linker script sizes flash , ram. added sections. here excerpt:

memory {   flash (rx)      : origin = 0x00010000, length = 448k   ram (xrw)       : origin = 0x10000000, length = 64k }  sections {   .text :   {     . = align(4);     *(.text)           /* .text sections (code) */   } > flash    .fini_array :   {     provide_hidden (__fini_array_start = .);     keep (*(.fini_array*))     provide_hidden (__fini_array_end = .);     _eflash = .;   } >flash    /* used startup initialize data */   _sidata = .;    .data : @ ( _sidata )   {     *(.data)           /* .data sections */     *(.data*)          /* .data* sections */     _edata = .;        /* define global symbol @ data end */   } >ram } 

the linker works fine placing section @ places. problem linker not check if there enough space .data , .data* sections in flash @ location _sidata. resulting output exceeds memory size without warning.

how can adapt linker script ld use initialization data (.data) in size calculation?

edit: there command line option enforce sensible data placement?

this linker malfunction can revealed assert:

  /* used startup initialize data */   _sidata = .;    .data : @ ( _sidata )   {     _sdata = .;     *(.data)           /* .data sections */     *(.data*)          /* .data* sections */     _edata = .;        /* define global symbol @ data end */   } >ram    /* verify initialization data fits in flash */   assert(      (_sidata + (_edata - _sdata)) <= (origin(flash) + length(flash)),      "initialization data blow up") } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -