Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ELF file structure in FreeBSD & Linux

In PE (for windows) it is possible to read the headers/sections of that structure by #include<windows.h> and can use the struct PIMAGE_DOS_HEADER to read the dos header in any PE file, for example.

How can i do that for ELF header in FreeBSD/Linux? What kind of preprocessor need to be added at the head of the C/C++ code? and Is there any difference between FreeBSD and Linux in term of the structure of ELF?

like image 391
Ahmed Avatar asked Aug 31 '25 23:08

Ahmed


2 Answers

You're looking for libelf.

like image 79
Ignacio Vazquez-Abrams Avatar answered Sep 03 '25 13:09

Ignacio Vazquez-Abrams


Look at the sources of readelf. Or just google. For example, this http://www.scribd.com/doc/7027807/ELF-Format looks promising.

If you just want existing code, try http://www.linux.com/learn/docs/man/2838-elf5.

like image 44
Gilad Naor Avatar answered Sep 03 '25 12:09

Gilad Naor