5 ! - both 32bit pointer and 64bit pointer environments (at compile time)
6 ! - an imposed stack bias (of 2047) (at run time)
7 ! - medium/low and medium/anywhere code models (at run time)
11 ! bottom of stack (higher memory address)
13 ! text of environment strings
14 ! text of argument strings
15 ! envp[envc] = 0 (4/8 bytes)
18 ! argv[argc] = 0 (4/8 bytes)
22 ! register save area (64 bits by 16 registers = 128 bytes)
27 ! It is the responsibility of the o/s to set this up.
28 ! We handle both a 0 and 2047 value for the stack bias.
30 ! Medium/Anywhere code model support:
32 ! In this model %g4 points to the start of the data segment.
33 ! The text segment can go anywhere, but %g4 points to the *data* segment.
34 ! It is up to the compiler/linker to get this right.
36 ! Since this model is statically linked the start of the data segment
37 ! is known at link time. Eg:
39 ! sethi %hh(data_start), %g1
40 ! sethi %lm(data_start), %g4
41 ! or %g1, %hm(data_start), %g1
42 ! or %g4, %lo(data_start), %g4
46 ! FIXME: For now we just assume 0.
48 ! FIXME: if %g1 contains a non-zero value, atexit() should be invoked
51 #include <sys/syscallasm.h>
55 GLOBAL (ASM_PRIVATE_SYMBOL (start))
56 ASM_PRIVATE_SYMBOL (start):
59 ! We use %g4 even if the code model is Medium/Low (simplifies the code).
61 clr %g4 ! Medium/Anywhere base reg
63 ! If there is a stack bias in effect, account for it in %g5. Then always
64 ! add %g5 to stack references below. This way the code can be used with
65 ! or without an imposed bias.
73 #if TARGET_PTR_SIZE == 32
74 ! FIXME: We apparently assume here that there is no reserved word.
75 ! This is probably correct, but try to verify it.
76 ld [%sp + 0x80], %o0 ! argc
77 add %sp, 0x84, %o1 ! argv
80 #else /* TARGET_PTR_SIZE == 64 */
81 ld [%sp + 0x8c], %o0 ! argc.lo
82 add %sp, 0x90, %o1 ! argv
86 add %o1, %o2, %o2 ! envp
87 sethi %hi (ASM_SYMBOL (environ)), %o3
88 or %o3, %lo (ASM_SYMBOL (environ)), %o3
89 #if TARGET_PTR_SIZE == 32
91 #else /* TARGET_PTR_SIZE == 64 */
95 ! Restore any stack bias before we call main() ...
99 GLOBAL (ASM_SYMBOL (main))
100 call ASM_SYMBOL (main)
102 ! FIXME: Not sure if this is needed anymore.
103 #if TARGET_PTR_SIZE == 32
104 sub %sp, 0x20, %sp ! room to push args
105 #else /* TARGET_PTR_SIZE == 64 */
106 sub %sp, 0x30, %sp ! room to push args
109 GLOBAL (ASM_SYMBOL (exit))
110 call ASM_SYMBOL (exit)
113 GLOBAL (ASM_SYMBOL (_exit))
114 call ASM_SYMBOL (_exit)
118 ta SYSCALL_TRAP ! in case user redefines __exit
120 ! If all the above methods fail to terminate the program, try an illegal insn.
121 ! If that does not work, the o/s is hosed more than we are.