9

Hello I have a linker script in which i found this code "__exidx_start = .;" which sets label value to the value of location counter ".". This label isn't used anywhere within the same linker script.

There is a similar label defined couple of lines below the first one and it is defined the same way "__exidx_end = .;".

These two labels are boundries of .text and .rodata sections, but i don't know why would anyone define those two if they aren't used in the linker script?

71GA
  • 1,666
  • 5
  • 30
  • 53

2 Answers2

5

These symbols are used internally by call-chain unwinding mechanism in GCC that takes control during exception handling phase. For instance, there is an example in unwind-arm-common.inc:104 where the boundaries of exception-handling table are obtained as pointers to these symbols.

As for .ARM.exidx*-entries that the symbols enclose, they form an exception-handling index table, which is a part of ARM Exception Handling ABI (in sect. 4.4.1) for C++.


Update 20.05.2020

Answering the question by @pixelou:
These sections are not related to debugging, but form a basis of exception unwinding mechanism. Stripping the the *.exidx* sections causes disability to clean the mess up forcing program to abort (fail completly) instead of accurate handling of invalid states on stack. Without that unwinding information a program behaves like if it's built with -fno-exceptions option.

Andrew D.
  • 982
  • 11
  • 25
  • 1
    Does this section also relate to debugging? Is it necessary to have it in order to have a complete stack when debugging? – pixelou Mar 06 '20 at 20:51
  • 1
    No, these entries are related only to the exception handling mechanism (roughly speaking they store the boundaries of try-except blocks and pointers to cleanup routines), and not to debugging. The information on function boundaries and line numbers is stored in `.debug_*` sections. (I've edited the answer, tried to clarify it considering your question.) – Andrew D. May 25 '20 at 22:39
2

They're not used in the linker script, but they are declared as extern variables and used in the gcc library. Take them out, and this is what happens:

.../gcc/config/arm/unwind-arm.c:614: undefined reference to `__exidx_start'
.../gcc/config/arm/unwind-arm.c:614: undefined reference to `__exidx_end'
Patrick
  • 37
  • 1