1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _PPC_BOOT_ELF_H_
3 #define _PPC_BOOT_ELF_H_
5 /* 32-bit ELF base types. */
6 typedef unsigned int Elf32_Addr;
7 typedef unsigned short Elf32_Half;
8 typedef unsigned int Elf32_Off;
9 typedef signed int Elf32_Sword;
10 typedef unsigned int Elf32_Word;
12 /* 64-bit ELF base types. */
13 typedef unsigned long long Elf64_Addr;
14 typedef unsigned short Elf64_Half;
15 typedef signed short Elf64_SHalf;
16 typedef unsigned long long Elf64_Off;
17 typedef signed int Elf64_Sword;
18 typedef unsigned int Elf64_Word;
19 typedef unsigned long long Elf64_Xword;
20 typedef signed long long Elf64_Sxword;
22 /* These constants are for the segment types stored in the image headers */
30 #define PT_TLS 7 /* Thread local storage segment */
31 #define PT_LOOS 0x60000000 /* OS-specific */
32 #define PT_HIOS 0x6fffffff /* OS-specific */
33 #define PT_LOPROC 0x70000000
34 #define PT_HIPROC 0x7fffffff
35 #define PT_GNU_EH_FRAME 0x6474e550
37 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
39 /* These constants define the different elf file types */
45 #define ET_LOPROC 0xff00
46 #define ET_HIPROC 0xffff
48 /* These constants define the various ELF target machines */
50 #define EM_PPC 20 /* PowerPC */
51 #define EM_PPC64 21 /* PowerPC64 */
55 typedef struct elf32_hdr {
56 unsigned char e_ident[EI_NIDENT];
60 Elf32_Addr e_entry; /* Entry point */
65 Elf32_Half e_phentsize;
67 Elf32_Half e_shentsize;
69 Elf32_Half e_shstrndx;
72 typedef struct elf64_hdr {
73 unsigned char e_ident[16]; /* ELF "magic number" */
77 Elf64_Addr e_entry; /* Entry point virtual address */
78 Elf64_Off e_phoff; /* Program header table file offset */
79 Elf64_Off e_shoff; /* Section header table file offset */
82 Elf64_Half e_phentsize;
84 Elf64_Half e_shentsize;
86 Elf64_Half e_shstrndx;
89 /* These constants define the permissions on sections in the program
95 typedef struct elf32_phdr {
106 typedef struct elf64_phdr {
109 Elf64_Off p_offset; /* Segment file offset */
110 Elf64_Addr p_vaddr; /* Segment virtual address */
111 Elf64_Addr p_paddr; /* Segment physical address */
112 Elf64_Xword p_filesz; /* Segment size in file */
113 Elf64_Xword p_memsz; /* Segment size in memory */
114 Elf64_Xword p_align; /* Segment alignment, file & memory */
117 #define EI_MAG0 0 /* e_ident[] indexes */
127 #define ELFMAG0 0x7f /* EI_MAG */
131 #define ELFMAG "\177ELF"
134 #define ELFCLASSNONE 0 /* EI_CLASS */
137 #define ELFCLASSNUM 3
139 #define ELFDATANONE 0 /* e_ident[EI_DATA] */
140 #define ELFDATA2LSB 1
141 #define ELFDATA2MSB 2
143 #define EV_NONE 0 /* e_version, EI_VERSION */
147 #define ELFOSABI_NONE 0
148 #define ELFOSABI_LINUX 3
151 unsigned long loadsize;
152 unsigned long memsize;
153 unsigned long elfoffset;
155 int parse_elf64(void *hdr, struct elf_info *info);
156 int parse_elf32(void *hdr, struct elf_info *info);
158 #endif /* _PPC_BOOT_ELF_H_ */