【发布时间】:2020-06-09 03:30:36
【问题描述】:
我正在使用C 语言。
我正在用--whole-archive 链接静态库。链接器是arm-none-eabi-ld
例如,为链接器提供以下选项:
--whole-archive abc.a def.a
但我仍然收到链接错误:
(.text.boot+0x94): undefined reference to `xyz'
...
为什么会出现链接错误?
编辑:
带有输出的完整命令:
make[1]: Entering directory '/home/Project1/kern'
arm-none-eabi-ld -o /home/Project1/kernel.elf -T memmap.ld \
hal/arm/arm_startup.o --whole-archive kunit.a hal.a fs.a --no-whole-archive /home/Project1/lib/lpc.a
hal/arm/arm_startup.o: In function `start':
(.text.boot+0x94): undefined reference to `mmu_init'
hal/arm/arm_startup.o: In function `halt':
(.text.boot+0x98): undefined reference to `exec_array'
hal.a(arm_int_handlers.o): In function `interrupt_svc':
(.text+0x18): undefined reference to `mmu_pagetable'
hal.a(arm_int_handlers.o): In function `interrupt_svc':
(.text+0x5c): undefined reference to `_enter_kernel'
...
输出:
readelf -Ws kunit.a hal.a fs.a | egrep ' (mmu_init|exec_array|mmu_pagetable|_enter_kernel)'
是:
9: 00000000 0 NOTYPE GLOBAL DEFAULT UND mmu_pagetable
10: 00000000 0 NOTYPE GLOBAL DEFAULT UND _enter_kernel
12: 00000000 0 NOTYPE GLOBAL DEFAULT UND mmu_pagetable
【问题讨论】:
-
您提供的信息有限,几乎不可能说出问题所在。至少给出导致链接错误的完整构建命令。您用来得出结论的任何输出也会有所帮助。
-
exact 错误信息是什么?你确定是
xyz而不是xyz()吗? -
@EmployedRussian Post 已更新。我相信
xyz是xyz() -
@kaylum 更新后
-
你能添加来自
readelf -Ws kunit.a hal.a fs.a | egrep ' (mmu_init|exec_array|mmu_pagetable|_enter_kernel)'的输出吗(都在单行上)。
标签: c linux linker arm embedded-linux