Dal
Dal

Reputation: 117

undefined reference to address even though there's no reference to it on the line mentioned

I'm getting the following error:

build/main.o:source/main.s:91: undefined reference to `addr_r'
collect2: error: ld returned 1 exit status

from this code:

82] @ Register Aliases for subroutines
83] addr_r  .req    r4
84]
85] write_latch:
86]     mov     fp, sp              @ save position in calling code
87]     PUSH    {r4-r10}            @ preserve variable registers
89]         @ do stuff here later
90]     POP     {r4-r10}            @ restore variable registers
91]     bx      lr                  @ return to position in calling code

Im using ARMv7 on a Raspberry Pi 3 running rasbian. Can anyone help explain why or how to fix it?

Upvotes: 0

Views: 1064

Answers (1)

Dal
Dal

Reputation: 117

It turns out the problem wasn't on line 91 at all, the problem was the following line in a different subroutine:

ldr r0, =addr_r     @ address for GPFSEL{n}

I was refering to an aliased register as a label, changed it to:

mov r0, addr_r      @ address for GPFSEL{n}

and that fixed the problem! :D

Upvotes: 1

Related Questions