Rev 3004 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3004 | Rev 3400 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | */ |
32 | */ |
33 | /** |
33 | /** |
34 | * @file |
34 | * @file |
35 | */ |
35 | */ |
36 | 36 | ||
- | 37 | #include <loader/pcb.h> |
|
37 | #include <elf_dyn.h> |
38 | #include <elf_dyn.h> |
38 | #include <rtld.h> |
39 | #include <rtld.h> |
39 | #include <pcb.h> |
- | |
40 | 40 | ||
41 | void __main(void); |
41 | void __main(pcb_t *pcb); |
42 | void __io_init(void); |
42 | //void __io_init(void); |
43 | void __exit(void); |
43 | void __exit(void); |
44 | 44 | ||
45 | static void kputint(unsigned i) |
45 | static void kputint(unsigned i) |
46 | { |
46 | { |
47 | unsigned dummy; |
47 | unsigned dummy; |
48 | asm volatile ( |
48 | asm volatile ( |
49 | "movl $31, %%eax;" |
49 | "movl $32, %%eax;" |
50 | "int $0x30" |
50 | "int $0x30" |
51 | : "=d" (dummy) /* output - %edx clobbered */ |
51 | : "=d" (dummy) /* output - %edx clobbered */ |
52 | : "d" (i) /* input */ |
52 | : "d" (i) /* input */ |
53 | : "%eax","%ecx" /* all scratch registers clobbered */ |
53 | : "%eax","%ecx" /* all scratch registers clobbered */ |
54 | ); |
54 | ); |
55 | } |
55 | } |
56 | 56 | ||
57 | void __bootstrap(void) |
57 | void __bootstrap(pcb_t *pcb) |
58 | { |
58 | { |
59 | unsigned bias; |
59 | unsigned bias; |
60 | unsigned *got; |
60 | unsigned *got; |
61 | elf_dyn_t *dynamic; |
61 | elf_dyn_t *dynamic; |
62 | void *dptr; |
62 | void *dptr; |
Line 72... | Line 72... | ||
72 | 72 | ||
73 | elf_symbol_t *sym_table; |
73 | elf_symbol_t *sym_table; |
74 | elf_rel_t *rel_table; |
74 | elf_rel_t *rel_table; |
75 | elf_rel_t *jmp_rel_table; |
75 | elf_rel_t *jmp_rel_table; |
76 | size_t jmp_rel_entries; |
76 | size_t jmp_rel_entries; |
77 | pcb_t *pcb; |
- | |
78 | - | ||
79 | pcb = __pcb_get(); |
- | |
80 | 77 | ||
81 | /* The program loader (iloader) kindly provided us with these */ |
78 | /* The program loader kindly provided us with these */ |
82 | dynamic = pcb->rtld_dynamic; |
79 | dynamic = pcb->rtld_dynamic; |
83 | bias = pcb->rtld_bias; |
80 | bias = pcb->rtld_bias; |
84 | /* |
81 | /* |
85 | asm volatile ( |
82 | asm volatile ( |
86 | // Calculate the bias into %0 |
83 | // Calculate the bias into %0 |
Line 95... | Line 92... | ||
95 | " addl %0, %1;" // Add bias to compute run-time address |
92 | " addl %0, %1;" // Add bias to compute run-time address |
96 | 93 | ||
97 | : "=r" (bias), "=r" (dynamic) |
94 | : "=r" (bias), "=r" (dynamic) |
98 | ); |
95 | ); |
99 | */ |
96 | */ |
- | 97 | kputint(pcb); |
|
100 | kputint(bias); |
98 | kputint(bias); |
101 | kputint((unsigned)dynamic); |
99 | kputint((unsigned)dynamic); |
102 | 100 | ||
103 | /* parse DYNAMIC */ |
101 | /* parse DYNAMIC */ |
104 | got = 0; |
102 | got = 0; |
Line 126... | Line 124... | ||
126 | } |
124 | } |
127 | 125 | ||
128 | ++i; |
126 | ++i; |
129 | } |
127 | } |
130 | 128 | ||
131 | kputint(1); |
129 | // kputint(1); |
132 | kputint((unsigned)sym_table); |
130 | // kputint((unsigned)sym_table); |
133 | kputint((unsigned)rel_table); |
131 | // kputint((unsigned)rel_table); |
134 | kputint((unsigned)rel_entries); |
132 | // kputint((unsigned)rel_entries); |
135 | 133 | ||
136 | /* Now relocate all our dynsyms */ |
134 | /* Now relocate all our dynsyms */ |
137 | kputint(-1); |
135 | // kputint(-1); |
138 | 136 | ||
139 | for (i=0; i<rel_entries; i++) { |
137 | for (i=0; i<rel_entries; i++) { |
140 | kputint(i); |
138 | kputint(i); |
141 | r_offset = rel_table[i].r_offset; |
139 | r_offset = rel_table[i].r_offset; |
142 | r_info = rel_table[i].r_info; |
140 | r_info = rel_table[i].r_info; |
Line 219... | Line 217... | ||
219 | break; |
217 | break; |
220 | } |
218 | } |
221 | } |
219 | } |
222 | 220 | ||
223 | kputint(-1); |
221 | kputint(-1); |
- | 222 | kputint(0x42); |
|
224 | 223 | ||
225 | /* This will come in handy */ |
224 | /* This will come in handy */ |
- | 225 | __pcb = pcb; |
|
226 | runtime_env.rtld_dynamic = dynamic; |
226 | runtime_env.rtld_dynamic = dynamic; |
227 | runtime_env.rtld.bias = bias; |
227 | runtime_env.rtld.bias = bias; |
- | 228 | ||
- | 229 | kputint(0x43); |
|
228 | 230 | ||
229 | /* Init libc and run rtld main */ |
231 | /* Init libc and run rtld main */ |
230 | __main(); |
232 | __main(pcb); |
- | 233 | ||
- | 234 | kputint(0x44); |
|
231 | 235 | ||
232 | kputint(33); |
236 | // kputint(33); |
233 | __io_init(); |
237 | // __io_init(); |
234 | kputint(34); |
238 | kputint(34); |
235 | _rtld_main(); |
239 | _rtld_main(); |
236 | kputint(35); |
240 | kputint(35); |
237 | __exit(); |
241 | __exit(); |
238 | 242 |