Subversion Repositories HelenOS

Rev

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

Rev 2949 Rev 2961
Line 55... Line 55...
55
    "unsupported image type",
55
    "unsupported image type",
56
    "irrecoverable error"
56
    "irrecoverable error"
57
};
57
};
58
 
58
 
59
static int segment_header(int fd, elf_header_t *elf);
59
static int segment_header(int fd, elf_header_t *elf);
60
static int section_header(elf_section_header_t *entry, elf_header_t *elf);
60
static int section_header(int fd, elf_header_t *elf);
61
static int load_segment(int fd, elf_segment_header_t *entry, elf_header_t *elf);
61
static int load_segment(int fd, elf_segment_header_t *entry, elf_header_t *elf);
62
 
62
 
63
typedef void (*epoint_t)(void);
63
typedef void (*epoint_t)(void);
64
 
64
 
65
/** ELF loader
65
/** ELF loader
Line 113... Line 113...
113
    printf("parse segments\n");
113
    printf("parse segments\n");
114
 
114
 
115
    /* Walk through all segment headers and process them. */
115
    /* Walk through all segment headers and process them. */
116
    for (i = 0; i < header->e_phnum; i++) {
116
    for (i = 0; i < header->e_phnum; i++) {
117
 
117
 
118
        /* Seek to start of header */
118
        /* Seek to start of segment header */
119
        lseek(fd, header->e_phoff + i * sizeof(elf_segment_header_t), SEEK_SET);
119
        lseek(fd, header->e_phoff + i * sizeof(elf_segment_header_t),
-
 
120
            SEEK_SET);
120
 
121
 
121
        rc = segment_header(fd, header);
122
        rc = segment_header(fd, header);
122
        if (rc != EE_OK)
123
        if (rc != EE_OK)
123
            return rc;
124
            return rc;
124
    }
125
    }
125
 
126
 
126
    printf("parse sections\n");
127
    printf("parse sections\n");
127
 
128
 
128
    /* Inspect all section headers and proccess them. */
129
    /* Inspect all section headers and proccess them. */
129
    for (i = 0; i < header->e_shnum; i++) {
130
    for (i = 0; i < header->e_shnum; i++) {
130
/*      elf_section_header_t *sechdr;
-
 
131
 
131
 
-
 
132
        /* Seek to start of section header */
132
        sechdr = &((elf_section_header_t *)(((uint8_t *) header) +
133
        lseek(fd, header->e_shoff + i * sizeof(elf_section_header_t),
133
            header->e_shoff))[i];
134
            SEEK_SET);
-
 
135
 
134
        rc = section_header(sechdr, header);
136
        rc = section_header(fd, header);
135
        if (rc != EE_OK)
137
        if (rc != EE_OK)
136
            return rc;*/
138
            return rc;
137
    }
139
    }
138
 
140
 
139
    printf("done\n");
141
    printf("done\n");
140
 
142
 
141
    return EE_OK;
143
    return EE_OK;
Line 291... Line 293...
291
 * @param entry Segment header.
293
 * @param entry Segment header.
292
 * @param elf ELF header.
294
 * @param elf ELF header.
293
 *
295
 *
294
 * @return EE_OK on success, error code otherwise.
296
 * @return EE_OK on success, error code otherwise.
295
 */
297
 */
296
static int section_header(elf_section_header_t *entry, elf_header_t *elf)
298
static int section_header(int fd, elf_header_t *elf)
297
{
299
{
-
 
300
    static elf_section_header_t entry_buf;
-
 
301
    elf_section_header_t *entry = &entry_buf;
-
 
302
    int rc;
-
 
303
 
-
 
304
    rc = read(fd, entry, sizeof(elf_section_header_t));
-
 
305
    if (rc < 0) { printf("read error\n"); return EE_INVALID; }
-
 
306
 
298
    switch (entry->sh_type) {
307
    switch (entry->sh_type) {
299
    case SHT_PROGBITS:
308
    case SHT_PROGBITS:
300
        if (entry->sh_flags & SHF_TLS) {
309
        if (entry->sh_flags & SHF_TLS) {
301
            /* .tdata */
310
            /* .tdata */
302
        }
311
        }
Line 304... Line 313...
304
    case SHT_NOBITS:
313
    case SHT_NOBITS:
305
        if (entry->sh_flags & SHF_TLS) {
314
        if (entry->sh_flags & SHF_TLS) {
306
            /* .tbss */
315
            /* .tbss */
307
        }
316
        }
308
        break;
317
        break;
-
 
318
    case SHT_DYNAMIC:
-
 
319
        printf("dynamic section found\n");
-
 
320
        break;
309
    default:
321
    default:
310
        break;
322
        break;
311
    }
323
    }
312
   
324
   
313
    return EE_OK;
325
    return EE_OK;