section .data overlaps other section

OP #1171508
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

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.