* added compilers lcc and bcc (linux86)
[mascara-docs.git] / compilers / linux86-0.16.17 / libc / crt0.c
blob819d92f19b1406808e39a50a4dbef8c0236f02dd
1 /* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
2 * This file is part of the Linux-8086 C library and is distributed
3 * under the GNU Library General Public License.
4 */
6 #if defined(__AS386_16__) || defined(__AS386_32__)
7 #define CRT0_OK
8 /*
9 * Change of aim here, to allow easy alteration for generation of COM files
10 * this code has been moved into libc. This means only the linker needs to
11 * to be told to fetch a different libc the crt0 is unaltered.
13 * This also allows us to deal with __FIRST_ARG_IN_AX__ and __CALLER_SAVES__
14 * in the same way.
17 #asm
18 .text
19 entry startup ! Crt0 startup
20 startup:
21 br ___cstartup
22 export no_op
23 no_op: ! Generic no operation call
24 ret
26 .ascii __LIBC_VER__ ! Version id.
28 loc 1 ! Segment 1 is where the pointers to the autostart
29 ! functions are stored.
30 #if !__AS386_32__
31 ZP_safety:
32 .word 0 ! But first some zeros to avoid null pointer writes.
33 .word 0
34 .word 0
35 .word 0
36 #endif
37 export auto_start
38 auto_start:
40 #endasm
41 #endif /* __AS386_16__ or __AS386_32__ */
43 #if defined(__GNUC__) && defined(__i386__)
44 #ifdef __ELF__
45 #define CRT0_OK
46 __asm__(".globl _start\n_start:");
47 __asm__("jmp __cstartup");
48 __asm__(".globl __no_op\n__no_op:");
49 __asm__("ret");
50 #else
52 #error This library is for ELF only, sorry.
53 __asm__(".globl startup\nstartup:");
54 __asm__("jmp ___cstartup");
55 __asm__(".globl no_op\nno_op:");
56 __asm__("ret");
57 #endif
59 #endif /* defined(__GNUC__) && defined(__i386__) */
61 #ifndef CRT0_OK
62 #error You are not going to get far without crt0.o!
63 #endif