elfload.c revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* ELF Boot loader
* As we have seek, this implementation can be straightforward.
* 2003-07 by SONE Takeshi
*/
#include <etherboot.h>
#include <elf.h>
#include <elf_boot.h>
#include <lib.h>
#include <sys_info.h>
#include <fs.h>
#define DEBUG_THIS DEBUG_ELFBOOT
#include <debug.h>
#if 1
//Use that in Etherboot
#else
// original in filo
#endif
extern char _virt_start[], _end[];
static char *image_name, *image_version;
{
int i, j;
unsigned long prog_start, prog_end;
#if 0
#else
#endif
for (i = 0; i < phnum; i++) {
continue;
goto conflict;
goto conflict;
#if 0
for (j = 0; j < info->n_memranges; j++) {
break;
}
if (j >= info->n_memranges)
goto badseg;
#else
#define LB_MEM_RAM 1
break;
}
goto badseg;
#endif
}
return 1;
return 0;
}
unsigned short *sum_ptr)
{
int i;
int retval = 0;
const char *name;
void *desc;
for (i = 0; i < phnum; i++) {
continue;
printf("Can't read note segment\n");
goto out;
}
}
}
/* Where in the file */
}
}
}
}
out:
if (buf)
return retval;
}
unsigned long checksum_offset)
{
unsigned long bytes;
unsigned int start_time, time;
int i;
int j;
bytes = 0;
start_time = currticks();
#if 0
for (j = 0; j < phnum; j++) {
continue;
debug("0 segment %d addr:%#x file:%#x mem:%#x, phdr%#x\n",
}
#endif
for (i = 0; i < phnum; i++) {
continue;
debug("segment %d addr:%#x file:%#x mem:%#x phdr:%#x ",
debug("loading... ");
printf("Can't read program segment %d\n", i);
return 0;
}
debug("clearing... ");
debug("clearing checksum... ");
}
debug("ok\n");
}
return 1;
}
unsigned short image_sum)
{
unsigned long offset;
int i;
sum = 0;
offset = 0;
for (i = 0; i < phnum; i++) {
continue;
}
printf("Verify FAILED (image:%04x vs computed:%04x)\n",
return 0;
}
return 1;
}
static inline unsigned const padded(unsigned s)
{
return (s + 3) & ~3;
}
{
char *addr;
if (!bhdr)
return NULL;
printf("Boot notes too big\n");
return NULL;
}
do {
if (new_size > 0xffff)
new_size = 0xffff;
}
return bhdr;
}
{
}
{
if (cmdline)
if (!bhdr)
return bhdr;
bhdr->b_checksum = 0;
return bhdr;
}
{
unsigned long phdr_size;
unsigned long checksum_offset;
unsigned short checksum;
int retval = -1;
int image_retval;
image_name = image_version = 0;
goto out;
debug("Can't read ELF header\n");
goto out;
}
debug("Not a bootable ELF image\n");
goto out;
}
printf("Can't read program header\n");
goto out;
}
goto out;
if (image_version)
printf("...\n");
goto out;
if (checksum_offset) {
goto out;
}
printf("Jumping to entry point...\n");
#if 0
console_init();
#endif
retval = 0;
out:
if (phdr)
if (boot_notes)
if (image_name)
if (image_version)
return retval;
}