Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1906 | serge | 1 | |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | #include |
||
7 | #include |
||
8 | #include |
||
9 | #include |
||
10 | |||
11 | |||
12 | { |
||
13 | char banner[8]; |
||
14 | int version; |
||
15 | int start; |
||
16 | int iend; |
||
17 | int memsize; |
||
18 | int stacktop; |
||
19 | char *cmdline; |
||
20 | char *path; |
||
21 | }; |
||
22 | |||
23 | |||
24 | char **_argv; |
||
25 | |||
26 | |||
27 | |||
28 | void* __fastcall create_image(void *raw); |
||
29 | int __fastcall link_image(void *img_base); |
||
30 | void* get_entry_point(void *raw); |
||
31 | int (*entry)(int, char **, char **); |
||
32 | |||
33 | |||
34 | |||
35 | |||
36 | |||
37 | |||
38 | |||
39 | __thread_startup (int (*entry)(void*), void *param, |
||
40 | void *stacklow, void *stackhigh) |
||
41 | { |
||
42 | int retval; |
||
43 | |||
44 | |||
45 | |||
46 | |||
47 | "movl %0, %%fs:4 \n\t" // use TLS |
||
48 | "movl %1, %%fs:8 \n\t" |
||
49 | ::"r"(stacklow), "r"(stackhigh)); |
||
50 | |||
51 | |||
52 | |||
53 | |||
54 | |||
55 | |||
56 | }; |
||
57 | |||
58 | |||
59 | { |
||
60 | return NULL; |
||
61 | } |
||
62 | |||
63 | |||
64 | int __appcwdlen; |
||
65 | char* __appenv; |
||
66 | int __appenv_size; |
||
67 | |||
68 | |||
69 | crt_startup (void *libc_base, void *obj_base, uint32_t *params) |
||
70 | { |
||
71 | struct app_hdr *header; |
||
72 | char *arg[2]; |
||
73 | |||
74 | |||
75 | char *p; |
||
76 | |||
77 | |||
78 | int retval = 0; |
||
79 | |||
80 | |||
81 | |||
82 | |||
83 | __initPOSIXHandles(); |
||
84 | __appenv = load_file("/sys/system.env", &__appenv_size); |
||
85 | |||
86 | |||
87 | |||
88 | |||
89 | |||
90 | |||
91 | goto done; |
||
92 | |||
93 | |||
94 | |||
95 | |||
96 | __appcwdlen = __appcwdlen > 1022 ? 1022 : __appcwdlen; |
||
97 | memcpy(__appcwd, header->path, __appcwdlen); |
||
98 | set_cwd(__appcwd); |
||
99 | |||
100 | |||
101 | len = strlen(header->path); |
||
102 | p = alloca(len+1); |
||
103 | memcpy(p, header->path, len); |
||
104 | p[len]=0; |
||
105 | |||
106 | |||
107 | #else |
||
108 | arg[0] = header->path; |
||
109 | #endif |
||
110 | |||
111 | |||
112 | |||
113 | |||
114 | { |
||
115 | #ifdef BRAVE_NEW_WORLD |
||
116 | len = strlen(header->cmdline); |
||
117 | if(len) |
||
118 | { |
||
119 | p = alloca(len+1); |
||
120 | memcpy(p, header->cmdline, len); |
||
121 | p[len]=0; |
||
122 | _argc = 2; |
||
123 | arg[1] = p; |
||
124 | }; |
||
125 | #else |
||
126 | _argc = 2; |
||
127 | arg[1] = header->cmdline; |
||
128 | #endif |
||
129 | }; |
||
130 | |||
131 | |||
132 | |||
133 | |||
134 | |||
135 | |||
136 | |||
137 | |||
138 | |||
139 | |||
140 | exit (retval); |
||
141 | } |
||
142 |