2006-09-07 14:12:30 +00:00
|
|
|
// Format of an ELF executable file
|
2006-08-29 19:06:37 +00:00
|
|
|
|
2006-09-06 17:53:15 +00:00
|
|
|
#define ELF_MAGIC 0x464C457FU // "\x7FELF" in little endian
|
2006-06-12 15:22:12 +00:00
|
|
|
|
2006-09-07 14:12:30 +00:00
|
|
|
// File header
|
2006-07-17 01:58:13 +00:00
|
|
|
struct elfhdr {
|
2006-09-06 17:04:06 +00:00
|
|
|
uint magic; // must equal ELF_MAGIC
|
|
|
|
uchar elf[12];
|
|
|
|
ushort type;
|
|
|
|
ushort machine;
|
|
|
|
uint version;
|
|
|
|
uint entry;
|
|
|
|
uint phoff;
|
|
|
|
uint shoff;
|
|
|
|
uint flags;
|
|
|
|
ushort ehsize;
|
|
|
|
ushort phentsize;
|
|
|
|
ushort phnum;
|
|
|
|
ushort shentsize;
|
|
|
|
ushort shnum;
|
|
|
|
ushort shstrndx;
|
2006-06-12 15:22:12 +00:00
|
|
|
};
|
|
|
|
|
2006-09-07 14:12:30 +00:00
|
|
|
// Program section header
|
2006-07-17 01:58:13 +00:00
|
|
|
struct proghdr {
|
2006-09-06 17:04:06 +00:00
|
|
|
uint type;
|
|
|
|
uint offset;
|
|
|
|
uint va;
|
|
|
|
uint pa;
|
|
|
|
uint filesz;
|
|
|
|
uint memsz;
|
|
|
|
uint flags;
|
|
|
|
uint align;
|
2006-06-12 15:22:12 +00:00
|
|
|
};
|
|
|
|
|
2006-07-16 15:41:47 +00:00
|
|
|
// Values for Proghdr type
|
2006-09-06 17:53:15 +00:00
|
|
|
#define ELF_PROG_LOAD 1
|
2006-06-12 15:22:12 +00:00
|
|
|
|
2006-07-16 15:41:47 +00:00
|
|
|
// Flag bits for Proghdr flags
|
2006-09-06 17:53:15 +00:00
|
|
|
#define ELF_PROG_FLAG_EXEC 1
|
|
|
|
#define ELF_PROG_FLAG_WRITE 2
|
|
|
|
#define ELF_PROG_FLAG_READ 4
|