EmbDev.net

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


von Bangla B. (Company: Bangla) (bangla)


Rate this post
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

von Martin Thomas (Guest)


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

von Bangla B. (Company: Bangla) (bangla)


Rate this post
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?

von Bangla B. (Company: Bangla) (bangla)


Rate this post
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

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.