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