Search code examples
assemblycross-compilinggnuarmcc

arm assembly instruction to their gnu equivalent ones


below are some code of lines which are compatible with arm assembler I want to convert these to their gnu equivalents. Basically I was trying to run a code on bare metal cortex-r4 and after looking over the internet I cannot find a startup and linker file for gnu ( for cortex-r4) so finally decided to convert these to gnu assembly. I tried and changed these before but there were some errors (however the code compiled smoothly, error were run time)

PRESERVE8
AREA   VECTORS, CODE, READONLY     ; Name this block of code
ENTRY
EXPORT Start
Start
IMPORT       ||Image$$ARM_LIB_STACKHEAP$$ZI$$Limit||
LDR     SP, =||Image$$ARM_LIB_STACKHEAP$$ZI$$Limit||
DCD
IF {TARGET_FPU_VFP}

If you can provide or guide me to a startup or linker file it would be a plus

regards,


Solution

  • Most of the keywords here are ARM compiler/linker specific with no direct counterpart in GNU C.

    The code creates a funtion "Start" which simply sets the stack pointer (SP) to the given literal. And instructs the linker to put this code in the readonly (RO) area of the memory map. Though your code is incomplete as there seems to be an IF clause.

    If you understood the ARM code then it would be relatively easy to translate that into a simple ld linker script. Read more here:
    http://www.embedded.com/design/mcus-processors-and-socs/4026075/Building-Bare-Metal-ARM-Systems-with-GNU-Part-2
    http://www.embedded.com/design/mcus-processors-and-socs/4026080/Building-Bare-Metal-ARM-Systems-with-GNU-Part-3