EmbDev.net

Forum: ARM programming with GCC/GNU tools ARM linking problem


Author: Bangla B. (Company: Bangla) (bangla)
Posted on:

Rate this post
0 useful
not useful
Hi,
I am using a M3 cpu (STM32103) and a gcc toolchain selfmade. Everything 
work fine if I compile my code for using the internal Flash (for the 
code) and the internal RAM (for the data). For reason of place I have to 
use the external RAM. So, I have modified my linker script accordingly. 
Now the linker report a problem.

With this script the linker works

_stEPROM   = 0x00000000;
_stRAM     = 0x20000000;

MEMORY {
  prgm_code (rx)  : ORIGIN = 0x00000000, LENGTH = 512K
  prgm_data  (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
}

SECTIONS {
  .text _stEPROM : {
    _stVECTORS = ABSOLUTE(.);
    KEEP(*(.isr_vector))
    _enVECTORS = ABSOLUTE(.);
    _stTEXT = ABSOLUTE(.);
      *(.text .text.*)
    _enTEXT = ABSOLUTE(.);
    _stRODATA = ABSOLUTE(.);
      *(.rodata .rodata.*)
      . = ALIGN(4);
    _enRODATA = ABSOLUTE(.);
  } > prgm_code

  .data _stRAM :  AT (_enRODATA) {
    _stDATA = ABSOLUTE(.);
      *(.data .data.*)
      . = ALIGN(4);
    *(vtable)
    *(.data*)
    _enDATA = ABSOLUTE(.);
  } > prgm_data

    . = ALIGN(4);
    .eh_frame : {
        KEEP (*(.eh_frame))
    } > prgm_data

    . = ALIGN(4);
  .ARM.extab : {
    *(.ARM.extab*)
  } > prgm_data

    . = ALIGN(4);
  __exidx_start = ABSOLUTE(.);
  .ARM.exidx : {
    *(.ARM.exidx*)
  } > prgm_data
  __exidx_end = ABSOLUTE(.);

  .bss (NOLOAD) : {
    _stBSS = ABSOLUTE(.);
      *(.bss .bss.*)
      . = ALIGN(4);
    *(COMMON)
      . = ALIGN(4);
    _enBSS = ABSOLUTE(.);
    _end = ABSOLUTE(.);
    end = ABSOLUTE(.);
    _heap = ABSOLUTE(.);
    . += 0x800;
    _main_stack = ABSOLUTE(.);
  } > prgm_data
}

With this modification the linker fails

_stEPROM   = 0x00000000;
_stRAM     = 0x60000000;

MEMORY {
  prgm_code (rx)  : ORIGIN = 0x00000000, LENGTH = 512K
  prgm_data  (rwx) : ORIGIN = 0x60000000, LENGTH = 8M
}

The linker reports me this error:

/Users/Shared/cross/gcc-4.6.1/arm/lib/gcc/arm-none-eabi/4.6.1/thumb/v7m/ 
libgcc.a(unwind-arm.o):(.ARM.exidx+0x38):  relocation truncated to fit: 
R_ARM_PREL31 against `.text'
/Users/Shared/cross/gcc-4.6.1/arm/lib/gcc/arm-none-eabi/4.6.1/thumb/v7m/ 
libgcc.a(unwind-arm.o):(.ARM.exidx+0x40):  additional relocation 
overflows omitted from the output

I have tried to use the compilation flag -mlong-calls but t doesn't 
work.
Any opinion or idea to workaround this problem?
Regards
  Bangla

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
Please create a minimal but full example so just typing "make all" in a 
shell will do to reproduce the issue.

Author: Bangla B. (Company: Bangla) (bangla)
Posted on:

Rate this post
0 useful
not useful
Hi Martin,
Of course I did a minimal project. It turns out that the problem appears 
only when I call a newlib function (like printf, puts, etc).
Strange ... do you think I have to recreate the libc and libgcc with 
some special configuration flags?

Author: Bangla B. (Company: Bangla) (bangla)
Posted on:

Rate this post
0 useful
not useful
I have rebuild all my toolchain with the switch 
--enable-newlib-io-long-long disabled during the newlib creation. Now it 
works. It is difficult to understand what is happening. Anyway, this is 
only a partial solution because I need to print long long integers.

Any comment or suggestions?
Regards
  Bangla

Reply

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.