SprinkleOS/elf.c

30 lines
1.0 KiB
C
Raw Permalink Normal View History

2021-04-09 18:13:55 +09:00
#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));
}
}