Subversion Repositories HelenOS

Rev

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

Rev 3222 Rev 3223
Line 222... Line 222...
222
        /* Seek to start of segment header */
222
        /* Seek to start of segment header */
223
        lseek(elf->fd, header->e_phoff
223
        lseek(elf->fd, header->e_phoff
224
                + i * sizeof(elf_segment_header_t), SEEK_SET);
224
                + i * sizeof(elf_segment_header_t), SEEK_SET);
225
 
225
 
226
        rc = read(elf->fd, &segment_hdr, sizeof(elf_segment_header_t));
226
        rc = read(elf->fd, &segment_hdr, sizeof(elf_segment_header_t));
-
 
227
        if (rc < 0) {
227
        if (rc < 0) { printf("read error\n"); return EE_INVALID; }
228
            printf("read error\n");
-
 
229
            return EE_INVALID;
-
 
230
        }
228
 
231
 
229
        rc = segment_header(elf, &segment_hdr);
232
        rc = segment_header(elf, &segment_hdr);
230
        if (rc != EE_OK)
233
        if (rc != EE_OK)
231
            return rc;
234
            return rc;
232
    }
235
    }
Line 240... Line 243...
240
        /* Seek to start of section header */
243
        /* Seek to start of section header */
241
        lseek(elf->fd, header->e_shoff
244
        lseek(elf->fd, header->e_shoff
242
            + i * sizeof(elf_section_header_t), SEEK_SET);
245
            + i * sizeof(elf_section_header_t), SEEK_SET);
243
 
246
 
244
        rc = read(elf->fd, &section_hdr, sizeof(elf_section_header_t));
247
        rc = read(elf->fd, &section_hdr, sizeof(elf_section_header_t));
-
 
248
        if (rc < 0) {
245
        if (rc < 0) { printf("read error\n"); return EE_INVALID; }
249
            printf("read error\n");
-
 
250
            return EE_INVALID;
-
 
251
        }
246
 
252
 
247
        rc = section_header(elf, &section_hdr);
253
        rc = section_header(elf, &section_hdr);
248
        if (rc != EE_OK)
254
        if (rc != EE_OK)
249
            return rc;
255
            return rc;
250
    }
256
    }
Line 324... Line 330...
324
    bias = elf->bias;
330
    bias = elf->bias;
325
 
331
 
326
    if (entry->p_align > 1) {
332
    if (entry->p_align > 1) {
327
        if ((entry->p_offset % entry->p_align) !=
333
        if ((entry->p_offset % entry->p_align) !=
328
            (entry->p_vaddr % entry->p_align)) {
334
            (entry->p_vaddr % entry->p_align)) {
329
            printf("align check 1 failed offset%%align=%d, vaddr%%align=%d\n",
335
            printf("align check 1 failed offset%%align=%d, "
-
 
336
                "vaddr%%align=%d\n",
330
            entry->p_offset % entry->p_align,
337
                entry->p_offset % entry->p_align,
331
            entry->p_vaddr % entry->p_align
338
                entry->p_vaddr % entry->p_align
332
            );
339
            );
333
            return EE_INVALID;
340
            return EE_INVALID;
334
        }
341
        }
335
    }
342
    }
336
 
343
 
Line 367... Line 374...
367
    /*
374
    /*
368
     * Load segment data
375
     * Load segment data
369
     */
376
     */
370
//  printf("seek to %d\n", entry->p_offset);
377
//  printf("seek to %d\n", entry->p_offset);
371
    rc = lseek(elf->fd, entry->p_offset, SEEK_SET);
378
    rc = lseek(elf->fd, entry->p_offset, SEEK_SET);
-
 
379
    if (rc < 0) {
372
    if (rc < 0) { printf("seek error\n"); return EE_INVALID; }
380
        printf("seek error\n");
-
 
381
        return EE_INVALID;
-
 
382
    }
373
 
383
 
374
//  printf("read 0x%x bytes to address 0x%x\n", entry->p_filesz, entry->p_vaddr+bias);
384
//  printf("read 0x%x bytes to address 0x%x\n", entry->p_filesz, entry->p_vaddr+bias);
375
/*  rc = read(fd, (void *)(entry->p_vaddr + bias), entry->p_filesz);
385
/*  rc = read(fd, (void *)(entry->p_vaddr + bias), entry->p_filesz);
376
    if (rc < 0) { printf("read error\n"); return EE_INVALID; }*/
386
    if (rc < 0) { printf("read error\n"); return EE_INVALID; }*/
377
 
387
 
Line 389... Line 399...
389
 
399
 
390
//      printf("read %d...", now);
400
//      printf("read %d...", now);
391
        rc = read(elf->fd, dp, now);
401
        rc = read(elf->fd, dp, now);
392
//      printf("->%d\n", rc);
402
//      printf("->%d\n", rc);
393
 
403
 
-
 
404
        if (rc < 0) {
394
        if (rc < 0) { printf("read error\n"); return EE_INVALID; }
405
            printf("read error\n");
-
 
406
            return EE_INVALID;
-
 
407
        }
395
 
408
 
396
        left -= now;
409
        left -= now;
397
        dp += now;
410
        dp += now;
398
    }
411
    }
399
 
412