Subversion Repositories HelenOS

Rev

Rev 3001 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3001 Rev 3009
Line 99... Line 99...
99
 
99
 
100
    /* Check if the object type is supported. */
100
    /* Check if the object type is supported. */
101
    if (header->e_type != ET_EXEC)
101
    if (header->e_type != ET_EXEC)
102
        return EE_UNSUPPORTED;
102
        return EE_UNSUPPORTED;
103
 
103
 
-
 
104
    /* Check if the ELF image starts on a page boundary */
-
 
105
    if (ALIGN_UP((uintptr_t)header, PAGE_SIZE) != (uintptr_t)header)
-
 
106
        return EE_UNSUPPORTED;
-
 
107
 
104
    /* Walk through all segment headers and process them. */
108
    /* Walk through all segment headers and process them. */
105
    for (i = 0; i < header->e_phnum; i++) {
109
    for (i = 0; i < header->e_phnum; i++) {
106
        elf_segment_header_t *seghdr;
110
        elf_segment_header_t *seghdr;
107
 
111
 
108
        seghdr = &((elf_segment_header_t *)(((uint8_t *) header) +
112
        seghdr = &((elf_segment_header_t *)(((uint8_t *) header) +
Line 191... Line 195...
191
int load_segment(elf_segment_header_t *entry, elf_header_t *elf, as_t *as)
195
int load_segment(elf_segment_header_t *entry, elf_header_t *elf, as_t *as)
192
{
196
{
193
    as_area_t *a;
197
    as_area_t *a;
194
    int flags = 0;
198
    int flags = 0;
195
    mem_backend_data_t backend_data;
199
    mem_backend_data_t backend_data;
-
 
200
    uintptr_t base;
-
 
201
    size_t mem_sz;
196
   
202
   
197
    backend_data.elf = elf;
203
    backend_data.elf = elf;
198
    backend_data.segment = entry;
204
    backend_data.segment = entry;
199
 
205
 
200
    if (entry->p_align > 1) {
206
    if (entry->p_align > 1) {
Line 210... Line 216...
210
        flags |= AS_AREA_WRITE;
216
        flags |= AS_AREA_WRITE;
211
    if (entry->p_flags & PF_R)
217
    if (entry->p_flags & PF_R)
212
        flags |= AS_AREA_READ;
218
        flags |= AS_AREA_READ;
213
    flags |= AS_AREA_CACHEABLE;
219
    flags |= AS_AREA_CACHEABLE;
214
 
220
 
215
    /*
221
    /*
-
 
222
     * Align vaddr down, inserting a little "gap" at the beginning.
216
     * Check if the virtual address starts on page boundary.
223
     * Adjust area size, so that its end remains in place.
217
     */
224
     */
218
    if (ALIGN_UP(entry->p_vaddr, PAGE_SIZE) != entry->p_vaddr)
225
    base = ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE);
219
        return EE_UNSUPPORTED;
226
    mem_sz = entry->p_memsz + (entry->p_vaddr - base);
220
 
227
 
221
    a = as_area_create(as, flags, entry->p_memsz, entry->p_vaddr,
228
    a = as_area_create(as, flags, mem_sz, base,
222
        AS_AREA_ATTR_NONE, &elf_backend, &backend_data);
229
        AS_AREA_ATTR_NONE, &elf_backend, &backend_data);
223
    if (!a)
230
    if (!a)
224
        return EE_MEMORY;
231
        return EE_MEMORY;
225
   
232
   
226
    /*
233
    /*