|
Packit Service |
82fcde |
/* Special .init and .fini section support for HPPA
|
|
Packit Service |
82fcde |
Copyright (C) 2000-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 |
#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 |
|
|
Packit Service |
82fcde |
/* If we have working .init_array support, we want to keep the .init
|
|
Packit Service |
82fcde |
section empty (apart from the mandatory prologue/epilogue. This
|
|
Packit Service |
82fcde |
ensures that the default unwind conventions (return-pointer in b0,
|
|
Packit Service |
82fcde |
frame state in ar.pfs, etc.) will do the Right Thing. To ensure
|
|
Packit Service |
82fcde |
an empty .init section, we register gmon_initializer() via the
|
|
Packit Service |
82fcde |
.init_array.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
--davidm 02/10/29 */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#if PREINIT_FUNCTION_WEAK
|
|
Packit Service |
82fcde |
/* This blob of assembly code is one simple C function:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static void
|
|
Packit Service |
82fcde |
__attribute__ ((used))
|
|
Packit Service |
82fcde |
gmon_initializer (void)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
extern void weak_function __gmon_start__ (void);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (__gmon_start__)
|
|
Packit Service |
82fcde |
(*__gmon_start__)();
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
In a final executable, PLABEL32 relocations for function pointers are
|
|
Packit Service |
82fcde |
resolved at link time. Typically, binutils/ld resolves __gmon_start__
|
|
Packit Service |
82fcde |
using an external shared library. __gmon_start__ is always called if
|
|
Packit Service |
82fcde |
it is found at link time. If __gmon_start__ is not found at runtime
|
|
Packit Service |
82fcde |
due to a library update, then the function pointer will point at a null
|
|
Packit Service |
82fcde |
function descriptor and calling it will cause a segmentation fault.
|
|
Packit Service |
82fcde |
So, we call __canonicalize_funcptr_for_compare to obtain the canonicalized
|
|
Packit Service |
82fcde |
address of __gmon_start__ and skip calling __gmon_start__ if it is zero.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
.type __canonicalize_funcptr_for_compare,@function
|
|
Packit Service |
82fcde |
.type $$dyncall,@function
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.section .data.rel.ro,"aw",@progbits
|
|
Packit Service |
82fcde |
.align 4
|
|
Packit Service |
82fcde |
.LC0:
|
|
Packit Service |
82fcde |
.type __gmon_start__,@function
|
|
Packit Service |
82fcde |
.word P%__gmon_start__
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.text
|
|
Packit Service |
82fcde |
.align 4
|
|
Packit Service |
82fcde |
.type gmon_initializer,@function
|
|
Packit Service |
82fcde |
gmon_initializer:
|
|
Packit Service |
82fcde |
.PROC
|
|
Packit Service |
82fcde |
.CALLINFO FRAME=64,CALLS,SAVE_RP,ENTRY_GR=4
|
|
Packit Service |
82fcde |
.ENTRY
|
|
Packit Service |
82fcde |
stw %r2,-20(%r30)
|
|
Packit Service |
82fcde |
stwm %r4,64(%r30)
|
|
Packit Service |
82fcde |
stw %r3,-60(%r30)
|
|
Packit Service |
82fcde |
addil LT'.LC0,%r19
|
|
Packit Service |
82fcde |
ldw RT'.LC0(%r1),%r28
|
|
Packit Service |
82fcde |
ldw 0(%r28),%r3
|
|
Packit Service |
82fcde |
comib,= 0,%r3,1f
|
|
Packit Service |
82fcde |
copy %r19,%r4
|
|
Packit Service |
82fcde |
stw %r19,-32(%r30)
|
|
Packit Service |
82fcde |
bl __canonicalize_funcptr_for_compare,%r2
|
|
Packit Service |
82fcde |
copy %r3,%r26
|
|
Packit Service |
82fcde |
comib,= 0,%r28,1f
|
|
Packit Service |
82fcde |
copy %r4,%r19
|
|
Packit Service |
82fcde |
copy %r3,%r22
|
|
Packit Service |
82fcde |
.CALL ARGW0=GR
|
|
Packit Service |
82fcde |
bl $$dyncall,%r31
|
|
Packit Service |
82fcde |
copy %r31,%r2
|
|
Packit Service |
82fcde |
1:
|
|
Packit Service |
82fcde |
ldw -84(%r30),%r2
|
|
Packit Service |
82fcde |
ldw -60(%r30),%r3
|
|
Packit Service |
82fcde |
bv %r0(%r2)
|
|
Packit Service |
82fcde |
ldwm -64(%r30),%r4
|
|
Packit Service |
82fcde |
.EXIT
|
|
Packit Service |
82fcde |
.PROCEND
|
|
Packit Service |
82fcde |
.size gmon_initializer, .-gmon_initializer
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# undef PREINIT_FUNCTION
|
|
Packit Service |
82fcde |
# define PREINIT_FUNCTION gmon_initializer
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.section .init_array, "aw"
|
|
Packit Service |
82fcde |
.word P% PREINIT_FUNCTION
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* _init prologue. */
|
|
Packit Service |
82fcde |
.section .init, "ax", %progbits
|
|
Packit Service |
82fcde |
.align 4
|
|
Packit Service |
82fcde |
.globl _init
|
|
Packit Service |
82fcde |
.hidden _init
|
|
Packit Service |
82fcde |
.type _init,@function
|
|
Packit Service |
82fcde |
_init:
|
|
Packit Service |
82fcde |
stw %rp,-20(%sp)
|
|
Packit Service |
82fcde |
stwm %r4,64(%sp)
|
|
Packit Service |
82fcde |
stw %r19,-32(%sp)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* _fini prologue. */
|
|
Packit Service |
82fcde |
.section .fini,"ax",%progbits
|
|
Packit Service |
82fcde |
.align 4
|
|
Packit Service |
82fcde |
.globl _fini
|
|
Packit Service |
82fcde |
.hidden _fini
|
|
Packit Service |
82fcde |
.type _fini,@function
|
|
Packit Service |
82fcde |
_fini:
|
|
Packit Service |
82fcde |
stw %rp,-20(%sp)
|
|
Packit Service |
82fcde |
stwm %r4,64(%sp)
|
|
Packit Service |
82fcde |
stw %r19,-32(%sp)
|
|
Packit Service |
82fcde |
copy %r19,%r4
|