Rev 3403 | Rev 3562 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3403 | Rev 3552 | ||
---|---|---|---|
Line 97... | Line 97... | ||
97 | * @param info Pointer to a structure for storing information |
97 | * @param info Pointer to a structure for storing information |
98 | * extracted from the binary. |
98 | * extracted from the binary. |
99 | * |
99 | * |
100 | * @return EOK on success or negative error code. |
100 | * @return EOK on success or negative error code. |
101 | */ |
101 | */ |
102 | int elf_load_file(char *file_name, size_t so_bias, elf_info_t *info) |
102 | int elf_load_file(char *file_name, size_t so_bias, eld_flags_t flags, |
- | 103 | elf_info_t *info) |
|
103 | { |
104 | { |
104 | elf_ld_t elf; |
105 | elf_ld_t elf; |
105 | 106 | ||
106 | int fd; |
107 | int fd; |
107 | int rc; |
108 | int rc; |
Line 114... | Line 115... | ||
114 | return -1; |
115 | return -1; |
115 | } |
116 | } |
116 | 117 | ||
117 | elf.fd = fd; |
118 | elf.fd = fd; |
118 | elf.info = info; |
119 | elf.info = info; |
- | 120 | elf.flags = flags; |
|
119 | 121 | ||
120 | rc = elf_load(&elf, so_bias); |
122 | rc = elf_load(&elf, so_bias); |
121 | 123 | ||
122 | close(fd); |
124 | close(fd); |
123 | 125 | ||
Line 305... | Line 307... | ||
305 | break; |
307 | break; |
306 | case PT_LOAD: |
308 | case PT_LOAD: |
307 | return load_segment(elf, entry); |
309 | return load_segment(elf, entry); |
308 | break; |
310 | break; |
309 | case PT_INTERP: |
311 | case PT_INTERP: |
310 | /* Assume silently interp == "/lib/rtld.so" */ |
312 | /* Assume silently interp == "/lib/rtld" */ |
311 | elf->info->interp = "/lib/rtld.so"; |
313 | elf->info->interp = "/lib/rtld"; |
312 | break; |
314 | break; |
313 | case PT_DYNAMIC: |
315 | case PT_DYNAMIC: |
314 | case PT_SHLIB: |
316 | case PT_SHLIB: |
315 | case PT_NOTE: |
317 | case PT_NOTE: |
316 | case PT_LOPROC: |
318 | case PT_LOPROC: |
Line 423... | Line 425... | ||
423 | 425 | ||
424 | left -= now; |
426 | left -= now; |
425 | dp += now; |
427 | dp += now; |
426 | } |
428 | } |
427 | 429 | ||
- | 430 | /* |
|
- | 431 | * The caller wants to modify the segments first. He will then |
|
- | 432 | * need to set the right access mode and ensure SMC coherence. |
|
- | 433 | */ |
|
- | 434 | if ((elf->flags & ELDF_RW) != 0) return EE_OK; |
|
- | 435 | ||
428 | // printf("set area flags to %d\n", flags); |
436 | printf("set area flags to %d\n", flags); |
429 | rc = as_area_change_flags((uint8_t *)entry->p_vaddr + bias, flags); |
437 | rc = as_area_change_flags((uint8_t *)entry->p_vaddr + bias, flags); |
430 | if (rc != 0) { |
438 | if (rc != 0) { |
431 | printf("failed to set memory area flags\n"); |
439 | printf("failed to set memory area flags\n"); |
432 | return EE_MEMORY; |
440 | return EE_MEMORY; |
433 | } |
441 | } |