[llvm-dev] clang is not emitting .ARM.extab section?

Peter Smith via llvm-dev llvm-dev at lists.llvm.org
Thu Oct 4 01:52:02 PDT 2018


On Thu, 4 Oct 2018 at 09:08, kamlesh kumar via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
>
> Hi Devs,
>
> For the below sample :
>
> $cat test.cpp
> int foo();
> int main(){
> int f=foo();
> return 0;
> }
>
> We  compiled with clang(8.1) like
>
> $clang -fno-builtin --target=arm-eabi  -mabi=aapcs -mlittle-endian -mfpu=vfpv3 -mfloat-abi=hard -mcpu=cortex-a9 -O0 test.cpp -c
>
> $readelfarm -S test.o
> Section Headers:
>   [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
>   [ 0]                   NULL            00000000 000000 000000 00      0   0  0
>   [ 1] .strtab           STRTAB          00000000 0001e8 000085 00      0   0  1
>   [ 2] .text             PROGBITS        00000000 000034 00002c 00  AX  0   0  4
>   [ 3] .rel.text         REL             00000000 0001d0 000008 08      9   2  4
>   [ 4] .ARM.exidx        ARM_EXIDX       00000000 000060 000008 00  AL  2   0  4
>   [ 5] .rel.ARM.exidx    REL             00000000 0001d8 000010 08      9   4  4
>   [ 6] .comment          PROGBITS        00000000 000068 0000ac 01  MS  0   0  1
>   [ 7] .note.GNU-stack   PROGBITS        00000000 000114 000000 00      0   0  1
>   [ 8] .ARM.attributes   ARM_ATTRIBUTES  00000000 000114 000049 00      0   0  1
>   [ 9] .symtab           SYMTAB          00000000 000160 000070 10      1   4  4
>
> And compiled by gcc:
> $gcc  -fno-builtin -mabi=aapcs -mlittle-endian -mfpu=vfpv3 -mfloat-abi=hard -mcpu=cortex-a9 -O0 test.cpp -c
>
> $readelf -S test.o
> Section Headers:
>   [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
>   [ 0]                   NULL            00000000 000000 000000 00      0   0  0
>   [ 1] .text             PROGBITS        00000000 000034 000028 00  AX  0   0  4
>   [ 2] .rel.text         REL             00000000 00025c 000008 08   I 12   1  4
>   [ 3] .data             PROGBITS        00000000 00005c 000000 00  WA  0   0  1
>   [ 4] .bss              NOBITS          00000000 00005c 000000 00  WA  0   0  1
>   [ 5] .ARM.extab        PROGBITS        00000000 00005c 00000c 00   A  0   0  4
>   [ 6] .ARM.exidx        ARM_EXIDX       00000000 000068 000008 00  AL  1   0  4
>   [ 7] .rel.ARM.exidx    REL             00000000 000264 000018 08   I 12   6  4
>   [ 8] .comment          PROGBITS        00000000 000070 000012 01  MS  0   0  1
>   [ 9] .note.GNU-stack   PROGBITS        00000000 000082 000000 00      0   0  1
>   [10] .ARM.attributes   ARM_ATTRIBUTES  00000000 000082 000033 00      0   0  1
>   [11] .shstrtab         STRTAB          00000000 0000b5 000073 00      0   0  1
>   [12] .symtab           SYMTAB          00000000 000128 000100 10     13  13  4
>   [13] .strtab           STRTAB          00000000 000228 000034 00      0   0  1
>
> From the above sections you see that .ARM.extab  and  .ARM.exidx sections are emitted by gcc  and in-case of clang only  the .ARM.exidx  section is present.
>
> We tried with -funwind-tables option too for clang with no luck and  we are going with ARM EHABI  to understand these sections better, meanwhile  .
>
> Is that  the clang semantics(not emitting the .ARM.extab section )  is expected ?
>

Hello Kamlesh,

To quote from Section 6 of the EHABI  Exception handling for the ARM
architecture
)
"If the entire handling table entry fits in 4 bytes, the entry can be
emitted inline in the index table instead (as described in ยง5). Bit 31
then discriminates between such an inline entry and a prel31 offset to
an entry in the handling table (for which bit 31 is 0)."

In this particular case Clang has produced all the unwind instructions
in an inline .ARM.exidx table, GCC has not. As long as the unwind
instructions match the generated code it doesn't really matter.

If I make your example a little bit more complex then clang will
generate a .ARM.extab section

Hope that answers your question

Peter

int foo();
int bar();
int main(){
    try {
        int f=foo();
    }
    catch (...) {
        bar();
    }
return 0;
}

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .strtab           STRTAB          00000000 0003ac 000153 00      0   0  1
  [ 2] .text             PROGBITS        00000000 000034 000090 00  AX  0   0  4
  [ 3] .rel.text         REL             00000000 00033c 000038 08     17   2  4
  [ 4] .ARM.extab        PROGBITS        00000000 0000c4 00002c 00   A  0   0  4
  [ 5] .rel.ARM.extab    REL             00000000 000374 000008 08     17   4  4
  [ 6] .ARM.exidx        ARM_EXIDX       00000000 0000f0 000008 00  AL  2   0  4
  [ 7] .rel.ARM.exidx    REL             00000000 00037c 000010 08     17   6  4
  [ 8] .group            GROUP           00000000 000218 000014 04     17  12  4
  [ 9] .text.__clang_cal PROGBITS        00000000 0000f8 00001c 00 AXG  0   0  4
  [10] .rel.text.__clang REL             00000000 00038c 000010 08   G 17   9  4
  [11] .ARM.exidx.text._ ARM_EXIDX       00000000 000114 000008 00 ALG  9   0  4
  [12] .rel.ARM.exidx.te REL             00000000 00039c 000008 08   G 17  11  4
  [13] .comment          PROGBITS        00000000 00011c 0000b4 01  MS  0   0  1
  [14] .note.GNU-stack   PROGBITS        00000000 0001d0 000000 00      0   0  1
  [15] .ARM.attributes   ARM_ATTRIBUTES  00000000 0001d0 000047 00      0   0  1
  [16] .llvm_addrsig     LOOS+fff4c03    00000000 0003a4 000008 00   E 17   0  1
  [17] .symtab           SYMTAB          00000000 00022c 000110 10      1   8  4


> ~Kamlesh
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list