Changes in kernel/generic/src/lib/elf.c [bdca26a:d91488d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/lib/elf.c
rbdca26a rd91488d 50 50 #include <lib/elf_load.h> 51 51 52 static errno_t load_segment(elf_segment_header_t *, elf_header_t *, as_t *); 52 static const char *error_codes[] = { 53 "no error", 54 "invalid image", 55 "address space error", 56 "incompatible image", 57 "unsupported image type", 58 "irrecoverable error" 59 }; 60 61 static int load_segment(elf_segment_header_t *, elf_header_t *, as_t *); 53 62 54 63 /** ELF loader … … 58 67 * @param flags A combination of ELD_F_* 59 68 * 60 * @return E OK on success69 * @return EE_OK on success 61 70 * 62 71 */ 63 errno_t elf_load(elf_header_t *header, as_t *as)72 unsigned int elf_load(elf_header_t *header, as_t *as) 64 73 { 65 74 /* Identify ELF */ … … 68 77 (header->e_ident[EI_MAG2] != ELFMAG2) || 69 78 (header->e_ident[EI_MAG3] != ELFMAG3)) 70 return E INVAL;79 return EE_INVALID; 71 80 72 81 /* Identify ELF compatibility */ … … 76 85 (header->e_version != EV_CURRENT) || 77 86 (header->e_ident[EI_CLASS] != ELF_CLASS)) 78 return E INVAL;87 return EE_INCOMPATIBLE; 79 88 80 89 if (header->e_phentsize != sizeof(elf_segment_header_t)) 81 return E INVAL;90 return EE_INCOMPATIBLE; 82 91 83 92 /* Check if the object type is supported. */ 84 93 if (header->e_type != ET_EXEC) 85 return E NOTSUP;94 return EE_UNSUPPORTED; 86 95 87 96 /* Check if the ELF image starts on a page boundary */ 88 97 if (ALIGN_UP((uintptr_t) header, PAGE_SIZE) != (uintptr_t) header) 89 return E NOTSUP;98 return EE_UNSUPPORTED; 90 99 91 100 /* Walk through all segment headers and process them. */ … … 99 108 continue; 100 109 101 errno_t rc = load_segment(seghdr, header, as);102 if (rc != E OK)110 int rc = load_segment(seghdr, header, as); 111 if (rc != EE_OK) 103 112 return rc; 104 113 } 105 114 106 return EOK; 115 return EE_OK; 116 } 117 118 /** Print error message according to error code. 119 * 120 * @param rc Return code returned by elf_load(). 121 * 122 * @return NULL terminated description of error. 123 * 124 */ 125 const char *elf_error(unsigned int rc) 126 { 127 assert(rc < sizeof(error_codes) / sizeof(char *)); 128 129 return error_codes[rc]; 107 130 } 108 131 … … 113 136 * @param as Address space into wich the ELF is being loaded. 114 137 * 115 * @return E OK on success, error code otherwise.138 * @return EE_OK on success, error code otherwise. 116 139 * 117 140 */ 118 errno_t load_segment(elf_segment_header_t *entry, elf_header_t *elf, as_t *as)141 int load_segment(elf_segment_header_t *entry, elf_header_t *elf, as_t *as) 119 142 { 120 143 mem_backend_data_t backend_data; … … 123 146 if ((entry->p_offset % entry->p_align) != 124 147 (entry->p_vaddr % entry->p_align)) 125 return E INVAL;148 return EE_INVALID; 126 149 } 127 150 … … 154 177 AS_AREA_ATTR_NONE, &elf_backend, &backend_data, &base, 0); 155 178 if (!area) 156 return E NOMEM;179 return EE_MEMORY; 157 180 158 181 /* … … 161 184 */ 162 185 163 return E OK;186 return EE_OK; 164 187 } 165 188
Note:
See TracChangeset
for help on using the changeset viewer.