changeset 517:c015d2a9971c

elf.h: added elf32 struct definitions Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Mon, 25 Apr 2011 14:43:47 -0400
parents bef9aeea6b0b
children 0c08f7d478d2
files include/binfmt_elf.h
diffstat 1 files changed, 82 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/include/binfmt_elf.h	Mon Apr 25 14:43:41 2011 -0400
+++ b/include/binfmt_elf.h	Mon Apr 25 14:43:47 2011 -0400
@@ -20,14 +20,23 @@
 #define EI_PAD		9
 #define EI_NIDENT	16
 
+#define ELFMAG0		0x7f
+#define ELFMAG1		'E'
+#define ELFMAG2		'L'
+#define ELFMAG3		'F'
+
+#define ELFCLASSNONE	0
 #define ELFCLASS32	1
 #define ELFCLASS64	2
 
+#define ELFDATANONE	0
 #define ELFDATA2LSB	1
 #define ELFDATA2MSB	2
 
 #define EV_CURRENT	1
 
+#define ELFOSABI_NONE	0
+
 #define ET_NONE		0
 #define ET_REL		1
 #define ET_EXEC		2
@@ -38,22 +47,37 @@
 #define ET_LOPROC	0xff00
 #define ET_HIPROC	0xffff
 
-#define SHT_NULL	0
-#define SHT_PROGBITS	1
-#define SHT_SYMTAB	2
-#define SHT_STRTAB	3
-#define SHT_RELA	4
-#define SHT_HASH	5
-#define SHT_DYNAMIC	6
-#define SHT_NOTE	7
-#define SHT_NOBITS	8
-#define SHT_REL		9
-#define SHT_SHLIB	10
-#define SHT_DYNSYM	11
-#define SHT_LOOS	0x60000000
-#define SHT_HIOS	0x6fffffff
-#define SHT_LOPROC	0x70000000
-#define SHT_HIPROC	0x7fffffff
+#define EM_S390		22
+
+#define SHT_NULL		0
+#define SHT_PROGBITS		1
+#define SHT_SYMTAB		2
+#define SHT_STRTAB		3
+#define SHT_RELA		4
+#define SHT_HASH		5
+#define SHT_DYNAMIC		6
+#define SHT_NOTE		7
+#define SHT_NOBITS		8
+#define SHT_REL			9
+#define SHT_SHLIB		10
+#define SHT_DYNSYM		11
+#define SHT_INIT_ARRAY		14
+#define SHT_FINI_ARRAY		15
+#define SHT_PREINI_ARRAY	16
+#define SHT_GROUP		17
+#define SHT_SYMTAB_SHNDX	18
+#define SHT_LOOS		0x60000000
+#define SHT_HIOS		0x6fffffff
+#define SHT_LOPROC		0x70000000
+#define SHT_HIPROC		0x7fffffff
+#define SHT_LOUSER		0x80000000
+#define SHT_HIUSER		0xffffffff
+
+typedef u32 Elf32_Addr;
+typedef u32 Elf32_Off;
+typedef u16 Elf32_Half;
+typedef u32 Elf32_Word;
+typedef s32 Elf32_Sword;
 
 typedef u64 Elf64_Addr;
 typedef u64 Elf64_Off;
@@ -68,6 +92,23 @@
  */
 typedef struct {
 	unsigned char   e_ident[EI_NIDENT];	/* ELF identification */
+	Elf32_Half      e_type;			/* Object file type */
+	Elf32_Half      e_machine;		/* Machine type */
+	Elf32_Word      e_version;		/* Object file version */
+	Elf32_Addr      e_entry;		/* Entry point address */
+	Elf32_Off       e_phoff;		/* Program header offset */
+	Elf32_Off       e_shoff;		/* Section header offset */
+	Elf32_Word      e_flags;		/* Processor-specific flags */
+	Elf32_Half      e_ehsize;		/* ELF header size */
+	Elf32_Half      e_phentsize;		/* Size of program header entry */
+	Elf32_Half      e_phnum;		/* Number of program header entries */
+	Elf32_Half      e_shentsize;		/* Size of section header entries */
+	Elf32_Half      e_shnum;		/* Number of section header entries */
+	Elf32_Half      e_shstrndx;		/* Section name string table index */
+} Elf32_Ehdr;
+
+typedef struct {
+	unsigned char   e_ident[EI_NIDENT];	/* ELF identification */
 	Elf64_Half      e_type;			/* Object file type */
 	Elf64_Half      e_machine;		/* Machine type */
 	Elf64_Word      e_version;		/* Object file version */
@@ -83,10 +124,29 @@
 	Elf64_Half      e_shstrndx;		/* Section name string table index */
 } Elf64_Ehdr;
 
+/* combined header for easy pointer casting */
+typedef union {
+	Elf32_Ehdr s390;
+	Elf64_Ehdr z;
+} Elf_Ehdr;
+
 /*
  * ELF section header
  */
 typedef struct {
+	Elf32_Word	sh_name;		/* Section name */
+	Elf32_Word	sh_type;		/* Section type */
+	Elf32_Word	sh_flags;		/* Section attributes */
+	Elf32_Addr	sh_addr;		/* Virtual address in memory */
+	Elf32_Off	sh_offset;		/* Offset in file */
+	Elf32_Word	sh_size;		/* Size of section */
+	Elf32_Word	sh_link;		/* Link to other section */
+	Elf32_Word	sh_info;		/* Misc information */
+	Elf32_Word	sh_addralign;		/* Address alignment boundary */
+	Elf32_Word	sh_entsize;		/* Size of entries, if section has table */
+} Elf32_Shdr;
+
+typedef struct {
 	Elf64_Word	sh_name;		/* Section name */
 	Elf64_Word	sh_type;		/* Section type */
 	Elf64_Xword	sh_flags;		/* Section attributes */
@@ -99,4 +159,10 @@
 	Elf64_Xword	sh_entsize;		/* Size of entries, if section has table */
 } Elf64_Shdr;
 
+/* combined header for easy pointer casting */
+typedef union {
+	Elf32_Shdr s390;
+	Elf64_Shdr z;
+} Elf_Shdr;
+
 #endif