Subversion Repositories HelenOS

Rev

Rev 3553 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3553 Rev 3562
Line 51... Line 51...
51
 *
51
 *
52
 * Currently works as if LD_BIND_NOW was specified.
52
 * Currently works as if LD_BIND_NOW was specified.
53
 */
53
 */
54
void module_process_relocs(module_t *m)
54
void module_process_relocs(module_t *m)
55
{
55
{
56
    printf("module_process_relocs('%s')\n", m->dyn.soname);
56
    DPRINTF("module_process_relocs('%s')\n", m->dyn.soname);
57
    if (m->dyn.plt_rel == DT_REL) {
57
    if (m->dyn.plt_rel == DT_REL) {
58
        if (m->dyn.rel != NULL)
58
        if (m->dyn.rel != NULL)
59
            rel_table_process(m, m->dyn.rel, m->dyn.rel_sz);
59
            rel_table_process(m, m->dyn.rel, m->dyn.rel_sz);
60
        /* FIXME: this seems wrong */
60
        /* FIXME: this seems wrong */
61
        if (m->dyn.jmp_rel != NULL)
61
        if (m->dyn.jmp_rel != NULL)
62
            rel_table_process(m, m->dyn.jmp_rel, m->dyn.plt_rel_sz);
62
            rel_table_process(m, m->dyn.jmp_rel, m->dyn.plt_rel_sz);
63
    } else { /* (m->dyn.plt_rel == DT_RELA) */
63
    } else { /* (m->dyn.plt_rel == DT_RELA) */
64
        printf("table type DT_RELA\n");
64
        DPRINTF("table type DT_RELA\n");
65
        if (m->dyn.rela != NULL) {
65
        if (m->dyn.rela != NULL) {
66
            printf("non-empty\n");
66
            DPRINTF("non-empty\n");
67
            rela_table_process(m, m->dyn.rela, m->dyn.rela_sz);
67
            rela_table_process(m, m->dyn.rela, m->dyn.rela_sz);
68
        }
68
        }
69
    }
69
    }
70
}
70
}
71
 
71
 
Line 131... Line 131...
131
    strcpy(name_buf, "/lib/");
131
    strcpy(name_buf, "/lib/");
132
    strcpy(name_buf + 5, name);
132
    strcpy(name_buf + 5, name);
133
 
133
 
134
    /* FIXME: need to vary bias / allocate address space */
134
    /* FIXME: need to vary bias / allocate address space */
135
    m->bias = 0x20000;
135
    m->bias = 0x20000;
136
    printf("filename:'%s'\n", name_buf);
136
    DPRINTF("filename:'%s'\n", name_buf);
137
 
137
 
138
    rc = elf_load_file(name_buf, m->bias, ELDF_RW, &info);
138
    rc = elf_load_file(name_buf, m->bias, ELDF_RW, &info);
139
    if (rc < 0) {
139
    if (rc < 0) {
140
        printf("Failed to load '%s'\n", name_buf);
140
        printf("Failed to load '%s'\n", name_buf);
141
        exit(1);
141
        exit(1);
142
    }
142
    }
143
 
143
 
144
    printf("parse dynamic section\n");
144
    DPRINTF("parse dynamic section\n");
145
    /* Parse ELF .dynamic section. Store info to m->dyn. */
145
    /* Parse ELF .dynamic section. Store info to m->dyn. */
146
    dynamic_parse(info.dynamic, m->bias, &m->dyn);
146
    dynamic_parse(info.dynamic, m->bias, &m->dyn);
147
 
147
 
148
    /* Insert into the list of loaded modules */
148
    /* Insert into the list of loaded modules */
149
    list_append(&m->modules_link, &runtime_env.modules_head);
149
    list_append(&m->modules_link, &runtime_env.modules_head);
Line 191... Line 191...
191
 
191
 
192
    while (dp->d_tag != DT_NULL) {
192
    while (dp->d_tag != DT_NULL) {
193
        if (dp->d_tag == DT_NEEDED) {
193
        if (dp->d_tag == DT_NEEDED) {
194
            dep_name = m->dyn.str_tab + dp->d_un.d_val;
194
            dep_name = m->dyn.str_tab + dp->d_un.d_val;
195
 
195
 
196
            printf("%s needs %s\n", m->dyn.soname, dep_name);
196
            DPRINTF("%s needs %s\n", m->dyn.soname, dep_name);
197
            dm = module_find(dep_name);
197
            dm = module_find(dep_name);
198
            if (!dm) {
198
            if (!dm) {
199
                dm = module_load(dep_name);
199
                dm = module_load(dep_name);
200
                module_load_deps(dm);
200
                module_load_deps(dm);
201
            }
201
            }