This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ds5 armcc link erro

I am building a shared library for my own os with armcc(for some reason used the stdlib's 'malloc'), the link options is "--fpic --shared --linker_script="../lscript.ld" ",buf I got a link fault with:Error: L6286E: Relocation #REL:7 in h1_alloc_mt.o(.text) with respect to _malloc_internal. Value(0xfffdae36) out of range(-0x800 - 0x7fe) for (R_ARM_THM_JUMP11), what should i do? thanks

the 'lscript.ld' as bellow(referenced from armcc doc):

SECTIONS

{

  . = 0 + SIZEOF_HEADERS;

  .note.ABI-tag   : { *(.note.ABI-tag) }

  .hash           : { *(.hash) }

  .dynsym         : { *(.dynsym) }

  .dynstr         : { *(.dynstr) }

  .version        : { *(.version) }

  .version_d      : { *(.version_d) }

  .version_r      : { *(.version_r) }

  .rel.dyn        : { *(.rel.dyn) }

  .rela.dyn       : { *(.rela.dyn) }

  .rel.plt        : { *(.rel.plt) }

  .rela.plt       : { *(.rela.plt) }

  .init           : { KEEP (*(.init)) }

  .plt            : { *(.plt) }

  .text           : { *(.text .text.*) }

  .fini           : { KEEP (*(.fini)) }

  PROVIDE(__etext = .);

  PROVIDE(_etext = .);

  PROVIDE(etext = .);

  .rodata         : { *(.rodata .rodata.*) }

   __exidx_start = .;

  .ARM.exidx   : { *(.ARM.exidx*) }

   __exidx_end = .;

  .interp         : { *(.interp) }

  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1));

  . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));

  .tdata  : { *(.tdata .tdata.*) }

  .tbss  : { *(.tbss .tbss.*) }

  .preinit_array     :

  {

     PROVIDE_HIDDEN (__preinit_array_start = .);

     KEEP (*(.preinit_array))

     PROVIDE_HIDDEN (__preinit_array_end = .);

  }

  .init_array     :

  {

     PROVIDE_HIDDEN (__init_array_start = .);

     KEEP (*(.init_array*))

     PROVIDE_HIDDEN (__init_array_end = .);

  }

  .fini_array     :

  {

     PROVIDE_HIDDEN (__fini_array_start = .);

     KEEP (*(.fini_array*))

     PROVIDE_HIDDEN (__fini_array_end = .);

  }

  .dynamic        : { *(.dynamic) }

  .got            : { *(.got.plt) *(.got) }

  .data           :

  {

    __data_start = .;

    *(.data .data.*)

  }

  _edata = .;

  PROVIDE(edata = .);

  __bss_start = .;

  __bss_start__ = .;

  .bss            :

  {

   *(.bss .bss.*)

   . = ALIGN(. != 0 ? 32 / 8 : 1);

  }

  __bss_end__ = .;

  _bss_end__ = .;

  . = ALIGN(4);

  __end = .;

  _end = .;

  PROVIDE(end = .);

}

  • Hi,

    Here are some pointers from our compilation tools team, which should hopefully help:

    In general, it's best to avoid statically linking the C library into a shared library. The linker has an option --no_scanlib which will prevent it from scanning the ARM C libraries. We recommend dynamically linking against a C library shared object. In a Linux environment this would usually be GNU libc, but since you mention that you are building your own OS, this might not work "out of the box". It's possible that you can build the ARM C libraries into a shared library, but there is no standard way to do this. Here's an application note on Infocenter that you can use as a guide to building an OS with dynamic linking support.

    The error that you are seeing is caused by the linker creating a PLT entry for the Thumb branch to _malloc_internal. The PLT entry is created because _malloc_internal has STV_DEFAULT visibility and can be pre-empted by a definition of _malloc_internal in an application using the shared library. The branch to the PLT entry will be out of range as the Thumb relocation range is too short.

    There are a couple of ways you can work around the problem:

    1. Use --no_thumb2_library which will cause armlink to use the Thumb/ARM library rather than the Thumb2 library. This library uses R_ARM_THM_CALL which has plenty of range to reach the PLT entry.

    2. If you are not planning to support symbol pre-emption, then --max_visibility=protected should prevent the linker from generating a PLT entry.

    Try these methods out and see if the application note helps as well. If you are still having trouble, it might be a good idea to contact ARM technical support directly so that they can walk through the problem with you.

    Thanks,

    Joe

  • Hi Joe,

    It's help full, my project linked successfully whith the option --no_thumb2_library , and we are also thinking about your opinion about using ARM C libraries 。

    Thank your very much for your answer!

    fcwindpass

  • Hi fcwindpass,

    Glad to hear it worked - good luck with the rest of your project.

    Joe