Subversion Repositories HelenOS

Rev

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

Rev 3688 Rev 3689
Line 52... Line 52...
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
    DPRINTF("module_process_relocs('%s')\n", m->dyn.soname);
56
    DPRINTF("module_process_relocs('%s')\n", m->dyn.soname);
-
 
57
 
-
 
58
    /* Do not relocate twice. */
-
 
59
    if (m->relocated) return;
-
 
60
 
57
    if (m->dyn.plt_rel == DT_REL) {
61
    if (m->dyn.plt_rel == DT_REL) {
58
        if (m->dyn.rel != NULL)
62
        if (m->dyn.rel != NULL)
59
            rel_table_process(m, m->dyn.rel, m->dyn.rel_sz);
63
            rel_table_process(m, m->dyn.rel, m->dyn.rel_sz);
60
        /* FIXME: this seems wrong */
64
        /* FIXME: this seems wrong */
61
        if (m->dyn.jmp_rel != NULL)
65
        if (m->dyn.jmp_rel != NULL)
Line 65... Line 69...
65
        if (m->dyn.rela != NULL) {
69
        if (m->dyn.rela != NULL) {
66
            DPRINTF("non-empty\n");
70
            DPRINTF("non-empty\n");
67
            rela_table_process(m, m->dyn.rela, m->dyn.rela_sz);
71
            rela_table_process(m, m->dyn.rela, m->dyn.rela_sz);
68
        }
72
        }
69
    }
73
    }
-
 
74
 
-
 
75
    m->relocated = true;
70
}
76
}
71
 
77
 
72
/** Find module structure by soname/pathname.
78
/** Find module structure by soname/pathname.
73
 *
79
 *
74
 * Used primarily to see if a module has already been loaded.
80
 * Used primarily to see if a module has already been loaded.
Line 129... Line 135...
129
    /* Prepend soname with '/lib/' */
135
    /* Prepend soname with '/lib/' */
130
    name_buf[0] = '/';
136
    name_buf[0] = '/';
131
    strcpy(name_buf, "/lib/");
137
    strcpy(name_buf, "/lib/");
132
    strcpy(name_buf + 5, name);
138
    strcpy(name_buf + 5, name);
133
 
139
 
134
    /* FIXME: need to vary bias / allocate address space */
140
    /* FIXME: need to real allocation of address space */
-
 
141
    m->bias = runtime_env->next_bias;
135
    m->bias = 0x20000;
142
    runtime_env->next_bias += 0x100000;
-
 
143
 
136
    DPRINTF("filename:'%s'\n", name_buf);
144
    DPRINTF("filename:'%s'\n", name_buf);
137
 
145
 
138
    rc = elf_load_file(name_buf, m->bias, ELDF_RW, &info);
146
    rc = elf_load_file(name_buf, m->bias, ELDF_RW, &info);
139
    if (rc < 0) {
147
    if (rc != EE_OK) {
140
        printf("Failed to load '%s'\n", name_buf);
148
        printf("Failed to load '%s'\n", name_buf);
141
        exit(1);
149
        exit(1);
142
    }
150
    }
143
 
151
 
-
 
152
    /* Pending relocation. */
-
 
153
    m->relocated = false;
-
 
154
 
144
    DPRINTF("parse dynamic section\n");
155
    DPRINTF("parse dynamic section\n");
145
    /* Parse ELF .dynamic section. Store info to m->dyn. */
156
    /* Parse ELF .dynamic section. Store info to m->dyn. */
146
    dynamic_parse(info.dynamic, m->bias, &m->dyn);
157
    dynamic_parse(info.dynamic, m->bias, &m->dyn);
147
 
158
 
148
    /* Insert into the list of loaded modules */
159
    /* Insert into the list of loaded modules */
Line 205... Line 216...
205
        }
216
        }
206
        ++dp;
217
        ++dp;
207
    }
218
    }
208
}
219
}
209
 
220
 
-
 
221
/** Process relocations in modules.
-
 
222
 *
-
 
223
 * Processes relocations in @a start and all its dependencies.
-
 
224
 * Modules that have already been relocated are unaffected.
-
 
225
 *
-
 
226
 * @param   start   The module where to start from.
-
 
227
 */
210
void modules_process_relocs(void)
228
void modules_process_relocs(module_t *start)
211
{
229
{
212
    link_t *head = &runtime_env->modules_head;
230
    link_t *head = &runtime_env->modules_head;
213
 
231
 
214
    link_t *cur;
232
    link_t *cur;
215
    module_t *m;
233
    module_t *m;