使用 Clang/LLVM(arm-none-eabi 目标)编译简单的 HelloWorld.c 会产生重定位部分“.rel.ARM.exidx”,但使用 arm-gcc 不会。这些 LLVM 生成的展开表条目被正确标记为 canunwind。但是,为什么它们根本不需要它们,因为它们是不需要的,并且当您获得 AXF 中每个 C 函数的条目时只会导致膨胀?
readelf edxidx from HelloWorld.o
Relocation section '.rel.ARM.exidx' at offset 0x580 contains 2 entries:
Offset Info Type Sym.Value Sym. Name
00000000 00000b2a R_ARM_PREL31 00000000 .text
00000008 00000b2a R_ARM_PREL31 00000000 .text
Unwind table index '.ARM.exidx' at offset 0xcc contains 2 entries:
0x0 <print_uart0>: 0x1 [cantunwind]
0x54 <c_entry>: 0x1 [cantunwind]
在测试 Clang 默认值时:如果我将“-funwind-tables”传递给 Clang 以强制展开 C 函数,如果我编写 .cpp 函数并且“-fno-unwind-tables”结果相同,我会得到我所期望的结果如上。
Relocation section '.rel.ARM.exidx' at offset 0x5a4 contains 4 entries:
Offset Info Type Sym.Value Sym. Name
00000000 00000b2a R_ARM_PREL31 00000000 .text
00000000 00001600 R_ARM_NONE 00000000 __aeabi_unwind_cpp_pr0
00000008 00000b2a R_ARM_PREL31 00000000 .text
00000008 00001600 R_ARM_NONE 00000000 __aeabi_unwind_cpp_pr0
Unwind table index '.ARM.exidx' at offset 0xcc contains 2 entries:
0x0 <print_uart0>: 0x8001b0b0
Compact model index: 0
0x01 vsp = vsp + 8
0xb0 finish
0xb0 finish
0x54 <c_entry>: 0x809b8480
Compact model index: 0
0x9b vsp = r11
0x84 0x80 pop {r11, r14}
1) 仅使用 C 函数时,无论如何都要关闭 .ARM.exidx 部分,因为它们总是被标记为“cantunwind”。
2)无论如何在链接期间剥离这一部分?(gc 部分当然不起作用,因为这些表条目引用了正在使用的函数)
3) 为什么 arm-gcc 不创建此部分(嗯,如果您使用新的 lib、nano 等...但我使用和链接没有 std 库)