When is .ARM.exidx is used

后端 未结 3 604
陌清茗
陌清茗 2020-12-11 15:27

I am working on Contiki 2.7 with the mbxxx target. While building my code the linker complained about an overlap of .ARM.exidx and .data sections. After som

相关标签:
3条回答
  • 2020-12-11 15:57

    .ARM.exidx is the section containing information for unwinding the stack. If your C program has functions that print out a stack backtrace, the functions will likely depend on this section being present.

    Maybe look for a -funwind-tables or -fexceptions flag in your compiler options.

    0 讨论(0)
  • 2020-12-11 16:00

    This feature is used in 'C'. The ARM APCS uses only a frame pointer to restore a stack. The newer AAPCS uses tables on occasion. Stack unwinding, signal handlers and other asynchronous 'C' features use these mechanism. For a bare metal embedded device it can be used to trace a stack. For instance, Linux's unwind.c uses both exidx and extab sections to do a stack trace.

    Briefly the exidx is a sorted table of routine start addresses and an extab table index. A binary search through the exidx will find the corresponding extab entry. The extab entry has details about the stack in this routineNote1. It gives details about what the routine is storing on the stack.

    if the commented out portions, (the r variable assignment) is uncommented, the .ARM.exidx thingy appears, otherwise it doesn't! Now can this be explained???

    When you have the statement *r++ = (comp)tmp;, the compiler can not hold all the variables in registers and needs to use the stack (or at least fp). This causes it to emit and exidx and extab data.


    There are some solutions. It is fine to discard both exidx and extab if you don't need stack tracing or asynchronous functionality. Simpler stack unwinding can be done with gnu tools/gcc using -mapcs-frame; then fp will always be used to store the previous stack frame (which stores its callers fp, etc). The actual tables are not that big and the routines to unwind are fairly simple. It maybe <3% overhead to have the tables which don't pollute the normal program path or use a register like -mapcs-frame. Desirable on Cortex-A cpus with cache and usually more memory.

    Reference: ATPCS Link and frame pointer explained
                      Structure of ARM extab

    Note1: This is after the prologue makes an adjustment to the stack.
    Note2: The ex is for exception, but it is not solely for C++ exceptions.

    0 讨论(0)
  • 2020-12-11 16:04

    Adding to tangrs' response, if you gcc -v, you can dump the default options used during compilation.

    All options (implicit & explicit) options of GCC are passed to cc1 program of GCC.

    0 讨论(0)
提交回复
热议问题