未定义的地址引用,即使在提及的行

时间:2018-02-22 20:51:17

标签: assembly arm raspberry-pi3 raspbian

我收到以下错误:

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

来自此代码:

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

我在运行rasbian的Raspberry Pi 3上使用ARMv7。任何人都可以帮忙解释为什么或如何解决它?

1 个答案:

答案 0 :(得分:1)

事实证明问题根本不在第91行,问题是不同子程序中的以下行:

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

我将别名寄存器称为标签,将其更改为:

mov r0, addr_r      @ address for GPFSEL{n}

并解决了这个问题! :d