2018-01-12 01:23 AM
I am using ♯STM32f070xB, In my program, I am trying to access registers (i.e. assembly code). My assembly code has branching instruction, which trying to branch to the function defined in another source file (.c).
Now the problem is, Branching instruction is generation error: [Lp002]: relocation failed: value out of range or illegal
What can be the possible reason behind and how I can resolve this.
#cortex-m0 #source-file #core-self-test #assembly-language #stm32f070 #stm32f02018-01-13 08:42 AM
Doesn't it suggest the relative branch target is too far away?
Not using IAR, but this should work
; Jump to function foo()
EXTERN foo
ldr r0, =foo
bx r0
; Call bar()
EXTERN bar
bl bar
2018-01-15 08:42 PM
,
,
Thanks for your response.
I have done the same. which generates the error of relocation failed.
extern Fun
Test1:
, , ,,Call ,Fun()
, ,MOVS R0, ♯ 0x00
,
, , ,BNE FunError[Lp002]: relocation failed: value out of range or illegal: 0x306
,
Kind : R_ARM_THM_JUMP8[0x67],
Location: 0x080000c4,
'Test1
' + 0x4,
Module: assembly.o,
Section: 6 (.text),
Offset: 0x4,
Target : 0x080003cf,
'Fun',
Module: source.o,
Section: 8 (.text),
Offset: 0x13If relative branch target is too far away, How can I make the address close enough?
2018-01-16 02:16 AM
I'm not using IAR, review the documentation for a NEAR/FAR version of the branch
Or as suggested load the address into a register and BX Rx
2018-01-16 02:53 AM
I have to branch to the function only if the status flag gets affected, So
load the address into a register and branch will not work for me.
I am trying to get IAR documentation for a NEAR/FAR version of the branch.
Any further help is appreciated.
2018-01-16 03:20 AM
It will work, you will just need to code the logic differently.
2018-01-16 09:53 PM
Thanks for your suggestion, It worked for me.
extern Fun
label1:
Bx Rx
Test1:
;Call Fun()
MOVS Ry, &sharp0x00
LDR Rx, =Fun BNE label1