Can I assign logical address of v8m .gnu.sgstubs section on SRAM region?

Asked by chiche ma

Hi,
    Can I assign logical address of v8m .gnu.sgstubs section on SRAM region?
    When I configure linker script below, ld.exe will fail.

    .gnu.sgstubs 0x2000fc00:
    {
        . = ALIGN(4);
        _start_sg = .;
        *(.gnu*)
        . = ALIGN(4);
        _end_sg = .;
    }

    c:/program files/gnu tools arm embedded/6.2 2016q4/bin/../lib/gcc/arm-none-eabi/6.2.1/../../../../arm-none-eabi/bin/ld.exe: BFD (GNU Tools for ARM Embedded Processors) 2.27.51.20161204 assertion fail /tmp/jenkins-GCC-6-buildandreg-54_20161216_1481890185/src/binutils/bfd/elf32-arm.c:4276

    if I change 0x2000fc00 to flash address (say 0x3fc00), everything seems fine.

    I just want to do something like .data section, put .sgstubs in physical flash address, and move them onto SRAM while booting.

    .data :
    {
        . = ALIGN(4);
        _sdata = .; /* create a global symbol at data start */
        *(.data) /* .data sections */
        *(.data*) /* .data* sections */
        . = ALIGN(4);
        _edata = .; /* define a global symbol at data end */
    } >RAM AT> FLASH

    But it seems to have limit to do so, could anyone give me some advice?

B.R.
Terry

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Thomas Preud'homme
Solved:
Last query:
Last reply:
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#1

Hi Chiche,

This assert failure usually means that the secure gateway entry in .gnu.sgstubs for the entry point that you are trying to call is too far from the entry point. You need to make sure that the maximum offset between .gnu.sgstubs and the secure code it is branching to is betweet -1048576 to 1048574.

Best regards.

Revision history for this message
chiche ma (ccma1120180) said :
#2

Hi Thomas,

I compared assembly code of armcc with arm-none-eabi-gcc, armcc use veneer layer to make branch offset with no limit.
It pushes a dummy register into stack, calculate the destination address then replace the dummy register location at stack, pop the destination to R15 PC register and jump to it.
It would be great if GNU ARM embedded compiler can do similar thing.

Sincerely,
Terry

Revision history for this message
Best Thomas Preud'homme (thomas-preudhomme) said :
#3

The GNU linker is normally capable of doing such thing but has problems in this case because the SG veneer is created dynamically. It requires more work on the linker. We are aware of the issue and will come round to it when we have enough resources.

Best regards.

Revision history for this message
chiche ma (ccma1120180) said :
#4

Thanks Thomas Preud'homme, that solved my question.