|
Packit Service |
82fcde |
/* Special .init and .fini section support for Nios II.
|
|
Packit Service |
82fcde |
Copyright (C) 2012-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 |
#include <libc-symbols.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 |
.align 2
|
|
Packit Service |
82fcde |
.global _init
|
|
Packit Service |
82fcde |
.hidden _init
|
|
Packit Service |
82fcde |
.type _init, @function
|
|
Packit Service |
82fcde |
_init:
|
|
Packit Service |
82fcde |
addi sp, sp, -8
|
|
Packit Service |
82fcde |
stw r22, 0(sp)
|
|
Packit Service |
82fcde |
nextpc r22
|
|
Packit Service |
82fcde |
1:
|
|
Packit Service |
82fcde |
movhi r8, %hiadj(_gp_got - 1b)
|
|
Packit Service |
82fcde |
addi r8, r8, %lo(_gp_got - 1b)
|
|
Packit Service |
82fcde |
add r22, r22, r8
|
|
Packit Service |
82fcde |
stw ra, 4(sp)
|
|
Packit Service |
82fcde |
#if PREINIT_FUNCTION_WEAK
|
|
Packit Service |
82fcde |
movhi r2, %got_hiadj(PREINIT_FUNCTION)
|
|
Packit Service |
82fcde |
addi r2, r2, %got_lo(PREINIT_FUNCTION)
|
|
Packit Service |
82fcde |
add r2, r2, r22
|
|
Packit Service |
82fcde |
ldw r2, 0(r2)
|
|
Packit Service |
82fcde |
beq r2, zero, .L5
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
movhi r2, %call_hiadj(PREINIT_FUNCTION)
|
|
Packit Service |
82fcde |
addi r2, r2, %call_lo(PREINIT_FUNCTION)
|
|
Packit Service |
82fcde |
add r2, r2, r22
|
|
Packit Service |
82fcde |
ldw r2, 0(r2)
|
|
Packit Service |
82fcde |
callr r2
|
|
Packit Service |
82fcde |
.L5:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.section .fini,"ax",@progbits
|
|
Packit Service |
82fcde |
.align 2
|
|
Packit Service |
82fcde |
.global _fini
|
|
Packit Service |
82fcde |
.hidden _fini
|
|
Packit Service |
82fcde |
.type _fini, @function
|
|
Packit Service |
82fcde |
_fini:
|
|
Packit Service |
82fcde |
addi sp, sp, -8
|
|
Packit Service |
82fcde |
stw r22, 0(sp)
|
|
Packit Service |
82fcde |
nextpc r22
|
|
Packit Service |
82fcde |
1:
|
|
Packit Service |
82fcde |
movhi r8, %hiadj(_gp_got - 1b)
|
|
Packit Service |
82fcde |
addi r8, r8, %lo(_gp_got - 1b)
|
|
Packit Service |
82fcde |
stw ra, 4(sp)
|
|
Packit Service |
82fcde |
add r22, r22, r8
|