428
|
1 /* C code startup routine.
|
|
2 Copyright (C) 1985, 1986, 1992, 1993 Free Software Foundation, Inc.
|
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* Synched up with: FSF 19.30. */
|
|
22
|
|
23
|
771
|
24 /* [[The standard Vax 4.2 Unix crt0.c cannot be used for Emacs
|
428
|
25 because it makes `environ' an initialized variable.
|
|
26 It is easiest to have a special crt0.c on all machines
|
771
|
27 though I don't know whether other machines actually need it.]]
|
|
28 This is insane! We DO NOT want to be doing this crap. */
|
428
|
29
|
|
30 /* On the vax and 68000, in BSD4.2 and USG5.2,
|
|
31 this is the data format on startup:
|
|
32 (vax) ap and fp are unpredictable as far as I know; don't use them.
|
|
33 sp -> word containing argc
|
|
34 word pointing to first arg string
|
|
35 [word pointing to next arg string]... 0 or more times
|
|
36 0
|
|
37 Optionally:
|
|
38 [word pointing to environment variable]... 1 or more times
|
|
39 ...
|
|
40 0
|
|
41 And always:
|
|
42 first arg string
|
|
43 [next arg string]... 0 or more times
|
|
44 */
|
|
45
|
|
46 /* On the 16000, at least in the one 4.2 system I know about,
|
|
47 the initial data format is
|
|
48 sp -> word containing argc
|
|
49 word containing argp
|
|
50 word pointing to first arg string, and so on as above
|
|
51 */
|
|
52
|
|
53 #ifdef emacs
|
|
54 #include <config.h>
|
|
55 #endif
|
|
56
|
|
57 #ifdef __GNUC__
|
|
58 #define asm __asm
|
|
59 #endif
|
|
60
|
|
61 /* Workaround for Sun cc 3.0, which doesn't handle asm's outside a fn. */
|
|
62 #if __SUNPRO_C >= 0x300
|
|
63 #define no_toplevel_asm
|
|
64 #endif
|
|
65
|
|
66 /* ******** WARNING ********
|
|
67 Do not insert any data definitions before data_start!
|
|
68 Since this is the first file linked, the address of the following
|
|
69 variable should correspond to the start of initialized data space.
|
|
70 On some systems this is a constant that is independent of the text
|
|
71 size for shared executables. On others, it is a function of the
|
|
72 text size. In short, this seems to be the most portable way to
|
|
73 discover the start of initialized data space dynamically at runtime,
|
|
74 for either shared or unshared executables, on either swapping or
|
|
75 virtual systems. It only requires that the linker allocate objects
|
|
76 in the order encountered, a reasonable model for most Unix systems.
|
|
77 Similarly, note that the address of _start() should be the start
|
|
78 of text space. Fred Fish, UniSoft Systems Inc. */
|
|
79
|
|
80 int data_start = 0;
|
|
81
|
|
82 #ifdef NEED_ERRNO
|
|
83 int errno;
|
|
84 #endif
|
|
85
|
|
86 #ifndef DONT_NEED_ENVIRON
|
|
87 char **environ;
|
|
88 #endif
|
|
89
|
|
90 #ifndef static
|
|
91 /* On systems where the static storage class is usable, this function
|
|
92 should be declared as static. Otherwise, the static keyword has
|
|
93 been defined to be something else, and code for those systems must
|
|
94 take care of this declaration appropriately. */
|
|
95 static start1 ();
|
|
96 #endif
|
|
97
|
|
98 #ifdef APOLLO
|
|
99 extern char *malloc(), *realloc(), *(*_libc_malloc) (), *(*_libc_realloc)();
|
|
100 extern void free(), (*_libc_free) (); extern int main();
|
|
101 std_$call void unix_$main();
|
|
102
|
|
103 _start()
|
|
104 {
|
|
105 _libc_malloc = malloc;
|
|
106 _libc_realloc = realloc;
|
|
107 _libc_free = free;
|
|
108 unix_$main(main); /* no return */
|
|
109 }
|
|
110 #endif /* APOLLO */
|
|
111
|
|
112 #if defined(orion) || defined(pyramid) || defined(celerity) || defined(ALLIANT) || defined(clipper) || defined(sps7)
|
|
113
|
|
114 #if defined(sps7) && defined(V3x)
|
|
115 asm(" section 10");
|
|
116 asm(" ds.b 0xb0");
|
|
117 #endif
|
|
118
|
|
119 #ifdef ALLIANT
|
|
120 /* _start must initialize _curbrk and _minbrk on the first startup;
|
|
121 when starting up after dumping, it must initialize them to what they were
|
|
122 before the dumping, since they are in the shared library and
|
|
123 are not dumped. See ADJUST_EXEC_HEADER in m-alliant.h. */
|
|
124 extern unsigned char *_curbrk, *_minbrk;
|
|
125 extern unsigned char end;
|
|
126 unsigned char *_setbrk = &end;
|
|
127 #ifdef ALLIANT_2800
|
|
128 unsigned char *_end = &end;
|
|
129 #endif
|
|
130 #endif
|
|
131
|
|
132 #ifndef DUMMIES
|
|
133 #define DUMMIES
|
|
134 #endif
|
|
135
|
|
136 _start (DUMMIES argc, argv, envp)
|
|
137 int argc;
|
|
138 char **argv, **envp;
|
|
139 {
|
|
140 #ifdef ALLIANT
|
|
141 #ifdef ALLIANT_2800
|
|
142 _curbrk = _end;
|
|
143 _minbrk = _end;
|
|
144 #else
|
|
145 _curbrk = _setbrk;
|
|
146 _minbrk = _setbrk;
|
|
147 #endif
|
|
148 #endif
|
|
149
|
|
150 environ = envp;
|
|
151
|
|
152 exit (main (argc, argv, envp));
|
|
153 }
|
|
154
|
|
155 #endif /* orion or pyramid or celerity or alliant or clipper */
|
|
156
|
|
157 #if defined (ns16000) && !defined (sequent) && !defined (UMAX) && !defined (CRT0_DUMMIES)
|
|
158
|
|
159 _start ()
|
|
160 {
|
|
161 /* On 16000, _start pushes fp onto stack */
|
|
162 start1 ();
|
|
163 }
|
|
164
|
|
165 /* ignore takes care of skipping the fp value pushed in start. */
|
|
166 static
|
|
167 start1 (ignore, argc, argv)
|
|
168 int ignore;
|
|
169 int argc;
|
|
170 char **argv;
|
|
171 {
|
|
172 environ = argv + argc + 1;
|
|
173
|
|
174 if (environ == *argv)
|
|
175 environ--;
|
|
176 exit (main (argc, argv, environ));
|
|
177 }
|
|
178 #endif /* ns16000, not sequent and not UMAX, and not the CRT0_DUMMIES method */
|
|
179
|
|
180 #ifdef UMAX
|
|
181 _start()
|
|
182 {
|
|
183 asm(" exit [] # undo enter");
|
|
184 asm(" .set exitsc,1");
|
|
185 asm(" .set sigcatchall,0x400");
|
|
186
|
|
187 asm(" .globl _exit");
|
|
188 asm(" .globl start");
|
|
189 asm(" .globl __start");
|
|
190 asm(" .globl _main");
|
|
191 asm(" .globl _environ");
|
|
192 asm(" .globl _sigvec");
|
|
193 asm(" .globl sigentry");
|
|
194
|
|
195 asm("start:");
|
|
196 asm(" br .xstart");
|
|
197 asm(" .org 0x20");
|
|
198 asm(" .double p_glbl,0,0xf00000,0");
|
|
199 asm(" .org 0x30");
|
|
200 asm(".xstart:");
|
|
201 asm(" adjspb $8");
|
|
202 asm(" movd 8(sp),0(sp) # argc");
|
|
203 asm(" addr 12(sp),r0");
|
|
204 asm(" movd r0,4(sp) # argv");
|
|
205 asm("L1:");
|
|
206 asm(" movd r0,r1");
|
|
207 asm(" addqd $4,r0");
|
|
208 asm(" cmpqd $0,0(r1) # null args term ?");
|
|
209 asm(" bne L1");
|
|
210 asm(" cmpd r0,0(4(sp)) # end of 'env' or 'argv' ?");
|
|
211 asm(" blt L2");
|
|
212 asm(" addqd $-4,r0 # envp's are in list");
|
|
213 asm("L2:");
|
|
214 asm(" movd r0,8(sp) # env");
|
|
215 asm(" movd r0,@_environ # indir is 0 if no env ; not 0 if env");
|
|
216 asm(" movqd $0,tos # setup intermediate signal handler");
|
|
217 asm(" addr @sv,tos");
|
|
218 asm(" movzwd $sigcatchall,tos");
|
|
219 asm(" jsr @_sigvec");
|
|
220 asm(" adjspb $-12");
|
|
221 asm(" jsr @_main");
|
|
222 asm(" adjspb $-12");
|
|
223 asm(" movd r0,tos");
|
|
224 asm(" jsr @_exit");
|
|
225 asm(" adjspb $-4");
|
|
226 asm(" addr @exitsc,r0");
|
|
227 asm(" svc");
|
|
228 asm(" .align 4 # sigvec arg");
|
|
229 asm("sv:");
|
|
230 asm(" .double sigentry");
|
|
231 asm(" .double 0");
|
|
232 asm(" .double 0");
|
|
233
|
|
234 asm(" .comm p_glbl,1");
|
|
235 }
|
|
236 #endif /* UMAX */
|
|
237
|
|
238 #ifdef CRT0_DUMMIES
|
|
239
|
|
240 /* Define symbol "start": here; some systems want that symbol. */
|
|
241 #ifdef DOT_GLOBAL_START
|
|
242 asm(" .text ");
|
|
243 asm(" .globl start ");
|
|
244 asm(" start: ");
|
|
245 #endif /* DOT_GLOBAL_START */
|
|
246
|
|
247 #ifdef NODOT_GLOBAL_START
|
|
248 asm(" text ");
|
|
249 asm(" global start ");
|
|
250 asm(" start: ");
|
|
251 #endif /* NODOT_GLOBAL_START */
|
|
252
|
|
253 #ifdef m68000
|
|
254
|
|
255 /* GCC 2.1, when optimization is turned off, seems to want to push a
|
|
256 word of garbage on the stack, which screws up the CRT0_DUMMIES
|
|
257 hack. So we hand-code _start in assembly language. */
|
|
258 asm(".text ");
|
|
259 #ifndef sony_news
|
|
260 asm(" .even ");
|
|
261 #else /* sony_news (not gas) */
|
|
262 + asm(" .align 2 ");
|
|
263 #endif /* sony_news (not gas) */
|
|
264 asm(".globl __start ");
|
|
265 asm("__start: ");
|
|
266 asm(" link a6,#0 ");
|
|
267 asm(" jbsr _start1 ");
|
|
268 asm(" unlk a6 ");
|
|
269 asm(" rts ");
|
|
270
|
|
271 #else /* not m68000 */
|
|
272
|
|
273 int
|
|
274 _start ()
|
|
275 {
|
|
276 /* On vax, nothing is pushed here */
|
|
277 /* On sequent, bogus fp is pushed here */
|
|
278 start1 ();
|
|
279 }
|
|
280
|
|
281 #endif /* possibly m68000 */
|
|
282
|
|
283 #ifdef __bsdi__ /* for version number */
|
|
284 #include <sys/param.h>
|
|
285 #endif
|
|
286 #if defined(_BSDI_VERSION) && (_BSDI_VERSION >= 199501)
|
|
287 char *__progname;
|
|
288 #endif
|
|
289 static int
|
|
290 start1 (CRT0_DUMMIES int argc, char *xargv)
|
|
291 {
|
|
292 char **argv = &xargv;
|
|
293 environ = argv + argc + 1;
|
|
294 #if defined(_BSDI_VERSION) && (_BSDI_VERSION >= 199501)
|
|
295 __progname = argv[0];
|
|
296 #endif
|
|
297
|
|
298 if ((char *)environ == xargv)
|
|
299 environ--;
|
|
300 exit (main (argc, argv, environ));
|
|
301
|
|
302 /* Refer to `start1' so GCC will not think it is never called
|
|
303 and optimize it out. */
|
|
304 (void) &start1;
|
|
305 }
|
|
306 #else /* not CRT0_DUMMIES */
|
|
307
|
|
308 /* "m68k" and "m68000" both stand for m68000 processors,
|
|
309 but with different program-entry conventions.
|
|
310 This is a kludge. Now that the CRT0_DUMMIES mechanism above exists,
|
|
311 most of these machines could use the vax code above
|
|
312 with some suitable definition of CRT0_DUMMIES.
|
|
313 Then the symbol m68k could be flushed.
|
|
314 But I don't want to risk breaking these machines
|
|
315 in a version 17 patch release, so that change is being put off. */
|
|
316
|
|
317 #ifdef m68k /* Can't do it all from C */
|
|
318 asm (" global _start");
|
|
319 asm (" text");
|
|
320 asm ("_start:");
|
|
321 #ifndef NU
|
|
322 #ifdef STRIDE
|
|
323 asm (" comm havefpu%,2");
|
|
324 #else /* m68k, not STRIDE */
|
|
325 asm (" comm splimit%,4");
|
|
326 #endif /* STRIDE */
|
|
327 asm (" global exit");
|
|
328 asm (" text");
|
|
329 #ifdef STRIDE
|
|
330 asm (" trap &3");
|
|
331 asm (" mov.w %d0,havefpu%");
|
|
332 #else /* m68k, not STRIDE */
|
|
333 asm (" mov.l %d0,splimit%");
|
|
334 #endif /* STRIDE */
|
|
335 #endif /* not NU */
|
|
336 asm (" jsr start1");
|
|
337 asm (" mov.l %d0,(%sp)");
|
|
338 asm (" jsr exit");
|
|
339 asm (" mov.l &1,%d0"); /* d0 = 1 => exit */
|
|
340 asm (" trap &0");
|
|
341 #else /* m68000, not m68k */
|
|
342
|
|
343 #ifdef m68000
|
|
344
|
|
345 #ifdef ISI68K
|
|
346 /* Added by ESM Sun May 24 12:44:02 1987 to get new ISI library to work */
|
|
347 /* Edited by Ray Mon May 15 15:59:56 EST 1989 so we can compile with gcc */
|
|
348 #if defined(BSD4_3) && !defined(__GNUC__)
|
|
349 static foo () {
|
|
350 #endif
|
|
351 asm (" .globl is68020");
|
|
352 asm ("is68020:");
|
|
353 #ifndef BSD4_3
|
|
354 asm (" .long 0x00000000");
|
|
355 asm (" .long 0xffffffff");
|
|
356 /* End of stuff added by ESM */
|
|
357 #endif
|
|
358 asm (" .text");
|
|
359 asm (" .globl __start");
|
|
360 asm ("__start:");
|
|
361 asm (" .word 0");
|
|
362 asm (" link a6,#0");
|
|
363 asm (" jbsr _start1");
|
|
364 asm (" unlk a6");
|
|
365 asm (" rts");
|
|
366 #if defined(BSD4_3) && !defined(__GNUC__)
|
|
367 }
|
|
368 #endif
|
|
369 #else /* not ISI68K */
|
|
370
|
|
371 _start ()
|
|
372 {
|
|
373 #ifdef sun
|
|
374 #ifdef LISP_FLOAT_TYPE
|
|
375 finitfp_();
|
|
376 #endif
|
|
377 #endif
|
|
378 /* On 68000, _start pushes a6 onto stack */
|
|
379 start1 ();
|
|
380 }
|
|
381 #endif /* not ISI68k */
|
|
382 #endif /* m68000 */
|
|
383 #endif /* m68k */
|
|
384
|
|
385 #if defined(m68k) || defined(m68000)
|
|
386 /* ignore takes care of skipping the a6 value pushed in start. */
|
|
387 static
|
|
388 #if defined(m68k)
|
|
389 start1 (argc, xargv)
|
|
390 #else
|
|
391 start1 (ignore, argc, xargv)
|
|
392 #endif
|
|
393 int argc;
|
|
394 char *xargv;
|
|
395 {
|
|
396 char **argv = &xargv;
|
|
397 environ = argv + argc + 1;
|
|
398
|
|
399 if ((char *)environ == xargv)
|
|
400 environ--;
|
|
401 #ifdef sun_68881
|
|
402 asm(" jsr f68881_used");
|
|
403 #endif
|
|
404 #ifdef sun_fpa
|
|
405 asm(" jsr ffpa_used");
|
|
406 #endif
|
|
407 #ifdef sun_soft
|
|
408 asm(" jsr start_float");
|
|
409 #endif
|
|
410 exit (main (argc, argv, environ));
|
|
411 }
|
|
412
|
|
413 #endif /* m68k or m68000 */
|
|
414
|
|
415 #endif /* not CRT0_DUMMIES */
|
|
416
|
|
417 #ifdef hp9000s300
|
|
418 int argc_value;
|
|
419 char **argv_value;
|
|
420 #ifdef OLD_HP_ASSEMBLER
|
|
421 asm(" text");
|
|
422 asm(" globl __start");
|
|
423 asm(" globl _exit");
|
|
424 asm(" globl _main");
|
|
425 asm("__start");
|
|
426 asm(" dc.l 0");
|
|
427 asm(" subq.w #0x1,d0");
|
|
428 asm(" move.w d0,float_soft");
|
|
429 asm(" move.l 0x4(a7),d0");
|
|
430 asm(" beq.s skip_1");
|
|
431 asm(" move.l d0,a0");
|
|
432 asm(" clr.l -0x4(a0)");
|
|
433 asm("skip_1");
|
|
434 asm(" move.l a7,a0");
|
|
435 asm(" subq.l #0x8,a7");
|
|
436 asm(" move.l (a0),(a7)");
|
|
437 asm(" move.l (a0),_argc_value");
|
|
438 asm(" addq.l #0x4,a0");
|
|
439 asm(" move.l a0,0x4(a7)");
|
|
440 asm(" move.l a0,_argv_value");
|
|
441 asm("incr_loop");
|
|
442 asm(" tst.l (a0)+");
|
|
443 asm(" bne.s incr_loop");
|
|
444 asm(" move.l 0x4(a7),a1");
|
|
445 asm(" cmp.l (a1),a0");
|
|
446 asm(" blt.s skip_2");
|
|
447 asm(" subq.l #0x4,a0");
|
|
448 asm("skip_2");
|
|
449 asm(" move.l a0,0x8(a7)");
|
|
450 asm(" move.l a0,_environ");
|
|
451 asm(" jsr _main");
|
|
452 asm(" addq.l #0x8,a7");
|
|
453 asm(" move.l d0,-(a7)");
|
|
454 asm(" jsr _exit");
|
|
455 asm(" move.w #0x1,d0");
|
|
456 asm(" trap #0x0");
|
|
457 asm(" comm float_soft,4");
|
|
458 /* float_soft is allocated in this way because C would
|
|
459 put an underscore character in its name otherwise. */
|
|
460
|
|
461 #else /* new hp assembler */
|
|
462
|
|
463 asm(" text");
|
|
464 asm(" global float_loc");
|
|
465 asm(" set float_loc,0xFFFFB000");
|
|
466 asm(" global fpa_loc");
|
|
467 asm(" set fpa_loc,0xfff08000");
|
|
468 asm(" global __start");
|
|
469 asm(" global _exit");
|
|
470 asm(" global _main");
|
|
471 asm("__start:");
|
|
472 asm(" byte 0,0,0,0");
|
|
473 asm(" subq.w &1,%d0");
|
|
474 asm(" mov.w %d0,float_soft");
|
|
475 asm(" mov.w %d1,flag_68881");
|
|
476 #ifndef HPUX_68010
|
|
477 asm(" beq.b skip_float");
|
|
478 asm(" fmov.l &0x7400,%fpcr");
|
|
479 /* asm(" fmov.l &0x7480,%fpcr"); */
|
|
480 #endif /* HPUX_68010 */
|
|
481 asm("skip_float:");
|
|
482 asm(" mov.l %a0,%d0");
|
|
483 asm(" add.l %d0,%d0");
|
|
484 asm(" subx.w %d1,%d1");
|
|
485 asm(" mov.w %d1,flag_68010");
|
|
486 asm(" add.l %d0,%d0");
|
|
487 asm(" subx.w %d1,%d1");
|
|
488 asm(" mov.w %d1,flag_fpa");
|
|
489 asm(" tst.l %d2");
|
|
490 asm(" ble.b skip_3");
|
|
491 asm(" lsl flag_68881");
|
|
492 asm(" lsl flag_fpa");
|
|
493 asm("skip_3:");
|
|
494 asm(" mov.l 4(%a7),%d0");
|
|
495 asm(" beq.b skip_1");
|
|
496 asm(" mov.l %d0,%a0");
|
|
497 asm(" clr.l -4(%a0)");
|
|
498 asm("skip_1:");
|
|
499 asm(" mov.l %a7,%a0");
|
|
500 asm(" subq.l &8,%a7");
|
|
501 asm(" mov.l (%a0),(%a7)");
|
|
502 asm(" mov.l (%a0),_argc_value");
|
|
503 asm(" addq.l &4,%a0");
|
|
504 asm(" mov.l %a0,4(%a7)");
|
|
505 asm(" mov.l %a0,_argv_value");
|
|
506 asm("incr_loop:");
|
|
507 asm(" tst.l (%a0)+");
|
|
508 asm(" bne.b incr_loop");
|
|
509 asm(" mov.l 4(%a7),%a1");
|
|
510 asm(" cmp.l %a0,(%a1)");
|
|
511 asm(" blt.b skip_2");
|
|
512 asm(" subq.l &4,%a0");
|
|
513 asm("skip_2:");
|
|
514 asm(" mov.l %a0,8(%a7)");
|
|
515 asm(" mov.l %a0,_environ");
|
|
516 asm(" jsr _main");
|
|
517 asm(" addq.l &8,%a7");
|
|
518 asm(" mov.l %d0,-(%a7)");
|
|
519 asm(" jsr _exit");
|
|
520 asm(" mov.w &1,%d0");
|
|
521 asm(" trap &0");
|
|
522 asm(" comm float_soft, 4");
|
|
523 asm(" comm flag_68881, 4");
|
|
524 asm(" comm flag_68010, 4");
|
|
525 asm(" comm flag_68040, 4");
|
|
526 asm(" comm flag_fpa, 4");
|
|
527
|
|
528 #endif /* new hp assembler */
|
|
529 #endif /* hp9000s300 */
|
|
530
|
|
531 #ifdef GOULD
|
|
532
|
|
533 /* startup code has to be in near text rather
|
|
534 than fartext as allocated by the C compiler. */
|
|
535 asm(" .text");
|
|
536 asm(" .align 2");
|
|
537 asm(" .globl __start");
|
|
538 asm(" .text");
|
|
539 asm("__start:");
|
|
540 /* setup base register b1 (function base). */
|
|
541 asm(" .using b1,.");
|
|
542 asm(" tpcbr b1");
|
|
543 /* setup base registers b3 through b7 (data references). */
|
|
544 asm(" file basevals,b3");
|
|
545 /* setup base register b2 (stack pointer); it should be
|
|
546 aligned on a 8-word boundary; but because it is pointing
|
|
547 to argc, its value should be remembered (in r5). */
|
|
548 asm(" movw b2,r4");
|
|
549 asm(" movw b2,r5");
|
|
550 asm(" andw #~0x1f,r4");
|
|
551 asm(" movw r4,b2");
|
|
552 /* allocate stack frame to do some work. */
|
|
553 asm(" subea 16w,b2");
|
|
554 /* initialize signal catching for UTX/32 1.2; this is
|
|
555 necessary to make restart from saved image work. */
|
|
556 asm(" movea sigcatch,r1");
|
|
557 asm(" movw r1,8w[b2]");
|
|
558 asm(" svc #1,#150");
|
|
559 /* setup address of argc for start1. */
|
|
560 asm(" movw r5,8w[b2]");
|
|
561 asm(" func #1,_start1");
|
|
562 asm(" halt");
|
|
563 /* space for ld to store base register initial values. */
|
|
564 asm(" .align 5");
|
|
565 asm("basevals:");
|
|
566 asm(" .word __base3,__base4,__base5,__base6,__base7");
|
|
567
|
|
568 static
|
|
569 start1 (xargc)
|
|
570 int *xargc;
|
|
571 {
|
|
572 int argc;
|
|
573 char **argv;
|
|
574
|
|
575 argc = *xargc;
|
|
576 argv = (char **)(xargc) + 1;
|
|
577 environ = argv + argc + 1;
|
|
578
|
|
579 if (environ == argv)
|
|
580 environ--;
|
|
581 exit (main (argc, argv, environ));
|
|
582
|
|
583 }
|
|
584
|
|
585 #endif /* GOULD */
|
|
586
|
|
587 #ifdef elxsi
|
|
588 #include <elxsi/argvcache.h>
|
|
589
|
|
590 extern char **environ;
|
|
591 extern int errno;
|
|
592 extern void _init_doscan(), _init_iob();
|
|
593 extern char end[];
|
|
594 char *_init_brk = end;
|
|
595
|
|
596 _start()
|
|
597 {
|
|
598 environ = exec_cache.ac_envp;
|
|
599 brk (_init_brk);
|
|
600 errno = 0;
|
|
601 _init_doscan ();
|
|
602 _init_iob ();
|
|
603 _exit (exit (main (exec_cache.ac_argc,
|
|
604 exec_cache.ac_argv,
|
|
605 exec_cache.ac_envp)));
|
|
606 }
|
|
607 #endif /* elxsi */
|
|
608
|
|
609
|
|
610 #ifdef sparc
|
|
611 #ifdef no_toplevel_asm
|
|
612 static no_toplevel_asm_wrapper() {
|
|
613 #ifdef USG5_4
|
|
614 asm (".pushsection \".text\"");
|
|
615 #endif /* USG5_4 */
|
|
616 #endif /* no_toplevel_asm */
|
|
617 #ifdef USG5_4
|
|
618 asm (".global _start");
|
|
619 asm (".text");
|
|
620 asm ("_start:");
|
|
621 asm (" mov 0, %fp");
|
|
622 asm (" ld [%sp + 64], %o0");
|
|
623 asm (" add %sp, 68, %o1");
|
|
624 asm (" sll %o0, 2, %o2");
|
|
625 asm (" add %o2, 4, %o2");
|
|
626 asm (" add %o1, %o2, %o2");
|
|
627 asm (" sethi %hi(_environ), %o3");
|
|
628 asm (" st %o2, [%o3+%lo(_environ)]");
|
|
629 asm (" andn %sp, 7, %sp");
|
|
630 asm (" call main");
|
|
631 asm (" sub %sp, 24, %sp");
|
|
632 asm (" call _exit");
|
|
633 asm (" nop");
|
|
634 #else
|
|
635 asm (".global __start");
|
|
636 asm (".text");
|
|
637 asm ("__start:");
|
|
638 asm (" mov 0, %fp");
|
|
639 asm (" ld [%sp + 64], %o0");
|
|
640 asm (" add %sp, 68, %o1");
|
|
641 asm (" sll %o0, 2, %o2");
|
|
642 asm (" add %o2, 4, %o2");
|
|
643 asm (" add %o1, %o2, %o2");
|
|
644 asm (" sethi %hi(_environ), %o3");
|
|
645 asm (" st %o2, [%o3+%lo(_environ)]");
|
|
646 asm (" andn %sp, 7, %sp");
|
|
647 asm (" call _main");
|
|
648 asm (" sub %sp, 24, %sp");
|
|
649 asm (" call __exit");
|
|
650 asm (" nop");
|
|
651 #endif /* USG5_4 */
|
|
652 #ifdef no_toplevel_asm
|
|
653 #ifdef USG5_4
|
|
654 asm (".popsection");
|
|
655 #endif /* USG5_4 */
|
|
656 } /* no_toplevel_asm_wrapper() */
|
|
657 #endif /* no_toplevel_asm */
|
|
658 #endif /* sparc */
|
|
659
|
|
660 #if __FreeBSD__ == 2
|
|
661 char *__progname;
|
|
662 #endif
|
|
663 #ifdef __bsdi__
|
|
664 #include <sys/param.h> /* for version number */
|
|
665 #if defined(_BSDI_VERSION) && (_BSDI_VERSION >= 199501)
|
|
666 char *__progname;
|
|
667 #endif
|
|
668 #endif /* __bsdi__ */
|