Rev 2962 | Rev 2968 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2962 | Rev 2964 | ||
---|---|---|---|
Line 43... | Line 43... | ||
43 | #include "elf.h" |
43 | #include "elf.h" |
44 | #include "elf_load.h" |
44 | #include "elf_load.h" |
45 | 45 | ||
46 | int main(int argc, char *argv[]) |
46 | int main(int argc, char *argv[]) |
47 | { |
47 | { |
48 | elf_header_t prog_header; |
48 | elf_info_t prog_info; |
49 | elf_header_t interp_header; |
49 | elf_info_t interp_info; |
50 | char *file_name; |
50 | char *file_name; |
51 | int rc; |
51 | int rc; |
52 | 52 | ||
53 | printf("This is loader\n"); |
53 | printf("This is loader\n"); |
54 | getchar(); |
54 | getchar(); |
55 | 55 | ||
56 | printf("Load program\n"); |
56 | printf("Load program\n"); |
57 | 57 | ||
58 | rc = elf_load_file("/tetris", &prog_header); |
58 | rc = elf_load_file("/tetris", &prog_info); |
59 | if (rc < 0) { |
59 | if (rc < 0) { |
60 | printf("failed to load program\n"); |
60 | printf("failed to load program\n"); |
61 | return 1; |
61 | return 1; |
62 | } |
62 | } |
63 | 63 | ||
64 | printf("Create PCB\n"); |
64 | printf("Create PCB\n"); |
65 | if (elf_create_pcb(&prog_header) < 0) return 1; |
65 | if (elf_create_pcb(&prog_info) < 0) return 1; |
66 | 66 | ||
67 | printf("Load dynamic linker\n"); |
67 | printf("Load dynamic linker\n"); |
68 | file_name = "/rtld.so"; |
68 | file_name = "/rtld.so"; |
69 | printf("open and read '%s'...\n", file_name); |
69 | printf("open and read '%s'...\n", file_name); |
70 | rc = elf_load_file(file_name, &interp_header); |
70 | rc = elf_load_file(file_name, &interp_info); |
71 | if (rc < 0) { |
71 | if (rc < 0) { |
72 | printf("failed to load dynamic linker\n"); |
72 | printf("failed to load dynamic linker\n"); |
73 | return 1; |
73 | return 1; |
74 | } |
74 | } |
75 | 75 | ||
76 | printf("run dynamic linker\n"); |
76 | printf("run dynamic linker\n"); |
77 | elf_run(&interp_header); |
77 | elf_run(&interp_info); |
78 | 78 | ||
79 | /* not reached */ |
79 | /* not reached */ |
80 | return 0; |
80 | return 0; |
81 | } |
81 | } |
82 | 82 |