Changeset 270 for trunk/kernel/libk
- Timestamp:
- Jul 21, 2017, 3:56:36 PM (7 years ago)
- Location:
- trunk/kernel/libk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/elf.c
r265 r270 40 40 static bool_t elf_isValidHeader(Elf_Ehdr *header) 41 41 { 42 if((header->e_ident[EI_CLASS] == ELFCLASS 32)42 if((header->e_ident[EI_CLASS] == ELFCLASS) 43 43 && (header->e_ident[EI_DATA] == ELFDATA2LSB) 44 44 && (header->e_ident[EI_VERSION] == EV_CURRENT) 45 /* 45 46 && (header->e_ident[EI_OSABI] == ELFOSABI_NONE) 47 */ 46 48 && ((header->e_machine == EM_MIPS) || 47 49 (header->e_machine == EM_MIPS_RS3_LE) || … … 50 52 return true; 51 53 52 if( header->e_ident[EI_CLASS] != ELFCLASS 32)53 printk("\n[ERROR] in %s : Elf is not 32 -Binary\n", __FUNCTION__ );54 if( header->e_ident[EI_CLASS] != ELFCLASS ) 55 printk("\n[ERROR] in %s : Elf is not 32/64-Binary\n", __FUNCTION__ ); 54 56 55 57 if( header->e_ident[EI_DATA] != ELFDATA2LSB ) … … 58 60 if( header->e_ident[EI_VERSION] != EV_CURRENT ) 59 61 printk("\n[ERROR] in %s : Elf is not in Current Version\n", __FUNCTION__); 60 62 /* 61 63 if( header->e_ident[EI_OSABI] != ELFOSABI_NONE ) 62 64 printk("\n[ERROR] in %s : Unexpected Elf ABI, need UNIX System V ABI\n", __FUNCTION__ ); 63 64 if( (header->e_machine == EM_MIPS) ||65 (header->e_machine == EM_MIPS_RS3_LE) ||66 (header->e_machine == EM_X86_64) )65 */ 66 if( (header->e_machine != EM_MIPS) && 67 (header->e_machine != EM_MIPS_RS3_LE) && 68 (header->e_machine != EM_X86_64) ) 67 69 printk("\n[ERROR] in %s : unexpected core / accept only MIPS or x86_64\n", __FUNCTION__ ); 68 70 69 if( header->e_type == ET_EXEC )71 if( header->e_type != ET_EXEC ) 70 72 printk("\n[ERROR] in %s : Elf is not executable binary\n", __FUNCTION__ ); 71 73 -
trunk/kernel/libk/elf.h
r227 r270 104 104 #define ELFCLASSNONE 0 /* Invalid class */ 105 105 #define ELFCLASS32 1 /* 32-bit objects */ 106 #define ELFCLASS64 2 /* 64-bit objects */ 107 106 108 #define ELFCLASSNUM 3 107 109 … … 209 211 #define Elf_Ehdr Elf32_Ehdr 210 212 #define Elf_Phdr Elf32_Phdr 213 #define ELFCLASS ELFCLASS32 211 214 #elif defined (HAL_64BIT) 212 215 #define Elf_Half Elf64_Half … … 217 220 #define Elf_Ehdr Elf64_Ehdr 218 221 #define Elf_Phdr Elf64_Phdr 222 #define ELFCLASS ELFCLASS64 219 223 #else 220 224 #error "Must define HAL_64BIT/HAL_32BIT"
Note: See TracChangeset
for help on using the changeset viewer.