Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

' __exidx_start' and '__exidx_end' what do they do?

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?

like image 203
71GA Avatar asked Mar 17 '12 17:03

71GA


2 Answers

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.

like image 149
Andrew D. Avatar answered Oct 03 '22 00:10

Andrew D.


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'
like image 36
Patrick Avatar answered Oct 03 '22 00:10

Patrick