Subversion Repositories HelenOS

Rev

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

Rev 2968 Rev 2969
Line 38... Line 38...
38
#include <unistd.h>
38
#include <unistd.h>
39
#include <fcntl.h>
39
#include <fcntl.h>
40
 
40
 
41
#include <rtld.h>
41
#include <rtld.h>
42
#include <dynamic.h>
42
#include <dynamic.h>
-
 
43
#include <pcb.h>
43
#include "../../app/iloader/pcb.h"
44
#include <elf_load.h>
44
 
45
 
45
static void kputint(unsigned i)
46
static void kputint(unsigned i)
46
{
47
{
47
    unsigned dummy;
48
    unsigned dummy;
48
    asm volatile (
49
    asm volatile (
Line 52... Line 53...
52
        : "d" (i) /* input */
53
        : "d" (i) /* input */
53
        : "%eax","%ecx" /* all scratch registers clobbered */
54
        : "%eax","%ecx" /* all scratch registers clobbered */
54
    );
55
    );
55
}
56
}
56
 
57
 
57
int z = 42;
-
 
58
 
-
 
59
void _putint(int i);
-
 
60
 
-
 
61
void test_func(void);
-
 
62
void test_func(void)
-
 
63
{
-
 
64
    int fd, rc;
-
 
65
    char buf[5];
-
 
66
 
-
 
67
    printf("Hello, world! (from rtld)\n");
-
 
68
 
-
 
69
    fd = open("/tetris", O_RDONLY);
-
 
70
    if (fd < 0) { printf("fd<0 ("); _putint(fd); printf(")\n"); }
-
 
71
    fd = 0;
-
 
72
 
-
 
73
    rc = read(fd, &buf, 4);
-
 
74
    //printf(" ->%d\n", rc);
-
 
75
    buf[4]='\0';
-
 
76
    printf(buf);
-
 
77
    getchar();
-
 
78
 
-
 
79
    printf("x\n");
-
 
80
    while(1);
-
 
81
}
-
 
82
 
-
 
83
 
-
 
84
void _rtld_main(void)
58
void _rtld_main(void)
85
{
59
{
86
//  test_func();
-
 
87
 
-
 
88
    pcb_t *pcb;
60
    pcb_t *pcb;
89
    static dyn_info_t dyn_info;
61
    static dyn_info_t dyn_info;
-
 
62
    elf_info_t lib_info;
-
 
63
    int rc;
90
 
64
 
91
    printf("Hello, world! (from rtld)\n");
65
    printf("Hello, world! (from rtld)\n");
92
    getchar();
66
    getchar();
93
    printf("Run program..\n");
-
 
94
 
67
 
-
 
68
    printf("Parse .dynamic section\n");
95
    pcb = (pcb_t *)PCB_ADDRESS;
69
    pcb = (pcb_t *)PCB_ADDRESS;
96
    dynamic_parse(pcb->dynamic, 0, &dyn_info);
70
    dynamic_parse(pcb->dynamic, 0, &dyn_info);
-
 
71
 
-
 
72
    printf("Program requested library '%s'\n", dyn_info.needed);
-
 
73
   
-
 
74
    rc = elf_load_file("/libtest.so.0", &lib_info);
-
 
75
    if (rc < 0) {
-
 
76
        printf("failed to load library\n");
-
 
77
        return;
-
 
78
    }
-
 
79
 
-
 
80
    printf("Run program..\n");
97
    pcb->entry();
81
    pcb->entry();
98
}
82
}
99
 
83
 
100
/** @}
84
/** @}
101
 */
85
 */