2 Copyright (C) 2008 Mathias Gottschlag
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in the
6 Software without restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8 Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #ifndef KE_ELF_H_INCLUDED
23 #define KE_ELF_H_INCLUDED
26 #include "mm/memory.h"
44 #define ELFCLASSNONE 0
53 #define SHT_PROGBITS 1
67 #define SHF_EXECINSTR 4
68 #define SHF_MASKPROC 0xF0000000
76 #define STT_FUNCTION 2
80 #define ELF32_ST_BIND(i) ((i)>>4)
81 #define ELF32_ST_TYPE(i) ((i)&0xF)
95 #define ELF32_R_SYM(i) ((i)>>8)
96 #define ELF32_R_TYPE(i) ((unsigned char)(i))
102 #define R_386_GLOB_DAT 6
103 #define R_386_JUMP_SLOT 7
104 #define R_386_RELATIVE 8
106 typedef struct ElfHeader
108 uint8_t e_ident
[EI_NIDENT
];
117 uint16_t e_phentsize
;
119 uint16_t e_shentsize
;
124 typedef struct ElfSectionHeader
134 uint32_t sh_addralign
;
138 typedef struct ElfSymbol
148 typedef struct ElfRel
154 typedef struct ElfRela
161 typedef struct ElfProgramHeader
173 int keElfMapProgram(MmAddressSpace
*addrspace
, char *program
, uint32_t size
);