Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
597 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...