What do the .eh_frame and .eh_frame_hdr sections store, exactly?

▼魔方 西西 提交于 2019-11-27 11:35:17

问题


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.


回答1:


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 !!



来源:https://stackoverflow.com/questions/14091231/what-do-the-eh-frame-and-eh-frame-hdr-sections-store-exactly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!