Blame sysdeps/alpha/crti.S

Packit Service 82fcde
/* Special .init and .fini section support for Alpha.
Packit Service 82fcde
   Copyright (C) 2001-2018 Free Software Foundation, Inc.
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
/* crti.S puts a function prologue at the beginning of the .init and
Packit Service 82fcde
   .fini sections and defines global symbols for those addresses, so
Packit Service 82fcde
   they can be called as functions.  The symbols _init and _fini are
Packit Service 82fcde
   magic and cause the linker to emit DT_INIT and DT_FINI.
Packit Service 82fcde
Packit Service 82fcde
   This differs from what would be generated for ordinary code in that
Packit Service 82fcde
   we save and restore the GP within the function.  In order for linker
Packit Service 82fcde
   relaxation to work, the value in the GP register on exit from a function
Packit Service 82fcde
   must be valid for the function entry point.  Normally, a function is
Packit Service 82fcde
   contained within one object file and this is not an issue, provided
Packit Service 82fcde
   that the function reloads the gp after making any function calls.
Packit Service 82fcde
   However, _init and _fini are constructed from pieces of many object
Packit Service 82fcde
   files, all of which may have different GP values.  So we must reload
Packit Service 82fcde
   the GP value from crti.o in crtn.o.  */
Packit Service 82fcde
Packit Service 82fcde
#include <libc-symbols.h>
Packit Service 82fcde
#include <sysdep.h>
Packit Service 82fcde
Packit Service 82fcde
#ifndef PREINIT_FUNCTION
Packit Service 82fcde
# define PREINIT_FUNCTION __gmon_start__
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
#ifndef PREINIT_FUNCTION_WEAK
Packit Service 82fcde
# define PREINIT_FUNCTION_WEAK 1
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
#if PREINIT_FUNCTION_WEAK
Packit Service 82fcde
        weak_extern (PREINIT_FUNCTION)
Packit Service 82fcde
#else
Packit Service 82fcde
        .hidden PREINIT_FUNCTION
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
	.section .init, "ax", @progbits
Packit Service 82fcde
	.globl	_init
Packit Service 82fcde
	.hidden	_init
Packit Service 82fcde
	.type	_init, @function
Packit Service 82fcde
	.usepv	_init, std
Packit Service 82fcde
_init:
Packit Service 82fcde
	ldgp	$29, 0($27)
Packit Service 82fcde
	subq	$30, 16, $30
Packit Service 82fcde
#if PREINIT_FUNCTION_WEAK
Packit Service 82fcde
	lda	$27, PREINIT_FUNCTION
Packit Service 82fcde
#endif
Packit Service 82fcde
	stq	$26, 0($30)
Packit Service 82fcde
	stq	$29, 8($30)
Packit Service 82fcde
#if PREINIT_FUNCTION_WEAK
Packit Service 82fcde
	beq	$27, 1f
Packit Service 82fcde
	jsr	$26, ($27), PREINIT_FUNCTION
Packit Service 82fcde
	ldq	$29, 8($30)
Packit Service 82fcde
1:
Packit Service 82fcde
#else
Packit Service 82fcde
	bsr	$26, PREINIT_FUNCTION !samegp
Packit Service 82fcde
#endif
Packit Service 82fcde
	.p2align 3
Packit Service 82fcde
Packit Service 82fcde
	.section .fini, "ax", @progbits
Packit Service 82fcde
	.globl	_fini
Packit Service 82fcde
	.hidden	_fini
Packit Service 82fcde
	.type	_fini,@function
Packit Service 82fcde
	.usepv	_fini,std
Packit Service 82fcde
_fini:
Packit Service 82fcde
	ldgp	$29, 0($27)
Packit Service 82fcde
	subq	$30, 16, $30
Packit Service 82fcde
	stq	$26, 0($30)
Packit Service 82fcde
	stq	$29, 8($30)
Packit Service 82fcde
	.p2align 3