Subversion Repositories HelenOS

Rev

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

Rev 3004 Rev 3401
Line 34... Line 34...
34
 * @file
34
 * @file
35
 */
35
 */
36
 
36
 
37
#include <elf_dyn.h>
37
#include <elf_dyn.h>
38
#include <rtld.h>
38
#include <rtld.h>
39
#include <pcb.h>
39
#include <loader/pcb.h>
40
 
40
 
41
// for testing printf
41
// for testing printf
42
#include <stdio.h>
42
#include <stdio.h>
43
 
43
 
44
void __main(void);
44
void __main(pcb_t *pcb);
45
void __io_init(void);
45
//void __io_init(void);
46
void __exit(void);
46
void __exit(void);
47
 
47
 
48
static void kputint(unsigned i)
48
static void kputint(unsigned i)
49
{
49
{
50
    asm volatile (
50
    asm volatile (
Line 98... Line 98...
98
    kputint(-1);
98
    kputint(-1);
99
}
99
}
100
 
100
 
101
int test_var = 0x818283;
101
int test_var = 0x818283;
102
 
102
 
103
void __bootstrap(void);
103
void __bootstrap(pcb_t *pcb);
104
 
104
 
105
void __bootstrap(void)
105
void __bootstrap(pcb_t *pcb)
106
{
106
{
107
    unsigned bias;
107
    unsigned bias;
108
    uint32_t *plt;
108
    uint32_t *plt;
109
    elf_dyn_t *dynamic;
109
    elf_dyn_t *dynamic;
110
    void *dptr;
110
    void *dptr;
Line 120... Line 120...
120
   
120
   
121
    elf_symbol_t *sym_table;
121
    elf_symbol_t *sym_table;
122
    elf_rela_t *rel_table;
122
    elf_rela_t *rel_table;
123
    elf_rela_t *jmp_rel_table;
123
    elf_rela_t *jmp_rel_table;
124
    size_t jmp_rel_entries;
124
    size_t jmp_rel_entries;
125
    pcb_t *pcb;
-
 
126
    uint32_t a, res;
125
    uint32_t a, res;
127
    uint32_t *r_ptr;
126
    uint32_t *r_ptr;
128
    uint32_t *_plt_ent;
127
    uint32_t *_plt_ent;
129
 
128
 
130
    kputint(42);
129
    kputint(42);
131
    pcb = __pcb_get();
-
 
132
 
130
 
133
    /* The program loader (iloader) kindly provided us with these */
131
    /* The program loader (iloader) kindly provided us with these */
134
    dynamic = pcb->rtld_dynamic;
132
    dynamic = pcb->rtld_dynamic;
135
    bias = pcb->rtld_bias;
133
    bias = pcb->rtld_bias;
136
 
134
 
Line 310... Line 308...
310
    kputint(test_var);
308
    kputint(test_var);
311
//  while(1);
309
//  while(1);
312
//  while(1);
310
//  while(1);
313
    /* Init libc and run rtld main */
311
    /* Init libc and run rtld main */
314
    kputint(0x22);
312
    kputint(0x22);
315
    __main();
313
    __main(pcb);
316
 
314
 
317
    kputint(33);
315
//  kputint(33);
318
    __io_init();
316
//  __io_init();
319
    kputint(-1);
317
    kputint(-1);
320
    kputint(0x52);
318
    kputint(0x52);
321
//  printf("Hello, world! (from ppc rtld)\n");
319
//  printf("Hello, world! (from ppc rtld)\n");
322
    kputint(0x62);
320
    kputint(0x62);
323
//  while(1);
321
//  while(1);