18 |
along with this program; if not, write to the Free Software |
along with this program; if not, write to the Free Software |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ |
20 |
|
|
21 |
|
#if HAVE_CONFIG_H |
22 |
|
#include <config.h> |
23 |
|
#endif |
24 |
|
|
25 |
#include <string.h> |
#include <string.h> |
26 |
|
|
27 |
#include "loader.h" |
#include "loader.h" |
186 |
if (!elf->e_phoff) |
if (!elf->e_phoff) |
187 |
panic ("%s has no valid program header offset", name); |
panic ("%s has no valid program header offset", name); |
188 |
|
|
189 |
#ifdef i386 |
/* FIXME: Some architectures support both word sizes. */ |
190 |
if (elf->e_ident[EI_CLASS] != ELFCLASS32 |
if (!((elf->e_ident[EI_CLASS] == ELFCLASS32 |
191 |
|| elf->e_ident[EI_DATA] != ELFDATA2LSB |
&& L4_WORDSIZE == 32) |
192 |
|| elf->e_machine != EM_386) |
|| (elf->e_ident[EI_CLASS] == ELFCLASS64 |
193 |
panic ("%s is not for this architecture", name); |
&& L4_WORDSIZE == 64))) |
194 |
|
panic ("%s has invalid word size", name); |
195 |
|
|
196 |
|
if (!((elf->e_ident[EI_DATA] == ELFDATA2LSB |
197 |
|
&& L4_BYTE_ORDER == L4_LITTLE_ENDIAN) |
198 |
|
|| (elf->e_ident[EI_DATA] == ELFDATA2MSB |
199 |
|
&& L4_BYTE_ORDER == L4_BIG_ENDIAN))) |
200 |
|
panic ("%s has invalid byte order", name); |
201 |
|
|
202 |
|
#if i386 |
203 |
|
# define elf_machine EM_386 |
204 |
|
#elif PPC |
205 |
|
# define elf_machine EM_PPC |
206 |
#else |
#else |
207 |
#error Not ported to this architecture! |
# error Not ported to this architecture! |
208 |
#endif |
#endif |
209 |
|
|
210 |
|
if (elf->e_machine != elf_machine) |
211 |
|
panic ("%s is not for this architecture", name); |
212 |
|
|
213 |
for (i = 0; i < elf->e_phnum; i++) |
for (i = 0; i < elf->e_phnum; i++) |
214 |
{ |
{ |
215 |
Elf32_Phdr *ph = (Elf32_Phdr *) (start + elf->e_phoff |
Elf32_Phdr *ph = (Elf32_Phdr *) (start + elf->e_phoff |