Rev 963 | Rev 1026 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 963 | Rev 973 | ||
---|---|---|---|
Line 183... | Line 183... | ||
183 | * Check if the virtual address starts on page boundary. |
183 | * Check if the virtual address starts on page boundary. |
184 | */ |
184 | */ |
185 | if (ALIGN_UP(entry->p_vaddr, PAGE_SIZE) != entry->p_vaddr) |
185 | if (ALIGN_UP(entry->p_vaddr, PAGE_SIZE) != entry->p_vaddr) |
186 | return EE_UNSUPPORTED; |
186 | return EE_UNSUPPORTED; |
187 | 187 | ||
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 | */ |
- | |
193 | segment_size = ALIGN_UP(max(entry->p_filesz, entry->p_memsz), PAGE_SIZE); |
188 | segment_size = ALIGN_UP(max(entry->p_filesz, entry->p_memsz), PAGE_SIZE); |
194 | segment = malloc(segment_size, 0); |
189 | if ((entry->p_flags & PF_W)) { |
- | 190 | /* If writable, copy data (should be COW in the future) */ |
|
195 | if (entry->p_filesz < entry->p_memsz) |
191 | segment = malloc(segment_size, 0); |
196 | memsetb((__address) (segment + entry->p_filesz), segment_size - entry->p_filesz, 0); |
192 | 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; |
|
198 | 196 | ||
199 | a = as_area_create(as, type, SIZE2FRAMES(entry->p_memsz), entry->p_vaddr); |
197 | a = as_area_create(as, type, SIZE2FRAMES(entry->p_memsz), entry->p_vaddr); |
200 | if (!a) |
198 | if (!a) |
201 | return EE_IRRECOVERABLE; |
199 | return EE_IRRECOVERABLE; |
202 | 200 |