Skip to main content
Priyadarshini Solanki
Associate III
January 12, 2018
Question

STM32f070xB generating Error[Lp002]: relocation failed: value out of range or illegal

  • January 12, 2018
  • 6 replies
  • 1907 views
Posted on January 12, 2018 at 10:23

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 #stm32f0
This topic has been closed for replies.

6 replies

Tesla DeLorean
Guru
January 13, 2018
Posted on January 13, 2018 at 17:42

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

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Priyadarshini Solanki
Associate III
January 16, 2018
Posted on January 16, 2018 at 04:42

 ,

 ,

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 Fun

Error[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: 0x13

If relative branch target is too far away, How can I make the address close enough?

Tesla DeLorean
Guru
January 16, 2018
Posted on January 16, 2018 at 10:16

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

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..