Rev 4349 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | /* |
2 | * crt1.c |
||
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. |
||
5 | * No warranty is given; refer to the file DISCLAIMER within the package. |
||
6 | * |
||
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. |
||
9 | * |
||
10 | */ |
||
11 | |||
12 | /* Hide the declaration of _fmode with dllimport attribute in stdlib.h to |
||
13 | avoid problems with older GCC. */ |
||
14 | |||
15 | #include |
||
16 | #include |
||
17 | #include |
||
18 | #include |
||
19 | #include |
||
20 | |||
4866 | Serge | 21 | /* |
4349 | Serge | 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 | } |
||
4866 | Serge | 35 | */ |
4349 | Serge | 36 | |
37 | void *load_libc(); |
||
4866 | Serge | 38 | //void __main (){}; |
4349 | Serge | 39 | |
40 | void* get_entry_point(void *raw); |
||
41 | |||
42 | void _pei386_runtime_relocator (void){}; |
||
43 | |||
44 | void __attribute__((noreturn)) |
||
45 | __crt_startup (void) |
||
46 | { |
||
47 | struct app_hdr *header; |
||
48 | void *img; |
||
49 | void __attribute__((noreturn)) (*entry)(void *img); |
||
50 | |||
51 | // _pei386_runtime_relocator(); |
||
52 | |||
53 | img = load_libc(); |
||
54 | |||
55 | if(img == NULL) |
||
56 | { |
||
57 | asm ("int $0x40" ::"a"(-1)); |
||
58 | }; |
||
59 | |||
60 | entry = get_entry_point(img); |
||
61 | entry(img); |
||
62 | } |
||
63 |