问题
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