Linker --whole-archive选项

问题描述 投票:0回答:1

我正在使用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

c linux linker arm embedded-linux
1个回答
0
投票

为什么发生链接错误?

由于缺少符号:mmu_initmmu_pagetable等在您希望在其中定义的库中未定义[[实际上。

这就是UND输出中的readelf的意思。

现在,为了告诉您

为什么

这些符号未定义,我们需要知道您希望在其中定义它们的库的来源,这些库的构建方式,以及可能有很多其他详情。请使用all您可以想到的细节问一个单独的问题。
© www.soinside.com 2019 - 2024. All rights reserved.