53 lines
1.3 KiB
C
53 lines
1.3 KiB
C
//---
|
|
// fxBoot:hypervisor:loader:entry - ELF Loader entry
|
|
//---
|
|
#include "fxBoot/hypervisor.h"
|
|
#include "fxBoot/terminal.h"
|
|
#include "fxBoot/fs/smemfs.h"
|
|
#include "fxBoot/elf.h"
|
|
|
|
/* internal header */
|
|
#include "../src/hypervisor/internal/elf.h"
|
|
|
|
/* loader_entry(): Load a ELF programm (PIE) */
|
|
int hypervisor_elf_loader(struct hworld *world, struct smemfs_inode *inode)
|
|
{
|
|
Elf32_Ehdr header;
|
|
int err;
|
|
|
|
if (world == NULL)
|
|
return (-1);
|
|
|
|
/* save private information */
|
|
terminal_write("hypervisor:\n");
|
|
terminal_write("- load the inode \"%s\"\n", inode->name);
|
|
world->private.inode = inode;
|
|
|
|
/* Try to get the ELF header information */
|
|
terminal_write("- check header information\n");
|
|
err = hypervisor_elf_loader_header_get(inode, &header);
|
|
if (err != 0)
|
|
return (-2);
|
|
|
|
/* Get / Check program validity */
|
|
terminal_write("- load image\n");
|
|
err = hypervisor_elf_loader_image_load(world, inode, &header);
|
|
if (err != 0)
|
|
return (-3);
|
|
|
|
/* Relocalise sections / symbols */
|
|
terminal_write("- relocalise static symbols\n");
|
|
err = hypervisor_elf_loader_reloc_sym(world, inode, &header);
|
|
if (err != 0)
|
|
return (-4);
|
|
|
|
#if 0
|
|
/* Relocalise Gint symbols */
|
|
terminal_write("- relocalise shared symbols\n");
|
|
err = hypervisor_elf_loader_reloc_gint(world, inode, &header);
|
|
if (err != 0)
|
|
return (-5);
|
|
#endif
|
|
return (0);
|
|
}
|