Subversion Repositories HelenOS

Rev

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

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