|
Packit Service |
82fcde |
/* Startup code compliant to the 64 bit S/390 ELF ABI.
|
|
Packit Service |
82fcde |
Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
In addition to the permissions in the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License, the Free Software Foundation gives you unlimited
|
|
Packit Service |
82fcde |
permission to link the compiled version of this file with other
|
|
Packit Service |
82fcde |
programs, and to distribute those programs without any restriction
|
|
Packit Service |
82fcde |
coming from the use of this file. (The GNU Lesser General Public
|
|
Packit Service |
82fcde |
License restrictions do apply in other respects; for example, they
|
|
Packit Service |
82fcde |
cover modification of the file, and distribution when not linked
|
|
Packit Service |
82fcde |
into another program.)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
Note that people who make modified versions of this file are not
|
|
Packit Service |
82fcde |
obligated to grant this special exception for their modified
|
|
Packit Service |
82fcde |
versions; it is their choice whether to do so. The GNU Lesser
|
|
Packit Service |
82fcde |
General Public License gives permission to release a modified
|
|
Packit Service |
82fcde |
version without this exception; this exception also makes it
|
|
Packit Service |
82fcde |
possible to release a modified version which carries forward this
|
|
Packit Service |
82fcde |
exception.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <sysdep.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/*
|
|
Packit Service |
82fcde |
This is the canonical entry point, usually the first thing in the text
|
|
Packit Service |
82fcde |
segment. Most registers' values are unspecified, except for:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
%r14 Contains a function pointer to be registered with `atexit'.
|
|
Packit Service |
82fcde |
This is how the dynamic linker arranges to have DT_FINI
|
|
Packit Service |
82fcde |
functions called for shared libraries that have been loaded
|
|
Packit Service |
82fcde |
before this code runs.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
%r15 The stack contains the arguments and environment:
|
|
Packit Service |
82fcde |
0(%r15) argc
|
|
Packit Service |
82fcde |
8(%r15) argv[0]
|
|
Packit Service |
82fcde |
...
|
|
Packit Service |
82fcde |
(8*argc)(%r15) NULL
|
|
Packit Service |
82fcde |
(8*(argc+1))(%r15) envp[0]
|
|
Packit Service |
82fcde |
...
|
|
Packit Service |
82fcde |
NULL
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.text
|
|
Packit Service |
82fcde |
.globl _start
|
|
Packit Service |
82fcde |
.type _start,@function
|
|
Packit Service |
82fcde |
_start:
|
|
Packit Service |
82fcde |
cfi_startproc
|
|
Packit Service |
82fcde |
/* Mark r14 as undefined in order to stop unwinding here! */
|
|
Packit Service |
82fcde |
cfi_undefined (r14)
|
|
Packit Service |
82fcde |
/* Load argc and argv from stack. */
|
|
Packit Service |
82fcde |
la %r4,8(%r15) # get argv
|
|
Packit Service |
82fcde |
lg %r3,0(%r15) # get argc
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Align the stack to a double word boundary. */
|
|
Packit Service |
82fcde |
lghi %r0,-16
|
|
Packit Service |
82fcde |
ngr %r15,%r0
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Setup a stack frame and a parameter area. */
|
|
Packit Service |
82fcde |
aghi %r15,-176 # make room on stack
|
|
Packit Service |
82fcde |
xc 0(8,%r15),0(%r15) # clear back-chain
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Set up arguments for __libc_start_main:
|
|
Packit Service |
82fcde |
main, argc, argv, envp, _init, _fini, rtld_fini, stack_end
|
|
Packit Service |
82fcde |
Note that envp will be determined later in __libc_start_main.
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
|
|
Packit Service |
82fcde |
la %r7,160(%r15)
|
|
Packit Service |
82fcde |
larl %r6,__libc_csu_fini # load pointer to __libc_csu_fini
|
|
Packit Service |
82fcde |
larl %r5,__libc_csu_init # load pointer to __libc_csu_init
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Ok, now branch to the libc main routine. */
|
|
Packit Service |
82fcde |
#ifdef PIC
|
|
Packit Service |
82fcde |
larl %r2,main@GOTENT # load pointer to main
|
|
Packit Service |
82fcde |
lg %r2,0(%r2)
|
|
Packit Service |
82fcde |
brasl %r14,__libc_start_main@plt
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
larl %r2,main # load pointer to main
|
|
Packit Service |
82fcde |
brasl %r14,__libc_start_main
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Crash if __libc_start_main returns. */
|
|
Packit Service |
82fcde |
.word 0
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
cfi_endproc
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Define a symbol for the first piece of initialized data. */
|
|
Packit Service |
82fcde |
.data
|
|
Packit Service |
82fcde |
.globl __data_start
|
|
Packit Service |
82fcde |
__data_start:
|
|
Packit Service |
82fcde |
.long 0
|
|
Packit Service |
82fcde |
.weak data_start
|
|
Packit Service |
82fcde |
data_start = __data_start
|