LibXenon
Bare-metal Xbox 360 homebrew library
Loading...
Searching...
No Matches
elf_abi.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 1995, 1996, 2001, 2002
3 * Erik Theisen. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <stdint.h>
29
30#ifndef _ELF_ABI_H
31#define _ELF_ABI_H
32
33typedef uint32_t Elf32_Addr; /* Unsigned program address */
34typedef uint32_t Elf32_Off; /* Unsigned file offset */
35typedef uint32_t Elf32_Word; /* Unsigned large integer */
36typedef uint16_t Elf32_Half; /* Unsigned medium integer */
37
38#define EI_MAG0 0 /* file ID */
39#define EI_MAG1 1 /* file ID */
40#define EI_MAG2 2 /* file ID */
41#define EI_MAG3 3 /* file ID */
42#define EI_CLASS 4 /* ELF type */
43#define EI_NIDENT 16 /* Size of e_ident[] */
44
45#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
46#define ELFMAG1 'E' /* e_ident[EI_MAG1] */
47#define ELFMAG2 'L' /* e_ident[EI_MAG2] */
48#define ELFMAG3 'F' /* e_ident[EI_MAG3] */
49
50#define ELFCLASSNONE 0
51#define ELFCLASS32 1
52#define ELFCLASS64 2
53
54#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
55 (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
56 (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
57 (ehdr).e_ident[EI_MAG3] == ELFMAG3)
58
59typedef struct elfhdr{
60 unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
61 Elf32_Half e_type; /* object file type */
62 Elf32_Half e_machine; /* machine */
63 Elf32_Word e_version; /* object file version */
64 Elf32_Addr e_entry; /* virtual entry point */
65 Elf32_Off e_phoff; /* program header table offset */
66 Elf32_Off e_shoff; /* section header table offset */
67 Elf32_Word e_flags; /* processor-specific flags */
68 Elf32_Half e_ehsize; /* ELF header size */
69 Elf32_Half e_phentsize; /* program header entry size */
70 Elf32_Half e_phnum; /* number of program header entries */
71 Elf32_Half e_shentsize; /* section header entry size */
72 Elf32_Half e_shnum; /* number of section header entries */
73 Elf32_Half e_shstrndx; /* section header table's "section
74 header string table" entry offset */
76
77#define ET_EXEC 2 /* executable file */
78
79typedef struct {
80 Elf32_Word sh_name; /* name - index into section header
81 string table section */
82 Elf32_Word sh_type; /* type */
83 Elf32_Word sh_flags; /* flags */
84 Elf32_Addr sh_addr; /* address */
85 Elf32_Off sh_offset; /* file offset */
86 Elf32_Word sh_size; /* section size */
87 Elf32_Word sh_link; /* section header table index link */
88 Elf32_Word sh_info; /* extra information */
89 Elf32_Word sh_addralign; /* address alignment */
90 Elf32_Word sh_entsize; /* section entry size */
92
93typedef struct {
102} Elf32_Phdr;
103
104#define SHT_NULL 0
105#define SHT_PROGBITS 1
106#define SHT_SYMTAB 2
107#define SHT_STRTAB 3 /* string table section */
108#define SHT_RELA 4
109#define SHT_HASH 5
110#define SHT_DYNAMIC 6
111#define SHT_NOTE 7
112#define SHT_NOBITS 8 /* no space section */
113#define SHT_REL 9
114#define SHT_SHLIB 10
115#define SHT_DYNSYM 11
116
117#define PT_LOAD 1
118#define PT_DYNAMIC 2
119#define PT_NOTE 4
120
121#define SHF_ALLOC 0x2 /* occupies memory */
122
123#endif /* _ELF_H */
uint16_t Elf32_Half
Definition: elf_abi.h:36
uint32_t Elf32_Addr
Definition: elf_abi.h:33
struct elfhdr Elf32_Ehdr
uint32_t Elf32_Off
Definition: elf_abi.h:34
#define EI_NIDENT
Definition: elf_abi.h:43
uint32_t Elf32_Word
Definition: elf_abi.h:35
u32 uint32_t
Definition: libfdt_env.h:11
u16 uint16_t
Definition: libfdt_env.h:10
Elf32_Word p_paddr
Definition: elf_abi.h:97
Elf32_Word p_vaddr
Definition: elf_abi.h:96
Elf32_Word p_flags
Definition: elf_abi.h:100
Elf32_Word p_type
Definition: elf_abi.h:94
Elf32_Word p_filesz
Definition: elf_abi.h:98
Elf32_Word p_offset
Definition: elf_abi.h:95
Elf32_Word p_memsz
Definition: elf_abi.h:99
Elf32_Word p_align
Definition: elf_abi.h:101
Elf32_Word sh_entsize
Definition: elf_abi.h:90
Elf32_Word sh_flags
Definition: elf_abi.h:83
Elf32_Word sh_addralign
Definition: elf_abi.h:89
Elf32_Off sh_offset
Definition: elf_abi.h:85
Elf32_Word sh_name
Definition: elf_abi.h:80
Elf32_Addr sh_addr
Definition: elf_abi.h:84
Elf32_Word sh_size
Definition: elf_abi.h:86
Elf32_Word sh_type
Definition: elf_abi.h:82
Elf32_Word sh_link
Definition: elf_abi.h:87
Elf32_Word sh_info
Definition: elf_abi.h:88
Definition: elf_abi.h:59
Elf32_Off e_phoff
Definition: elf_abi.h:65
Elf32_Half e_type
Definition: elf_abi.h:61
Elf32_Half e_phentsize
Definition: elf_abi.h:69
Elf32_Off e_shoff
Definition: elf_abi.h:66
Elf32_Half e_shentsize
Definition: elf_abi.h:71
Elf32_Half e_shstrndx
Definition: elf_abi.h:73
Elf32_Word e_flags
Definition: elf_abi.h:67
Elf32_Word e_version
Definition: elf_abi.h:63
Elf32_Addr e_entry
Definition: elf_abi.h:64
Elf32_Half e_phnum
Definition: elf_abi.h:70
Elf32_Half e_ehsize
Definition: elf_abi.h:68
Elf32_Half e_shnum
Definition: elf_abi.h:72
unsigned char e_ident[EI_NIDENT]
Definition: elf_abi.h:60
Elf32_Half e_machine
Definition: elf_abi.h:62