1 #ifndef _PPC_BOOT_ELF_H_
2 #define _PPC_BOOT_ELF_H_
4 /* 32-bit ELF base types. */
5 typedef unsigned int Elf32_Addr
;
6 typedef unsigned short Elf32_Half
;
7 typedef unsigned int Elf32_Off
;
8 typedef signed int Elf32_Sword
;
9 typedef unsigned int Elf32_Word
;
11 /* 64-bit ELF base types. */
12 typedef unsigned long long Elf64_Addr
;
13 typedef unsigned short Elf64_Half
;
14 typedef signed short Elf64_SHalf
;
15 typedef unsigned long long Elf64_Off
;
16 typedef signed int Elf64_Sword
;
17 typedef unsigned int Elf64_Word
;
18 typedef unsigned long long Elf64_Xword
;
19 typedef signed long long Elf64_Sxword
;
21 /* These constants are for the segment types stored in the image headers */
29 #define PT_TLS 7 /* Thread local storage segment */
30 #define PT_LOOS 0x60000000 /* OS-specific */
31 #define PT_HIOS 0x6fffffff /* OS-specific */
32 #define PT_LOPROC 0x70000000
33 #define PT_HIPROC 0x7fffffff
34 #define PT_GNU_EH_FRAME 0x6474e550
36 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
38 /* These constants define the different elf file types */
44 #define ET_LOPROC 0xff00
45 #define ET_HIPROC 0xffff
47 /* These constants define the various ELF target machines */
49 #define EM_PPC 20 /* PowerPC */
50 #define EM_PPC64 21 /* PowerPC64 */
54 typedef struct elf32_hdr
{
55 unsigned char e_ident
[EI_NIDENT
];
59 Elf32_Addr e_entry
; /* Entry point */
64 Elf32_Half e_phentsize
;
66 Elf32_Half e_shentsize
;
68 Elf32_Half e_shstrndx
;
71 typedef struct elf64_hdr
{
72 unsigned char e_ident
[16]; /* ELF "magic number" */
76 Elf64_Addr e_entry
; /* Entry point virtual address */
77 Elf64_Off e_phoff
; /* Program header table file offset */
78 Elf64_Off e_shoff
; /* Section header table file offset */
81 Elf64_Half e_phentsize
;
83 Elf64_Half e_shentsize
;
85 Elf64_Half e_shstrndx
;
88 /* These constants define the permissions on sections in the program
94 typedef struct elf32_phdr
{
105 typedef struct elf64_phdr
{
108 Elf64_Off p_offset
; /* Segment file offset */
109 Elf64_Addr p_vaddr
; /* Segment virtual address */
110 Elf64_Addr p_paddr
; /* Segment physical address */
111 Elf64_Xword p_filesz
; /* Segment size in file */
112 Elf64_Xword p_memsz
; /* Segment size in memory */
113 Elf64_Xword p_align
; /* Segment alignment, file & memory */
116 #define EI_MAG0 0 /* e_ident[] indexes */
126 #define ELFMAG0 0x7f /* EI_MAG */
130 #define ELFMAG "\177ELF"
133 #define ELFCLASSNONE 0 /* EI_CLASS */
136 #define ELFCLASSNUM 3
138 #define ELFDATANONE 0 /* e_ident[EI_DATA] */
139 #define ELFDATA2LSB 1
140 #define ELFDATA2MSB 2
142 #define EV_NONE 0 /* e_version, EI_VERSION */
146 #define ELFOSABI_NONE 0
147 #define ELFOSABI_LINUX 3
150 unsigned long loadsize
;
151 unsigned long memsize
;
152 unsigned long elfoffset
;
154 int parse_elf64(void *hdr
, struct elf_info
*info
);
155 int parse_elf32(void *hdr
, struct elf_info
*info
);
157 #endif /* _PPC_BOOT_ELF_H_ */