Rev 4874 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4874 | Rev 5963 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * crt1.c |
2 | * crt1.c |
3 | * This file has no copyright assigned and is placed in the Public Domain. |
3 | * This file has no copyright assigned and is placed in the Public Domain. |
4 | * This file is a part of the mingw-runtime package. |
4 | * This file is a part of the mingw-runtime package. |
5 | * No warranty is given; refer to the file DISCLAIMER within the package. |
5 | * No warranty is given; refer to the file DISCLAIMER within the package. |
6 | * |
6 | * |
7 | * Source code for the startup proceedures used by all programs. This code |
7 | * Source code for the startup proceedures used by all programs. This code |
8 | * is compiled to make crt1.o, which should be located in the library path. |
8 | * is compiled to make crt1.o, which should be located in the library path. |
9 | * |
9 | * |
10 | */ |
10 | */ |
11 | 11 | ||
12 | /* Hide the declaration of _fmode with dllimport attribute in stdlib.h to |
12 | /* Hide the declaration of _fmode with dllimport attribute in stdlib.h to |
13 | avoid problems with older GCC. */ |
13 | avoid problems with older GCC. */ |
14 | 14 | ||
15 | #include |
15 | #include |
16 | #include |
16 | #include |
17 | #include |
17 | #include |
18 | #include |
18 | #include |
19 | #include |
19 | #include |
20 | - | ||
21 | /* |
- | |
22 | typedef void (*ctp)(); |
- | |
23 | static void __do_global_ctors () |
- | |
24 | { |
- | |
25 | extern int __CTOR_LIST__; |
- | |
26 | int *c = &__CTOR_LIST__; |
- | |
27 | c++; |
- | |
28 | while (*c) |
- | |
29 | { |
- | |
30 | ctp d = (ctp)*c; |
- | |
31 | (d)(); |
- | |
32 | c++; |
- | |
33 | } |
- | |
34 | } |
- | |
35 | */ |
- | |
36 | 20 | ||
37 | void *load_libc(); |
- | |
38 | //void __main (){}; |
- | |
39 | 21 | void *load_libc(); |
|
40 | void* get_entry_point(void *raw); |
- | |
41 | 22 | void* get_entry_point(void *raw); |
|
42 | void _pei386_runtime_relocator (void){}; |
23 | |
43 | 24 | ||
44 | void __attribute__((noreturn)) |
25 | void __attribute__((noreturn)) |
45 | __crt_startup (void) |
26 | __crt_startup (void) |
46 | { |
27 | { |
47 | struct app_hdr *header; |
28 | struct app_hdr *header; |
48 | void *img; |
29 | void *img; |
49 | void __attribute__((noreturn)) (*entry)(void *img); |
30 | void __attribute__((noreturn)) (*entry)(void *img); |
50 | - | ||
51 | // _pei386_runtime_relocator(); |
- | |
52 | 31 | ||
53 | img = load_libc(); |
32 | img = load_libc(); |
54 | 33 | ||
55 | if(img == NULL) |
34 | if(img == NULL) |
56 | { |
35 | { |
57 | asm ("int $0x40" ::"a"(-1)); |
36 | asm ("int $0x40" ::"a"(-1)); |
58 | }; |
37 | }; |
59 | 38 | ||
60 | entry = get_entry_point(img); |
39 | entry = get_entry_point(img); |
61 | entry(img); |
40 | entry(img); |
62 | } |
41 | } |