I know that, when using languages that support exceptions, such as C++, additional information must be provided to the runtime environment to describe the call frames that must be unwound during the processing of an exception. This information is contained in special sections of the object files, such as .eh_frame
and .eh_frame_hdr
.
But, what kind of data structures are stored in these sections? I mean, can they be read by using any C struct? Do they have anything to do with the .cfi
statements (such as .cfi_startproc
, .cfi_endproc
, .cfi_offset
, .cfi_def_cfa_offset
, .cfi_personality
and .cfi_lsda
) in GNU assembly code? If they do, what each one of these clauses cause in those sections? What does the .eh_frame_hdr
section have to do with the .eh_frame
one?
I would appreciate explanations using C structs as much as possible. Thank you.
Please, see cfi-directives
It should cover history and theory of most of the sections in question.
About eh_frame, it contains exception unwinding and source language information. Each entry in this section is represented by single CFI (call frame information )
see, eh_frame in linuxfoundation
eh_frame_hdr, is used by c++ runtime code to access the eh_frame. That means, it contains the pointer and binary search table to efficiently retrieve the information from eh_frame.
Now, in case you want to see how you read/write this sections then I suggest take a look at following linker code.
(look for EhFrame.cpp, EhFrameHdr.cpp and EhFrameReader.cpp )
Good luck !!