开发者

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开发者_StackOverflow 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.


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.


Here are some pointers which should help you out:

  • Oracle article LibElf and GElf - A Library to Manipulate ELf Files

  • GElf

  • Libelf homepage


I can't vouch for FreeBSD, but on Linux there are a lot of details in the elf(5) manpage:

NAME
   elf - format of Executable and Linking Format (ELF) files

SYNOPSIS
   #include <elf.h>

DESCRIPTION
   The header file <elf.h> defines the format of ELF executable
   binary files.  Amongst these files are normal executable
   files, relocatable object files, core files and shared
   libraries.
...

When I needed to understand ELF, I found nothing more useful than the MuppetLabs Tiny Executable walk-through. I'm sure many of the techniques are out-of-date (and were never a good idea), but they explained things very well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜