Forum: ARM programming with GCC/GNU tools section .data overlaps other section

Author: Andy K. (ddancer)
Posted on:

Rate this post
0 useful
not useful
Hi everybody,

  I have problem with linking my application. The section .data should
be stored after sections .text and .rodata in flash and copied to RAM by
startup code. To tell this to linker I use linker script (part shown

  .vectors : { *(.vectors) }     > VECT
  .config  : { *(.sgfm_config) } > CFG
  .text    : { *(.text) }        > TEXT

  .rodata  : {

    . = ALIGN(4);

  } > TEXT

  . = ALIGN(4);

  /************* HERE IS PROBLEM *******/
  __rom_data_start = .;
  /* I should expect that . points after .rodata section, shouldn't I?

  .data : AT(__rom_data_start) /* This section is located at wrong 0x58
address */
    __ram_data_start = .;

    /* IRQ handling requires the jump table to be at 0x40000000.
       If you don't put it there, then you must rewrite the vsr_IRQ
       function in crt0.S so it can find the table. */


    *(.data .data.* .gnu.linkonce.d.*)

   /* crt0.S copies data 32 bits at a time, so alignment is critical.
      Align here to ensure that the .data section occupies space up to
      _end.  Align after .data to ensure correct alignment even if the
      .data section disappears because there are no input sections. */

   . = ALIGN(4);

  __ram_data_end = . ;

  } > RAM

I expect, that symbol __rom_data_start will point to the first word
after section .rodata where the flash image of .data section should be
stored. It should be a result of using . (dot - actual location
counter). But it doesn't work! In my application __rom_data_start should
be at say 0x2000 but it is at 0x58 and overlaps section .config.

The problem comes when I try to use malloc function (I have my own
syscalls.c with sbrk function). When I do not use malloc, there is no
problem, but I've just started my app.

I used GnuARM distribution and WinARM: 4.0.1 4.0.2 4.1.0 with
newlib-1.4.0. With same results.

Please help! Andy


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.