Changeset 8565a42 in mainline for kernel/generic/src/lib/elf.c
- Timestamp:
- 2018-03-02T20:34:50Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1a81f69, d5e5fd1
- Parents:
- 3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
- git-committer:
- GitHub <noreply@…> (2018-03-02 20:34:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/lib/elf.c
r3061bc1 r8565a42 80 80 (header->e_ident[EI_MAG3] != ELFMAG3)) 81 81 return EE_INVALID; 82 82 83 83 /* Identify ELF compatibility */ 84 84 if ((header->e_ident[EI_DATA] != ELF_DATA_ENCODING) || … … 88 88 (header->e_ident[EI_CLASS] != ELF_CLASS)) 89 89 return EE_INCOMPATIBLE; 90 90 91 91 if (header->e_phentsize != sizeof(elf_segment_header_t)) 92 92 return EE_INCOMPATIBLE; 93 93 94 94 if (header->e_shentsize != sizeof(elf_section_header_t)) 95 95 return EE_INCOMPATIBLE; 96 96 97 97 /* Check if the object type is supported. */ 98 98 if (header->e_type != ET_EXEC) 99 99 return EE_UNSUPPORTED; 100 100 101 101 /* Check if the ELF image starts on a page boundary */ 102 102 if (ALIGN_UP((uintptr_t) header, PAGE_SIZE) != (uintptr_t) header) 103 103 return EE_UNSUPPORTED; 104 104 105 105 /* Walk through all segment headers and process them. */ 106 106 elf_half i; … … 109 109 &((elf_segment_header_t *)(((uint8_t *) header) + 110 110 header->e_phoff))[i]; 111 111 112 112 int rc = segment_header(seghdr, header, as, flags); 113 113 if (rc != EE_OK) 114 114 return rc; 115 115 } 116 116 117 117 /* Inspect all section headers and process them. */ 118 118 for (i = 0; i < header->e_shnum; i++) { … … 120 120 &((elf_section_header_t *)(((uint8_t *) header) + 121 121 header->e_shoff))[i]; 122 122 123 123 int rc = section_header(sechdr, header, as); 124 124 if (rc != EE_OK) 125 125 return rc; 126 126 } 127 127 128 128 return EE_OK; 129 129 } … … 139 139 { 140 140 assert(rc < sizeof(error_codes) / sizeof(char *)); 141 141 142 142 return error_codes[rc]; 143 143 } … … 199 199 backend_data.elf = elf; 200 200 backend_data.segment = entry; 201 201 202 202 if (entry->p_align > 1) { 203 203 if ((entry->p_offset % entry->p_align) != … … 205 205 return EE_INVALID; 206 206 } 207 207 208 208 unsigned int flags = 0; 209 209 210 210 if (entry->p_flags & PF_X) 211 211 flags |= AS_AREA_EXEC; 212 212 213 213 if (entry->p_flags & PF_W) 214 214 flags |= AS_AREA_WRITE; 215 215 216 216 if (entry->p_flags & PF_R) 217 217 flags |= AS_AREA_READ; 218 218 219 219 flags |= AS_AREA_CACHEABLE; 220 220 221 221 /* 222 222 * Align vaddr down, inserting a little "gap" at the beginning. … … 226 226 uintptr_t base = ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE); 227 227 size_t mem_sz = entry->p_memsz + (entry->p_vaddr - base); 228 228 229 229 as_area_t *area = as_area_create(as, flags, mem_sz, 230 230 AS_AREA_ATTR_NONE, &elf_backend, &backend_data, &base, 0); 231 231 if (!area) 232 232 return EE_MEMORY; 233 233 234 234 /* 235 235 * The segment will be mapped on demand by elf_page_fault(). 236 236 * 237 237 */ 238 238 239 239 return EE_OK; 240 240 } … … 266 266 break; 267 267 } 268 268 269 269 return EE_OK; 270 270 }
Note:
See TracChangeset
for help on using the changeset viewer.