' __exidx_start' and '__exidx_end' what do they do?
Asked Answered
F

2

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?

Frederik answered 17/3, 2012 at 17:13 Comment(0)
M
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.

Masquerade answered 4/8, 2019 at 19:35 Comment(2)
Does this section also relate to debugging? Is it necessary to have it in order to have a complete stack when debugging?Inspiration
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.)Masquerade
T
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'
Turnbow answered 10/4, 2012 at 4:30 Comment(1)
But.. What do they do?Puffball

© 2022 - 2024 — McMap. All rights reserved.