Manually dump an elf core

I am looking to create an ELF core dump file.

I have a RAM dump from my program, and can also get case information, etc.

With this data, I would like to create an ELF core dump file similar to those generated by the Linux kernel when the program crashes, the goal will be to analyze this core dump using GDB, specially created for my platform.

I was looking for kernel dump specifications or a detailed format, but could not find what I wanted:

  • In which sections do you need the main dump file?
  • How are they organized in an ELF container?
  • How do I switch from a binary RAM dump (+ value registers) to a kernel dump file.

This should be done in C, I thought I could use the libelf library to help me create the file, but I did not find the relevant information about what to put in this file and in what format, so any key, link or tip welcome.

Note. This is not about creating exceptions and doing kernel work for me, I can do it, but I really need to collect RAM and manually register the data in the elf core dump.

Thanks!

+3
source share
1 answer

I am looking to create an ELF core dump file.

Just use the Google elf userpace coredumper , it does just that.

I want to create my main dump, and not implement it directly in my software.

There is no existing program (I know) that can do this. Most likely, you will have to write one from scratch or adapt some other programs.

There are two programs that can write a core dump from user space - the aforementioned coredumper user space and GDB (via the gcore command). I expect the adaptation of the Google coredumper to be much simpler than the adaptation of GDB.

If you decide to write one from scratch, you can still read the Google coredumper source to find out exactly what you should write to the kernel.

+5
source

Source: https://habr.com/ru/post/950725/


All Articles