From: Richard Henderson Date: Mon, 6 Apr 1998 17:40:58 +0000 (+0000) Subject: * sysdeps/sparc/sparc32/elf.S: Rewrite for __libc_start_main. * sysdeps/sparc/sparc64... X-Git-Tag: upstream/2.30~28614 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a55400166da3b4713ea9258be7ee739bdbd2d607;p=external%2Fglibc.git * 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 --- diff --git a/ChangeLog b/ChangeLog index 9727fdd..93fc41c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 1998-04-06 Richard Henderson + * sysdeps/sparc/sparc32/elf.S: Rewrite for __libc_start_main. + * sysdeps/sparc/sparc64/elf.S: Likewise. + +1998-04-06 Richard Henderson + * sysdeps/unix/sysv/linux/sparc/sparc32/socket.S: Revert 03-01 change, as the buffer is not properly aligned. Reported by Juan Cespedes . diff --git a/sysdeps/sparc/sparc32/elf/start.S b/sysdeps/sparc/sparc32/elf/start.S index 24715e6..d45e0ce 100644 --- a/sysdeps/sparc/sparc32/elf/start.S +++ b/sysdeps/sparc/sparc32/elf/start.S @@ -1,5 +1,5 @@ /* Startup code for elf32-sparc - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. Contributed by Richard Henderson , 1997. The GNU C Library is free software; you can redistribute it and/or @@ -31,56 +31,30 @@ _start: mov %g0, %fp sub %sp, 6*4, %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: */ - - cmp %l0, 0 - beq 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. */ - ld [%sp+22*4], %o0 - add %sp, 23*4, %o1 - sll %o0, 2, %o2 - add %o2, %o1, %o2 - sethi %hi(__environ), %g2 - add %o2, 4, %o2 - st %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 - 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 + ld [%sp+22*4], %o1 + add %sp, 23*4, %o2 + + /* Load the addresses of the user entry points. */ + sethi %hi(main), %o0 + sethi %hi(_init), %o3 + sethi %hi(_fini), %o4 + or %o0, %lo(main), %o0 + or %o3, %lo(_init), %o3 + or %o4, %lo(_fini), %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. */ unimp - .size _start,.-_start + .size _start, .-_start diff --git a/sysdeps/sparc/sparc64/elf/start.S b/sysdeps/sparc/sparc64/elf/start.S index 73f4236..140cd36 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 , 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