Accessing .eh_frame data during execution

浪子不回头ぞ 提交于 2019-12-14 00:24:30

问题


I'm trying to access the contents of .eh_frame section of a running program from within it (specifically, the program is Linux kernel 2.6.34.8). The .eh_frame contains useful data used for exception handling and I'd like to use it internally from within kernel code. The section is already being written by gcc (readelf -a vmlinux.o contains .eh_frame), the problem is reading it from the code. I'm pretty sure the elf format docs say that .eh_frame is accessible during code execution.

I've looked into the source of glibc in search of .eh_frame usage and found macros for most CFA instructions in sysdeps/generic/sysdep.h, but not the actual code that loads the .eh_frame data.

Is it required to modify the process of loading the kernel to load the data from the file, or is the .eh_frame info/.eh_frame_hdr section pointer stored somewhere as a macro/assembler name (so it can be extracted into a C variable)?


回答1:


vmlinux.o is not the actual kernel that gets loaded.

The actual kernel image (typically bzImage) is not an ELF file and contains only the data needed for running the kernel.

Furthermore, most of the kernel is not compiled with exception handling information.



来源:https://stackoverflow.com/questions/18091714/accessing-eh-frame-data-during-execution

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