Challenge of handmade OS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 lines
1.0 KiB

#include "elf.h"
#include "text.h"
#include <Library/BaseMemoryLib.h>
void run(char *elfdata) {
if (elfdata[EI_CLASS] == ELFCLASS32) {
Elf32_Ehdr elf32header;
CopyMem(&elf32header, elfdata, sizeof(elf32header));
if (!IS_ELF(elf32header)) {
print("This is not ELF file!");
}
if (elf32header.e_ident[EI_OSABI] != ELFOSABI_LINUX &&
elf32header.e_ident[EI_OSABI] != ELFOSABI_NONE) {
print("This ELF file is not valid OS ABI!");
}
if (elf32header.e_machine != EM_386 &&
elf32header.e_machine != EM_486 &&
elf32header.e_machine != EM_X86_64) {
print("This ELF file is not for x86 or x86_64!");
}
if (elf32header.e_type == ET_REL) {
} else if (elf32header.e_type == ET_EXEC) {
} else if (elf32header.e_type == ET_DYN) {
}
} else if (elfdata[EI_CLASS] == ELFCLASS64) {
Elf64_Ehdr elf64header;
CopyMem(&elf64header, elfdata, sizeof(elf64header));
}
}