What do I do with DW_OP_call_frame_cfa

*爱你&永不变心* 提交于 2019-12-12 08:56:24

问题


I'm trying to calculate the locations of local variables inside a running program using libdwarf. I used to be able to do this by executing DW_OP_fbreg which would ultimately map to a register that would the frame base for that function. In the newer dwarf standard the frame base is DW_OP_call_frame_cfa. I can't seem to find any information that tells me how to execute DW_OP_call_frame_cfa and come back with a frame base location. There's a lot of references to a CFA table and who restores what registers but I don't know how to get at that information and how to apply it. Can someone fill in the gaps?


回答1:


DW_OP_call_frame_cfa means that you have to use the call frame information to compute the CFA; then push this on the expression stack.

See section 6.4 ("Call Frame Information") of the DWARF 4 standard for an explanation of this. Essentially you must now read the .debug_frame section and decode it according to the rules described in 6.4. This amounts to writing another interpreter for another little bytecode language; and possibly reusing the DWARF expression interpreter as well.

This opcode is basically a space optimization in DWARF. Compilers were already emitting the call frame information, and this opcode lets them reuse it to compute variable locations as well.



来源:https://stackoverflow.com/questions/33071545/what-do-i-do-with-dw-op-call-frame-cfa

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