Subversion Repositories HelenOS

Rev

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

Rev 2932 Rev 2949
Line 43... Line 43...
43
#include <assert.h>
43
#include <assert.h>
44
#include <as.h>
44
#include <as.h>
45
#include "elf.h"
45
#include "elf.h"
46
 
46
 
47
#define RTLD_BIAS 0x80000
47
#define RTLD_BIAS 0x80000
-
 
48
//#define RTLD_BIAS 0
48
 
49
 
49
static char *error_codes[] = {
50
static char *error_codes[] = {
50
    "no error",
51
    "no error",
51
    "invalid image",
52
    "invalid image",
52
    "address space error",
53
    "address space error",
Line 227... Line 228...
227
    if (entry->p_flags & PF_R)
228
    if (entry->p_flags & PF_R)
228
        flags |= AS_AREA_READ;
229
        flags |= AS_AREA_READ;
229
    flags |= AS_AREA_CACHEABLE;
230
    flags |= AS_AREA_CACHEABLE;
230
*/
231
*/
231
    /* FIXME: Kernel won't normally allow this, unless you "patch" it */
232
    /* FIXME: Kernel won't normally allow this, unless you "patch" it */
232
    flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_EXEC | AS_AREA_CACHEABLE;
233
//  flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_EXEC | AS_AREA_CACHEABLE;
-
 
234
    flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE;
233
 
235
 
234
    /*
236
    /*
235
     * Check if the virtual address starts on page boundary.
237
     * Check if the virtual address starts on page boundary.
236
     */
238
     */
237
    if (ALIGN_UP(entry->p_vaddr, PAGE_SIZE) != entry->p_vaddr) {
239
    if (ALIGN_UP(entry->p_vaddr, PAGE_SIZE) != entry->p_vaddr) {
Line 249... Line 251...
249
    if (a == (void *)(-1)) {
251
    if (a == (void *)(-1)) {
250
        printf("memory mapping failed\n");
252
        printf("memory mapping failed\n");
251
        return EE_MEMORY;
253
        return EE_MEMORY;
252
    }
254
    }
253
 
255
 
254
    printf("as_area_create() -> 0x%x\n", (unsigned)a);
256
    printf("as_area_create(0x%x, 0x%x, %d) -> 0x%x\n",
-
 
257
        entry->p_vaddr+bias, entry->p_memsz, flags, (unsigned)a);
255
 
258
 
256
    /*
259
    /*
257
     * Load segment data
260
     * Load segment data
258
     */
261
     */
-
 
262
    printf("seek to %d\n", entry->p_offset);
259
    rc = lseek(fd, entry->p_offset, SEEK_SET);
263
    rc = lseek(fd, entry->p_offset, SEEK_SET);
260
    if (rc < 0) { printf("seek error\n"); return EE_INVALID; }
264
    if (rc < 0) { printf("seek error\n"); return EE_INVALID; }
261
 
265
 
-
 
266
    printf("read 0x%x bytes to address 0x%x\n", entry->p_filesz, entry->p_vaddr+bias);
262
    rc = read(fd, (void *)(entry->p_vaddr + bias), entry->p_filesz);
267
/*  rc = read(fd, (void *)(entry->p_vaddr + bias), entry->p_filesz);
-
 
268
    if (rc < 0) { printf("read error\n"); return EE_INVALID; }*/
-
 
269
    unsigned left, now;
-
 
270
    uint8_t *dp;
-
 
271
 
-
 
272
    left = entry->p_filesz;
-
 
273
    dp = (uint8_t *)(entry->p_vaddr + bias);
-
 
274
 
-
 
275
    while (left > 0) {
-
 
276
        now = 4096;
-
 
277
        if (now > left) now=left;
-
 
278
        printf("read %d...", now);
-
 
279
        rc = read(fd, dp, now);
263
    if (rc < 0) { printf("read error\n"); return EE_INVALID; }
280
        if (rc < 0) { printf("read error\n"); return EE_INVALID; }
-
 
281
        printf("->%d\n", rc);
-
 
282
        left -= now;
-
 
283
        dp += now;
-
 
284
    }
264
 
285
 
265
    return EE_OK;
286
    return EE_OK;
266
}
287
}
267
 
288
 
268
/** Process section header.
289
/** Process section header.