diff options
Diffstat (limited to 'sysdeps/sparc/sparc64/elf')
-rw-r--r-- | sysdeps/sparc/sparc64/elf/Dist | 4 | ||||
-rw-r--r-- | sysdeps/sparc/sparc64/elf/Makefile | 10 | ||||
-rw-r--r-- | sysdeps/sparc/sparc64/elf/crtbegin.S | 69 | ||||
-rw-r--r-- | sysdeps/sparc/sparc64/elf/crtbeginS.S | 1 | ||||
-rw-r--r-- | sysdeps/sparc/sparc64/elf/crtend.S | 70 | ||||
-rw-r--r-- | sysdeps/sparc/sparc64/elf/crtendS.S | 1 | ||||
-rw-r--r-- | sysdeps/sparc/sparc64/elf/start.S | 93 |
7 files changed, 248 insertions, 0 deletions
diff --git a/sysdeps/sparc/sparc64/elf/Dist b/sysdeps/sparc/sparc64/elf/Dist new file mode 100644 index 0000000000..d9338c8fd6 --- /dev/null +++ b/sysdeps/sparc/sparc64/elf/Dist @@ -0,0 +1,4 @@ +crtbegin.S +crtbeginS.S +crtend.S +crtendS.S diff --git a/sysdeps/sparc/sparc64/elf/Makefile b/sysdeps/sparc/sparc64/elf/Makefile new file mode 100644 index 0000000000..1b38355b38 --- /dev/null +++ b/sysdeps/sparc/sparc64/elf/Makefile @@ -0,0 +1,10 @@ +# The assembler on SPARC needs the -fPIC flag even when it's assembler code. +ASFLAGS-.so = -fPIC + +ifeq ($(subdir), csu) +extra-objs += crtbegin.o crtend.o crtbeginS.o crtendS.o +install-lib += crtbegin.o crtend.o crtbeginS.o crtendS.o + +CPPFLAGS-crtbeginS.S = -fPIC -DPIC +CPPFLAGS-crtendS.S = -fPIC -DPIC +endif diff --git a/sysdeps/sparc/sparc64/elf/crtbegin.S b/sysdeps/sparc/sparc64/elf/crtbegin.S new file mode 100644 index 0000000000..318e7a6a3f --- /dev/null +++ b/sysdeps/sparc/sparc64/elf/crtbegin.S @@ -0,0 +1,69 @@ +/* Destructor cleanup code for elf64-sparc + Copyright (C) 1997 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 + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +.section ".ctors",#alloc,#write + + .align 8 +__CTOR_LIST__: + .xword -1 + +.section ".dtors",#alloc,#write + + .align 8 +__DTOR_LIST__: + .xword -1 + +.section ".fini",#alloc,#execinstr + + call __do_global_dtors_aux + nop + +.text + + .align 4 + .type __do_global_dtors_aux,#function +__do_global_dtors_aux: + save %sp,-160,%sp + +#ifdef PIC +1: call 11f + sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7 +11: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7 + add %l7, %o7, %l7 + sethi %hi(__DTOR_LIST__), %l0 + or %l0, %lo(__DTOR_LIST__), %l0 + ldx [%l7+%l0], %l0 +#else + sethi %hi(__DTOR_LIST__), %l0 + or %l0, %lo(__DTOR_LIST__), %l0 + add %l0, %g4, %l0 +#endif + + ba 3f + ldx [%l0+8], %l1 +2: jmpl %l1, %o7 + ldx [%l0+8], %l1 +3: brnz,pt %l1, 2b + add %l0, 8, %l0 + + ret + restore + + .size __do_global_dtors_aux,.-__do_global_dtors_aux diff --git a/sysdeps/sparc/sparc64/elf/crtbeginS.S b/sysdeps/sparc/sparc64/elf/crtbeginS.S new file mode 100644 index 0000000000..7db4bc590e --- /dev/null +++ b/sysdeps/sparc/sparc64/elf/crtbeginS.S @@ -0,0 +1 @@ +#include "crtbegin.S" diff --git a/sysdeps/sparc/sparc64/elf/crtend.S b/sysdeps/sparc/sparc64/elf/crtend.S new file mode 100644 index 0000000000..7a5c067b07 --- /dev/null +++ b/sysdeps/sparc/sparc64/elf/crtend.S @@ -0,0 +1,70 @@ +/* Constructor startup code for elf64-sparc + Copyright (C) 1997 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 + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +.section ".ctors",#alloc,#write + + .align 8 +__CTOR_END__: + .xword 0 + +.section ".dtors",#alloc,#write + + .align 8 +__DTOR_END__: + .xword 0 + +.section ".init",#alloc,#execinstr + + call __do_global_ctors_aux + nop + +.text + + .align 4 + .type __do_global_ctors_aux,#function +__do_global_ctors_aux: + save %sp,-160,%sp + +#ifdef PIC +1: call 11f + sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7 +11: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7 + add %l7, %o7, %l7 + sethi %hi(__CTOR_END__), %l0 + or %l0, %lo(__CTOR_END__), %l0 + ldx [%l7+%l0], %l0 +#else + sethi %hi(__CTOR_END__), %l0 + or %l0, %lo(__CTOR_END__), %l0 + add %l0, %g4, %l0 +#endif + + ba 3f + ldx [%l0+8], %l1 +2: jmpl %l1, %o7 + ldx [%l0+8], %l1 +3: addcc %l1, 1, %g0 + bnz,pt %xcc, 2b + add %l0, 8, %l0 + + ret + restore + + .size __do_global_ctors_aux,.-__do_global_ctors_aux diff --git a/sysdeps/sparc/sparc64/elf/crtendS.S b/sysdeps/sparc/sparc64/elf/crtendS.S new file mode 100644 index 0000000000..56532f567d --- /dev/null +++ b/sysdeps/sparc/sparc64/elf/crtendS.S @@ -0,0 +1 @@ +#include "crtend.S" diff --git a/sysdeps/sparc/sparc64/elf/start.S b/sysdeps/sparc/sparc64/elf/start.S new file mode 100644 index 0000000000..73f42367ee --- /dev/null +++ b/sysdeps/sparc/sparc64/elf/start.S @@ -0,0 +1,93 @@ +/* Startup code for elf64-sparc + Copyright (C) 1997 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 + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sysdep.h> + + + .section ".text" + .align 4 + .global _start + .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 + nop + + /* Die very horribly if exit returns. */ + illtrap 0 + + .size _start,.-_start |