Reputation: 2494
From elf.h in c (Linux):
#include <elf.h>
What do the following pointers stand for/do? I tried looking up the documentation but there is nothing written about it. I just saw some source code from other people using it to implement an ELF loader:
Elf32_Ehdr
Elf32_Phdr
Elf32_Shdr
Elf32_Sym
Thanks!
Upvotes: 4
Views: 3948
Reputation: 477464
ELF is a very general format for binary files (e.g. executables, core dumps). You can read its specification as linked from the Wikipedia article.
After you understand what the format looks like, you'll know about the ELF header, program headers, section headers, and much more. The elf.h
header file defines C structures which match those parts of the ELF structure. You can use those to write your own ELF files or load existing ones.
tl;dr: If you don't want to write your own binary executable files or parse core dumps manually, you don't need to know this.
Upvotes: 2
Reputation: 5612
They're just structs with a bunch of information. For example, Elf32_Ehdr is defined as such:
typedef struct {
unsigned char e_ident[EI_NIDENT]; /* ident bytes */
Elf32_Half e_type; /* file type */
Elf32_Half e_machine; /* target machine */
Elf32_Word e_version; /* file version */
Elf32_Addr e_entry; /* start address */
Elf32_Off e_phoff; /* phdr file offset */
Elf32_Off e_shoff; /* shdr file offset */
Elf32_Word e_flags; /* file flags */
Elf32_Half e_ehsize; /* sizeof ehdr */
Elf32_Half e_phentsize; /* sizeof phdr */
Elf32_Half e_phnum; /* number phdrs */
Elf32_Half e_shentsize; /* sizeof shdr */
Elf32_Half e_shnum; /* number shdrs */
Elf32_Half e_shstrndx; /* shdr string index */
} Elf32_Ehdr;
You can find all of them defined here:
http://www.opensource.apple.com/source/dtrace/dtrace-78/sys/elf.h
Upvotes: 2