LLVM(arm-none-eabi目标)正在为基于C的代码生成ARM.exidx部分(?)

时间:2014-02-23 12:17:24

标签: arm clang llvm bare-metal

使用Clang / LLVM(arm-none-eabi target)编译一个简单的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-section当然不起作用,因为这些表条目引用了使用中的函数)

3)为什么arm-gcc不能创建这个部分(好吧,如果你使用新的lib,nano等等它会...但我使用并链接没有std libs)

1 个答案:

答案 0 :(得分:4)

我会回答(2),因为那就是我所做的。添加到链接描述文件:

/DISCARD/ :
{
    *(.ARM.exidx)
}