diff options
author | Richard Henderson <rth@redhat.com> | 1998-04-06 17:40:58 +0000 |
---|---|---|
committer | Richard Henderson <rth@redhat.com> | 1998-04-06 17:40:58 +0000 |
commit | a55400166da3b4713ea9258be7ee739bdbd2d607 (patch) | |
tree | a76e856fa728c047fe54f3259238ed8a91b46035 /sysdeps/sparc/sparc64/elf | |
parent | deb2f929b59710d946e0a32dc3f49e4f0d4ed25d (diff) | |
download | glibc-a55400166da3b4713ea9258be7ee739bdbd2d607.tar.gz glibc-a55400166da3b4713ea9258be7ee739bdbd2d607.tar.xz glibc-a55400166da3b4713ea9258be7ee739bdbd2d607.zip |
* sysdeps/sparc/sparc32/elf.S: Rewrite for __libc_start_main. * sysdeps/sparc/sparc64/elf.S: Likewise.
* sysdeps/sparc/sparc32/elf.S: Rewrite for __libc_start_main. * sysdeps/sparc/sparc64/elf.S: Likewise. 1998-04-06 Richard Henderson <rth@cygnus.com>
Diffstat (limited to 'sysdeps/sparc/sparc64/elf')
-rw-r--r-- | sysdeps/sparc/sparc64/elf/start.S | 86 |
1 files changed, 33 insertions, 53 deletions
diff --git a/sysdeps/sparc/sparc64/elf/start.S b/sysdeps/sparc/sparc64/elf/start.S index 73f42367ee..140cd366e5 100644 --- a/sysdeps/sparc/sparc64/elf/start.S +++ b/sysdeps/sparc/sparc64/elf/start.S @@ -1,5 +1,5 @@ /* Startup code for elf64-sparc - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997. The GNU C Library is free software; you can redistribute it and/or @@ -26,68 +26,48 @@ .type _start,#function _start: - /* First order of business is to load %g4 with our base address. */ - sethi %uhi(_start), %g4 - or %g4, %ulo(_start), %g4 - sllx %g4, 32, %g4 - /* Terminate the stack frame, and reserve space for functions to drop their arguments. */ mov %g0, %fp sub %sp, 6*8, %sp - /* Save %g1. When starting a binary via the dynamic linker, %g1 - contains the address of the shared library termination function, - which we will register below with atexit() to be called by exit(). - If we are statically linked, this will be NULL. */ - - /* Do essential libc initialization (sp points to argc, argv, and envp) */ - call __libc_init_first - mov %g1, %l0 - - /* Now that we have the proper stack frame, register library termination - function, if there is any: */ - - brz,pn %l0, 1f - nop - call atexit - mov %l0, %o0 -1: - /* Extract the arguments and environment as encoded on the stack. The argument info starts after one register window (16 words) past the SP, plus the bias we added, plus the magic v9 STACK_BIAS. */ - ldx [%sp+STACK_BIAS+22*8], %o0 - add %sp, STACK_BIAS+23*8, %o1 - sllx %o0, 3, %o2 - add %o2, %o1, %o2 - sethi %hi(__environ), %g2 - add %o2, 8, %o2 - add %g2, %g4, %g2 - stx %o2, [%g2+%lo(__environ)] - - mov %o0, %l0 /* tuck them away */ - mov %o1, %l1 - - /* Call _init, the entry point to our own .init section. */ - call _init - mov %o2, %l2 - - /* Register our .fini section with atexit. */ - sethi %hi(_fini), %o0 - add %o0, %g4, %o0 - call atexit - add %o0, %lo(_fini), %o0 - - /* Call the user's main and exit with its return value. */ - mov %l0, %o0 - mov %l1, %o1 - call main - mov %l2, %o2 - call exit + ldx [%sp+STACK_BIAS+22*8], %o1 + add %sp, STACK_BIAS+23*8, %o2 + + /* Load the addresses of the user entry points. */ + sethi %uhi(main), %o0 + sethi %uhi(_init), %o3 + sethi %uhi(_fini), %o4 + or %o0, %ulo(main), %o0 + or %o3, %ulo(_init), %o3 + or %o4, %ulo(_fini), %o4 + sethi %hi(main), %i0 + sethi %hi(_init), %i3 + sethi %hi(_fini), %i4 + sllx %o0, 32, %o0 + or %i0, %lo(main), %i0 + sllx %o3, 32, %o3 + or %i3, %lo(_init), %i3 + sllx %o4, 32, %o4 + or %i4, %lo(_fini), %i4 + or %o0, %i0, %o0 + or %o3, %i3, %o3 + or %o4, %i4, %o4 + + /* When starting a binary via the dynamic linker, %g1 contains the + address of the shared library termination function, which will be + registered with atexit(). If we are statically linked, this will + be NULL. */ + mov %g1, %o5 + + /* Let libc do the rest of the initialization, and call main. */ + call __libc_start_main nop /* Die very horribly if exit returns. */ illtrap 0 - .size _start,.-_start + .size _start, .-_start |