Move in assembly

I have a boot code for voice ARM written in the assembly, and I'm trying to understand how this works. The binary file is written to some external Flash and copies parts of itself to RAM at startup. In this context, I still do not understand the concept of relocation, although I read this wikipedia entry . RAM is displayed in the low address window, and flash is displayed in the high address window. Can someone explain to me why we are testing the value of the link register here?

/* Test if we are running from an address, we are not linked at */
       bl check_position
 check_position:
        mov     r0, lr                  
        ldr     r1, =check_position
        cmp     r0, r1                  /* ; don't relocate during debug */
        beq     relocated_entry 
+5
source share
2 answers

, ram, , , - / jtag ram, ( ).

, - , - . , , - (), ram, - -, . , , , " ram and branch", ( ), - , .

+5

- , ?

bl check_position PC+4 check_position PC-. bl ARM PC .

ldr r1,=check_position . Ref1 ,

  ldr r1,[pc, #offset]
...
  offset:
    .long check_position   # absolute address from assemble/link. 

, R0 , R1 . . , , ; , , . Ref2 , R0 R1 . pseudo code bl.

 mov lr,pc               ; pc is actually two instruction ahead.
 add pc,pc,#branch_offset-8

, bl PC, lr. mov R0,PC, , PC 8 . adr R0,check_position, .

 /* Test if we are running from an address, we are not linked at */
 check_position:
    adr    r0, check_position
    ldr    r1, =check_position
    cmp    r0, r1                  /* ; don't relocate during debug */
    beq    relocated_entry 

Ref1: Arm op-codes .ltorg gnu-
Ref2: , Linux head.S ARM.

: ARM ARM, , -, +8, , . , adr , -op adr , .

+3

All Articles