Subversion Repositories Kolibri OS

Rev

Rev 3805 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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 <newlib.h>
  16. #include <stdint.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <stdio.h>
  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 _pei386_runtime_relocator (void){};
  42.  
  43. void  __attribute__((noreturn))
  44. __crt_startup (void)
  45. {
  46.     struct   app_hdr *header;
  47.     void    *img;
  48.     void __attribute__((noreturn)) (*entry)(void *img);
  49.  
  50. //    _pei386_runtime_relocator();
  51.  
  52.     img = load_libc();
  53.  
  54.     if(img == NULL)
  55.     {
  56.         asm ("int $0x40" ::"a"(-1));
  57.     };
  58.  
  59.     entry = get_entry_point(img);
  60.     entry(img);
  61. }
  62.  
  63.  
  64.  
  65.