EmbDev.net

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


von Andy K. (ddancer)


Rate this post
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
below):


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

  .rodata  : {

    . = ALIGN(4);
    *(.rodata)

  } > 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. */

    jumptab.o(.data)

    *(.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

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.