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 finitfp_();
+ − 375 #endif
+ − 376 /* On 68000, _start pushes a6 onto stack */
+ − 377 start1 ();
+ − 378 }
+ − 379 #endif /* not ISI68k */
+ − 380 #endif /* m68000 */
+ − 381 #endif /* m68k */
+ − 382
+ − 383 #if defined(m68k) || defined(m68000)
+ − 384 /* ignore takes care of skipping the a6 value pushed in start. */
+ − 385 static
+ − 386 #if defined(m68k)
+ − 387 start1 (argc, xargv)
+ − 388 #else
+ − 389 start1 (ignore, argc, xargv)
+ − 390 #endif
+ − 391 int argc;
+ − 392 char *xargv;
+ − 393 {
+ − 394 char **argv = &xargv;
+ − 395 environ = argv + argc + 1;
+ − 396
+ − 397 if ((char *)environ == xargv)
+ − 398 environ--;
+ − 399 #ifdef sun_68881
+ − 400 asm(" jsr f68881_used");
+ − 401 #endif
+ − 402 #ifdef sun_fpa
+ − 403 asm(" jsr ffpa_used");
+ − 404 #endif
+ − 405 #ifdef sun_soft
+ − 406 asm(" jsr start_float");
+ − 407 #endif
+ − 408 exit (main (argc, argv, environ));
+ − 409 }
+ − 410
+ − 411 #endif /* m68k or m68000 */
+ − 412
+ − 413 #endif /* not CRT0_DUMMIES */
+ − 414
+ − 415 #ifdef hp9000s300
+ − 416 int argc_value;
+ − 417 char **argv_value;
+ − 418 #ifdef OLD_HP_ASSEMBLER
+ − 419 asm(" text");
+ − 420 asm(" globl __start");
+ − 421 asm(" globl _exit");
+ − 422 asm(" globl _main");
+ − 423 asm("__start");
+ − 424 asm(" dc.l 0");
+ − 425 asm(" subq.w #0x1,d0");
+ − 426 asm(" move.w d0,float_soft");
+ − 427 asm(" move.l 0x4(a7),d0");
+ − 428 asm(" beq.s skip_1");
+ − 429 asm(" move.l d0,a0");
+ − 430 asm(" clr.l -0x4(a0)");
+ − 431 asm("skip_1");
+ − 432 asm(" move.l a7,a0");
+ − 433 asm(" subq.l #0x8,a7");
+ − 434 asm(" move.l (a0),(a7)");
+ − 435 asm(" move.l (a0),_argc_value");
+ − 436 asm(" addq.l #0x4,a0");
+ − 437 asm(" move.l a0,0x4(a7)");
+ − 438 asm(" move.l a0,_argv_value");
+ − 439 asm("incr_loop");
+ − 440 asm(" tst.l (a0)+");
+ − 441 asm(" bne.s incr_loop");
+ − 442 asm(" move.l 0x4(a7),a1");
+ − 443 asm(" cmp.l (a1),a0");
+ − 444 asm(" blt.s skip_2");
+ − 445 asm(" subq.l #0x4,a0");
+ − 446 asm("skip_2");
+ − 447 asm(" move.l a0,0x8(a7)");
+ − 448 asm(" move.l a0,_environ");
+ − 449 asm(" jsr _main");
+ − 450 asm(" addq.l #0x8,a7");
+ − 451 asm(" move.l d0,-(a7)");
+ − 452 asm(" jsr _exit");
+ − 453 asm(" move.w #0x1,d0");
+ − 454 asm(" trap #0x0");
+ − 455 asm(" comm float_soft,4");
+ − 456 /* float_soft is allocated in this way because C would
+ − 457 put an underscore character in its name otherwise. */
+ − 458
+ − 459 #else /* new hp assembler */
+ − 460
+ − 461 asm(" text");
+ − 462 asm(" global float_loc");
+ − 463 asm(" set float_loc,0xFFFFB000");
+ − 464 asm(" global fpa_loc");
+ − 465 asm(" set fpa_loc,0xfff08000");
+ − 466 asm(" global __start");
+ − 467 asm(" global _exit");
+ − 468 asm(" global _main");
+ − 469 asm("__start:");
+ − 470 asm(" byte 0,0,0,0");
+ − 471 asm(" subq.w &1,%d0");
+ − 472 asm(" mov.w %d0,float_soft");
+ − 473 asm(" mov.w %d1,flag_68881");
+ − 474 #ifndef HPUX_68010
+ − 475 asm(" beq.b skip_float");
+ − 476 asm(" fmov.l &0x7400,%fpcr");
+ − 477 /* asm(" fmov.l &0x7480,%fpcr"); */
+ − 478 #endif /* HPUX_68010 */
+ − 479 asm("skip_float:");
+ − 480 asm(" mov.l %a0,%d0");
+ − 481 asm(" add.l %d0,%d0");
+ − 482 asm(" subx.w %d1,%d1");
+ − 483 asm(" mov.w %d1,flag_68010");
+ − 484 asm(" add.l %d0,%d0");
+ − 485 asm(" subx.w %d1,%d1");
+ − 486 asm(" mov.w %d1,flag_fpa");
+ − 487 asm(" tst.l %d2");
+ − 488 asm(" ble.b skip_3");
+ − 489 asm(" lsl flag_68881");
+ − 490 asm(" lsl flag_fpa");
+ − 491 asm("skip_3:");
+ − 492 asm(" mov.l 4(%a7),%d0");
+ − 493 asm(" beq.b skip_1");
+ − 494 asm(" mov.l %d0,%a0");
+ − 495 asm(" clr.l -4(%a0)");
+ − 496 asm("skip_1:");
+ − 497 asm(" mov.l %a7,%a0");
+ − 498 asm(" subq.l &8,%a7");
+ − 499 asm(" mov.l (%a0),(%a7)");
+ − 500 asm(" mov.l (%a0),_argc_value");
+ − 501 asm(" addq.l &4,%a0");
+ − 502 asm(" mov.l %a0,4(%a7)");
+ − 503 asm(" mov.l %a0,_argv_value");
+ − 504 asm("incr_loop:");
+ − 505 asm(" tst.l (%a0)+");
+ − 506 asm(" bne.b incr_loop");
+ − 507 asm(" mov.l 4(%a7),%a1");
+ − 508 asm(" cmp.l %a0,(%a1)");
+ − 509 asm(" blt.b skip_2");
+ − 510 asm(" subq.l &4,%a0");
+ − 511 asm("skip_2:");
+ − 512 asm(" mov.l %a0,8(%a7)");
+ − 513 asm(" mov.l %a0,_environ");
+ − 514 asm(" jsr _main");
+ − 515 asm(" addq.l &8,%a7");
+ − 516 asm(" mov.l %d0,-(%a7)");
+ − 517 asm(" jsr _exit");
+ − 518 asm(" mov.w &1,%d0");
+ − 519 asm(" trap &0");
+ − 520 asm(" comm float_soft, 4");
+ − 521 asm(" comm flag_68881, 4");
+ − 522 asm(" comm flag_68010, 4");
+ − 523 asm(" comm flag_68040, 4");
+ − 524 asm(" comm flag_fpa, 4");
+ − 525
+ − 526 #endif /* new hp assembler */
+ − 527 #endif /* hp9000s300 */
+ − 528
+ − 529 #ifdef GOULD
+ − 530
+ − 531 /* startup code has to be in near text rather
+ − 532 than fartext as allocated by the C compiler. */
+ − 533 asm(" .text");
+ − 534 asm(" .align 2");
+ − 535 asm(" .globl __start");
+ − 536 asm(" .text");
+ − 537 asm("__start:");
+ − 538 /* setup base register b1 (function base). */
+ − 539 asm(" .using b1,.");
+ − 540 asm(" tpcbr b1");
+ − 541 /* setup base registers b3 through b7 (data references). */
+ − 542 asm(" file basevals,b3");
+ − 543 /* setup base register b2 (stack pointer); it should be
+ − 544 aligned on a 8-word boundary; but because it is pointing
+ − 545 to argc, its value should be remembered (in r5). */
+ − 546 asm(" movw b2,r4");
+ − 547 asm(" movw b2,r5");
+ − 548 asm(" andw #~0x1f,r4");
+ − 549 asm(" movw r4,b2");
+ − 550 /* allocate stack frame to do some work. */
+ − 551 asm(" subea 16w,b2");
+ − 552 /* initialize signal catching for UTX/32 1.2; this is
+ − 553 necessary to make restart from saved image work. */
+ − 554 asm(" movea sigcatch,r1");
+ − 555 asm(" movw r1,8w[b2]");
+ − 556 asm(" svc #1,#150");
+ − 557 /* setup address of argc for start1. */
+ − 558 asm(" movw r5,8w[b2]");
+ − 559 asm(" func #1,_start1");
+ − 560 asm(" halt");
+ − 561 /* space for ld to store base register initial values. */
+ − 562 asm(" .align 5");
+ − 563 asm("basevals:");
+ − 564 asm(" .word __base3,__base4,__base5,__base6,__base7");
+ − 565
+ − 566 static
+ − 567 start1 (xargc)
+ − 568 int *xargc;
+ − 569 {
+ − 570 int argc;
+ − 571 char **argv;
+ − 572
+ − 573 argc = *xargc;
+ − 574 argv = (char **)(xargc) + 1;
+ − 575 environ = argv + argc + 1;
+ − 576
+ − 577 if (environ == argv)
+ − 578 environ--;
+ − 579 exit (main (argc, argv, environ));
+ − 580
+ − 581 }
+ − 582
+ − 583 #endif /* GOULD */
+ − 584
+ − 585 #ifdef elxsi
+ − 586 #include <elxsi/argvcache.h>
+ − 587
+ − 588 extern char **environ;
+ − 589 extern int errno;
+ − 590 extern void _init_doscan(), _init_iob();
+ − 591 extern char end[];
+ − 592 char *_init_brk = end;
+ − 593
+ − 594 _start()
+ − 595 {
+ − 596 environ = exec_cache.ac_envp;
+ − 597 brk (_init_brk);
+ − 598 errno = 0;
+ − 599 _init_doscan ();
+ − 600 _init_iob ();
+ − 601 _exit (exit (main (exec_cache.ac_argc,
+ − 602 exec_cache.ac_argv,
+ − 603 exec_cache.ac_envp)));
+ − 604 }
+ − 605 #endif /* elxsi */
+ − 606
+ − 607
+ − 608 #ifdef sparc
+ − 609 #ifdef no_toplevel_asm
+ − 610 static no_toplevel_asm_wrapper() {
+ − 611 #ifdef USG5_4
+ − 612 asm (".pushsection \".text\"");
+ − 613 #endif /* USG5_4 */
+ − 614 #endif /* no_toplevel_asm */
+ − 615 #ifdef USG5_4
+ − 616 asm (".global _start");
+ − 617 asm (".text");
+ − 618 asm ("_start:");
+ − 619 asm (" mov 0, %fp");
+ − 620 asm (" ld [%sp + 64], %o0");
+ − 621 asm (" add %sp, 68, %o1");
+ − 622 asm (" sll %o0, 2, %o2");
+ − 623 asm (" add %o2, 4, %o2");
+ − 624 asm (" add %o1, %o2, %o2");
+ − 625 asm (" sethi %hi(_environ), %o3");
+ − 626 asm (" st %o2, [%o3+%lo(_environ)]");
+ − 627 asm (" andn %sp, 7, %sp");
+ − 628 asm (" call main");
+ − 629 asm (" sub %sp, 24, %sp");
+ − 630 asm (" call _exit");
+ − 631 asm (" nop");
+ − 632 #else
+ − 633 asm (".global __start");
+ − 634 asm (".text");
+ − 635 asm ("__start:");
+ − 636 asm (" mov 0, %fp");
+ − 637 asm (" ld [%sp + 64], %o0");
+ − 638 asm (" add %sp, 68, %o1");
+ − 639 asm (" sll %o0, 2, %o2");
+ − 640 asm (" add %o2, 4, %o2");
+ − 641 asm (" add %o1, %o2, %o2");
+ − 642 asm (" sethi %hi(_environ), %o3");
+ − 643 asm (" st %o2, [%o3+%lo(_environ)]");
+ − 644 asm (" andn %sp, 7, %sp");
+ − 645 asm (" call _main");
+ − 646 asm (" sub %sp, 24, %sp");
+ − 647 asm (" call __exit");
+ − 648 asm (" nop");
+ − 649 #endif /* USG5_4 */
+ − 650 #ifdef no_toplevel_asm
+ − 651 #ifdef USG5_4
+ − 652 asm (".popsection");
+ − 653 #endif /* USG5_4 */
+ − 654 } /* no_toplevel_asm_wrapper() */
+ − 655 #endif /* no_toplevel_asm */
+ − 656 #endif /* sparc */
+ − 657
+ − 658 #if __FreeBSD__ == 2
+ − 659 char *__progname;
+ − 660 #endif
+ − 661 #ifdef __bsdi__
+ − 662 #include <sys/param.h> /* for version number */
+ − 663 #if defined(_BSDI_VERSION) && (_BSDI_VERSION >= 199501)
+ − 664 char *__progname;
+ − 665 #endif
+ − 666 #endif /* __bsdi__ */