Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3805 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
 
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
void *load_libc();
37
void __main (){};
38
 
39
void* get_entry_point(void *raw);
40
 
41
void  __attribute__((noreturn))
42
__crt_startup (void)
43
{
44
    struct   app_hdr *header;
45
    void    *img;
46
    void __attribute__((noreturn)) (*entry)(void *img);
47
 
48
    img = load_libc();
49
 
50
    if(img == NULL)
51
    {
52
        asm("int3");
53
        asm ("int $0x40" ::"a"(-1));
54
    };
55
 
56
    entry = get_entry_point(img);
57
    entry(img);
58
}
59