Subversion Repositories HelenOS

Rev

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

Rev 3772 Rev 3970
Line 46... Line 46...
46
{
46
{
47
    elf_symbol_t *sym_table;
47
    elf_symbol_t *sym_table;
48
    elf_symbol_t *sym_def;
48
    elf_symbol_t *sym_def;
49
    elf_symbol_t *sym;
49
    elf_symbol_t *sym;
50
    uint32_t gotsym;
50
    uint32_t gotsym;
-
 
51
    uint32_t lgotno;
51
    uint32_t *got;
52
    uint32_t *got;
52
    char *str_tab;
53
    char *str_tab;
53
    int i;
54
    int i, j;
54
 
55
 
55
    uint32_t sym_addr;
56
    uint32_t sym_addr;
56
    module_t *dest;
57
    module_t *dest;
57
 
58
 
58
    got = (uint32_t *) m->dyn.plt_got;
59
    got = (uint32_t *) m->dyn.plt_got;
59
    sym_table = m->dyn.sym_tab;
60
    sym_table = m->dyn.sym_tab;
60
    str_tab = m->dyn.str_tab;
61
    str_tab = m->dyn.str_tab;
61
    gotsym = m->dyn.arch.gotsym;
62
    gotsym = m->dyn.arch.gotsym;
-
 
63
    lgotno = m->dyn.arch.lgotno;
62
 
64
 
63
    DPRINTF("** Relocate GOT entries **\n");
65
    DPRINTF("** Relocate GOT entries **\n");
64
    DPRINTF("MIPS base = 0x%x\n", m->dyn.arch.base);
66
    DPRINTF("MIPS base = 0x%x\n", m->dyn.arch.base);
65
 
67
 
66
    /*
68
    /*
Line 70... Line 72...
70
        /* FIXME: really subtract MIPS base? */
72
        /* FIXME: really subtract MIPS base? */
71
        got[i] += m->bias - m->dyn.arch.base;
73
        got[i] += m->bias - m->dyn.arch.base;
72
    }
74
    }
73
 
75
 
74
    DPRINTF("sym_ent = %d, gotsym = %d\n", m->dyn.arch.sym_no, gotsym);
76
    DPRINTF("sym_ent = %d, gotsym = %d\n", m->dyn.arch.sym_no, gotsym);
-
 
77
    DPRINTF("lgotno = %d\n", lgotno);
75
 
78
 
76
    /*
79
    /*
77
     * Global entries.
80
     * Iterate over GOT-mapped symbol entries.
78
     */
81
     */
79
    for (i = gotsym; i < m->dyn.arch.sym_no; i++) {
82
    for (j = gotsym; j < m->dyn.arch.sym_no; j++) {
-
 
83
        /* Corresponding (global) GOT entry. */
-
 
84
        i = lgotno + j - gotsym;
-
 
85
 
80
        DPRINTF("relocate GOT entry %d\n", i);
86
        DPRINTF("relocate GOT entry %d\n", i);
81
//      getchar();
87
//      getchar();
-
 
88
//      getchar();
82
 
89
 
83
        sym = &sym_table[i];
90
        sym = &sym_table[j];
84
        if (ELF32_R_TYPE(sym->st_info) == STT_FUNC) {
91
        if (ELF32_R_TYPE(sym->st_info) == STT_FUNC) {
85
            if (sym->st_shndx == SHN_UNDEF) {
92
            if (sym->st_shndx == SHN_UNDEF) {
86
                if (sym->st_value == 0) {
93
                if (sym->st_value == 0) {
87
                    /* 1 */
94
                    /* 1 */
88
                } else {
95
                } else {
Line 121... Line 128...
121
        } else {
128
        } else {
122
            DPRINTF("symbol definition not found\n");
129
            DPRINTF("symbol definition not found\n");
123
            continue;
130
            continue;
124
        }
131
        }
125
        DPRINTF("write 0x%x at 0x%x\n", sym_addr, (uint32_t) &got[i]);
132
        DPRINTF("write 0x%x at 0x%x\n", sym_addr, (uint32_t) &got[i]);
126
//      getchar();
-
 
127
        got[i] = sym_addr;
133
        got[i] = sym_addr;
128
    }
134
    }
129
 
135
 
130
    DPRINTF("** Done **\n");
136
    DPRINTF("** Done **\n");
131
}
137
}
Line 153... Line 159...
153
    elf_symbol_t *sym_def;
159
    elf_symbol_t *sym_def;
154
    module_t *dest;
160
    module_t *dest;
155
 
161
 
156
    uint32_t *got;
162
    uint32_t *got;
157
    uint32_t gotsym;
163
    uint32_t gotsym;
-
 
164
    uint32_t lgotno;
158
    uint32_t ea;
165
    uint32_t ea;
159
 
166
 
160
    DPRINTF("parse relocation table\n");
167
    DPRINTF("parse relocation table\n");
161
 
168
 
162
    sym_table = m->dyn.sym_tab;
169
    sym_table = m->dyn.sym_tab;
163
    rt_entries = rt_size / sizeof(elf_rela_t);
170
    rt_entries = rt_size / sizeof(elf_rela_t);
164
    str_tab = m->dyn.str_tab;
171
    str_tab = m->dyn.str_tab;
165
    got = (uint32_t *) m->dyn.plt_got;
172
    got = (uint32_t *) m->dyn.plt_got;
166
    gotsym = m->dyn.arch.gotsym;
173
    gotsym = m->dyn.arch.gotsym;
-
 
174
    lgotno = m->dyn.arch.lgotno;
167
 
175
 
168
    DPRINTF("got=0x%lx, gotsym=%d\n", (uintptr_t) got, gotsym);
176
    DPRINTF("got=0x%lx, gotsym=%d\n", (uintptr_t) got, gotsym);
169
 
177
 
170
    DPRINTF("address: 0x%x, entries: %d\n", (uintptr_t)rt, rt_entries);
178
    DPRINTF("address: 0x%x, entries: %d\n", (uintptr_t)rt, rt_entries);
171
   
179
   
Line 209... Line 217...
209
        case R_MIPS_REL32:
217
        case R_MIPS_REL32:
210
            DPRINTF("fixup R_MIPS_REL32 (r - ea + s)\n");
218
            DPRINTF("fixup R_MIPS_REL32 (r - ea + s)\n");
211
            if (sym_idx < gotsym)
219
            if (sym_idx < gotsym)
212
                ea = sym_addr;
220
                ea = sym_addr;
213
            else
221
            else
214
                ea = got[sym_idx];
222
                ea = got[lgotno + sym_idx - gotsym];
215
 
223
 
216
            *r_ptr += sym_addr - ea;
224
            *r_ptr += sym_addr - ea;
217
            DPRINTF("p = 0x%x, val := 0x%x\n", (uint32_t) r_ptr,
225
            DPRINTF("p = 0x%x, val := 0x%x\n", (uint32_t) r_ptr,
218
                *r_ptr);
226
                *r_ptr);
219
//          getchar();
227
//          getchar();