Subversion Repositories HelenOS

Rev

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

Rev 2996 Rev 2997
Line 96... Line 96...
96
    kputint(-1);
96
    kputint(-1);
97
    kputint(42);
97
    kputint(42);
98
    kputint(-1);
98
    kputint(-1);
99
}
99
}
100
 
100
 
-
 
101
int test_var = 0x818283;
-
 
102
 
101
void __bootstrap(void);
103
void __bootstrap(void);
102
 
104
 
103
void __bootstrap(void)
105
void __bootstrap(void)
104
{
106
{
105
    unsigned bias;
107
    unsigned bias;
Line 215... Line 217...
215
//      kputint(rel_type);
217
//      kputint(rel_type);
216
//      kputint(r_offset);
218
//      kputint(r_offset);
217
 
219
 
218
        switch (rel_type) {
220
        switch (rel_type) {
219
        case R_PPC_JMP_SLOT:
221
        case R_PPC_JMP_SLOT:
220
            kputint(0xa);
222
//          kputint(0xa);
221
            sym_idx = ELF32_R_SYM(r_info);
223
            sym_idx = ELF32_R_SYM(r_info);
222
 
224
 
223
            sym_addr = sym_table[sym_idx].st_value + bias;
225
            sym_addr = sym_table[sym_idx].st_value + bias;
224
            kputint(sym_idx);
226
//          kputint(sym_idx);
225
            kputint(sym_addr);
227
//          kputint(sym_addr);
226
 
228
 
227
            // r_ptr should point to a plt entry...
229
            // r_ptr should point to a plt entry...
228
            uint32_t pidx = (r_ptr - _plt_ent) / 2;
230
            uint32_t pidx = (r_ptr - _plt_ent) / 2;
229
            if (pidx >= plt_n) {
231
            if (pidx >= plt_n) {
230
                kputint(0xee00ee0ee00);
232
                kputint(0xee00ee0ee00);
231
                //while(1);
233
                while(1);
232
            }
234
            }
233
            _plt_table[pidx] = sym_addr;
235
//          _plt_table[pidx] = sym_addr;
234
//          kputint(pidx);
236
//          kputint(pidx);
235
//          plt[18] = _b(sym_addr, plt + 18);
237
            plt[18+2*pidx] = _b(sym_addr, &plt[18+2*pidx]);
236
//          kputint(&plt[18]);
238
//          kputint(&plt[18]);
237
//          kputint(plt[18]);
239
//          kputint(plt[18]);
238
//          while(1);
240
//          while(1);
239
//          while(1);
241
//          while(1);
240
            //*r_ptr = sym_addr;
242
            //*r_ptr = sym_addr;
-
 
243
 
241
            break;
244
            break;
242
 
245
 
243
        case R_PPC_ADDR32:
246
        case R_PPC_ADDR32:
244
            kputint(0xb);
247
            kputint(0xb);
245
            sym_idx = ELF32_R_SYM(r_info);
248
            sym_idx = ELF32_R_SYM(r_info);
Line 250... Line 253...
250
 
253
 
251
            *r_ptr = a + sym_addr;
254
            *r_ptr = a + sym_addr;
252
            break;
255
            break;
253
           
256
           
254
        case R_PPC_RELATIVE:
257
        case R_PPC_RELATIVE:
255
//          kputint(0xc);
258
            kputint(0xc);
256
            *r_ptr = a + bias;
259
            *r_ptr = a + bias;
257
            break;
260
            break;
258
 
261
 
259
        case R_PPC_REL24:
262
        case R_PPC_REL24:
260
            kputint(0xd);
263
            kputint(0xd);
Line 282... Line 285...
282
    plt[7] = _lwz(11, __L(_plt_table), 11); // lwz r11, .PLTtable@l(r11)
285
    plt[7] = _lwz(11, __L(_plt_table), 11); // lwz r11, .PLTtable@l(r11)
283
    plt[8] = _mtctr(11);            // mtctr r11
286
    plt[8] = _mtctr(11);            // mtctr r11
284
    plt[9] = _bctr();
287
    plt[9] = _bctr();
285
 
288
 
286
/* .PLTi, i = 0..N-1 */
289
/* .PLTi, i = 0..N-1 */
287
    kputint(-4);
290
/*  kputint(-4);
288
    for (i = 0; i < plt_n; ++i) {
291
    for (i = 0; i < plt_n; ++i) {
289
        //_plt_table[i] == function address;
292
        //_plt_table[i] == function address;
290
        plt[18+i] = _b(_plt_call, &plt[18+i]);  // b .PLTcall
293
        plt[18+i] = _b(_plt_call, &plt[18+i]);  // b .PLTcall
291
    }
294
    }
292
 
295
*/
293
    kputint(-5);
296
    kputint(-5);
294
    kputint(_plt_table[0]);
297
    kputint(_plt_table[0]);
295
    }
298
    }
296
 
299
 
-
 
300
    kputint(-6);
297
    /* This will come in handy */
301
    /* This will come in handy */
298
    runtime_env.rtld_dynamic = dynamic;
302
    runtime_env.rtld_dynamic = dynamic;
299
    runtime_env.rtld.bias = bias;
303
    runtime_env.rtld.bias = bias;
300
 
304
 
301
//  volatile int ff=1;
305
//  volatile int ff=1;
302
//  while(ff);
306
//  while(ff);
-
 
307
    kputint(-7);
303
    test_func();
308
    test_func();
304
    kputint(0x42);
309
    kputint(0x42);
-
 
310
    kputint(test_var);
-
 
311
//  while(1);
305
//  while(1);
312
//  while(1);
306
    /* Init libc and run rtld main */
313
    /* Init libc and run rtld main */
307
    kputint(0x22);
314
    kputint(0x22);
308
    __main();
315
    __main();
309
 
316