Changeset 5be1923 in mainline for generic/src/lib/elf.c


Ignore:
Timestamp:
2006-03-14T12:11:28Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d3e7ff4
Parents:
4bb4836d
Message:

Added simpler userspace starting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/lib/elf.c

    r4bb4836d r5be1923  
    186186                return EE_UNSUPPORTED;
    187187
    188         /*
    189          * Copying the segment out is certainly necessary for segments with p_filesz < p_memsz
    190          * because of the effect of .bss-like sections. For security reasons, it looks like a
    191          * good idea to copy the segment anyway.
    192          */
    193188        segment_size = ALIGN_UP(max(entry->p_filesz, entry->p_memsz), PAGE_SIZE);
    194         segment = malloc(segment_size, 0);
    195         if (entry->p_filesz < entry->p_memsz)
     189        if ((entry->p_flags & PF_W)) {
     190                /* If writable, copy data (should be COW in the future) */
     191                segment = malloc(segment_size, 0);
    196192                memsetb((__address) (segment + entry->p_filesz), segment_size - entry->p_filesz, 0);
    197         memcpy(segment, (void *) (((__address) elf) + entry->p_offset), entry->p_filesz);
     193                memcpy(segment, (void *) (((__address) elf) + entry->p_offset), entry->p_filesz);
     194        } else /* Map identically original data */
     195                segment = ((void *) elf) + entry->p_offset;
    198196
    199197        a = as_area_create(as, type, SIZE2FRAMES(entry->p_memsz), entry->p_vaddr);
Note: See TracChangeset for help on using the changeset viewer.