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?
You’re looking for libelf.