Blame sysdeps/s390/s390-64/s390x-mcount.S

Packit Service 82fcde
/* 64 bit S/390-specific implementation of profiling support.
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
   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
/* How profiling works on 64 bit S/390:
Packit Service 82fcde
   On the start of each function _mcount is called with the address of a
Packit Service 82fcde
   data word in %r1 (initialized to 0, used for counting). The compiler
Packit Service 82fcde
   with the option -p generates code of the form:
Packit Service 82fcde
Packit Service 82fcde
           STM    6,15,24(15)
Packit Service 82fcde
           BRAS   13,.LTN0_0
Packit Service 82fcde
   .LT0_0:
Packit Service 82fcde
   .LC13:  .long  .LP0
Packit Service 82fcde
           .data
Packit Service 82fcde
           .align 4
Packit Service 82fcde
   .LP0:   .long  0
Packit Service 82fcde
           .text
Packit Service 82fcde
   # function profiler
Packit Service 82fcde
           stg    14,4(15)
Packit Service 82fcde
           lg     1,.LC13-.LT0_0(13)
Packit Service 82fcde
           brasl  14,_mcount
Packit Service 82fcde
           lg     14,4(15)
Packit Service 82fcde
Packit Service 82fcde
   The _mcount implementation now has to call __mcount_internal with the
Packit Service 82fcde
   address of .LP0 as first parameter and the return address as second
Packit Service 82fcde
   parameter. &.LP0 was loaded to %r1 and the return address is in %r14.
Packit Service 82fcde
   _mcount may not modify any register.  */
Packit Service 82fcde
Packit Service 82fcde
	.globl C_SYMBOL_NAME(_mcount)
Packit Service 82fcde
	.type C_SYMBOL_NAME(_mcount), @function
Packit Service 82fcde
	cfi_startproc
Packit Service 82fcde
	.align ALIGNARG(4)
Packit Service 82fcde
C_LABEL(_mcount)
Packit Service 82fcde
	/* Save the caller-clobbered registers.  */
Packit Service 82fcde
        aghi  %r15,-224
Packit Service 82fcde
	cfi_adjust_cfa_offset (224)
Packit Service 82fcde
        stmg  %r14,%r5,160(%r15)
Packit Service 82fcde
	cfi_offset (r14, 0)
Packit Service 82fcde
	cfi_offset (r15, 8)
Packit Service 82fcde
        lg    %r2,232(%r15)       # callers address  = first parameter
Packit Service 82fcde
        la    %r2,0(%r2)          # clear bit 0
Packit Service 82fcde
        la    %r3,0(%r14)         # callees address  = second parameter
Packit Service 82fcde
Packit Service 82fcde
#ifdef PIC
Packit Service 82fcde
	brasl %r14,__mcount_internal@PLT
Packit Service 82fcde
#else
Packit Service 82fcde
	brasl %r14,__mcount_internal
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
	/* Pop the saved registers.  Please note that `mcount' has no
Packit Service 82fcde
	   return value.  */
Packit Service 82fcde
	lmg   %r14,%r5,160(%r15)
Packit Service 82fcde
        aghi   %r15,224
Packit Service 82fcde
	cfi_adjust_cfa_offset (-224)
Packit Service 82fcde
        br    %r14
Packit Service 82fcde
	cfi_endproc
Packit Service 82fcde
	ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(_mcount))
Packit Service 82fcde
Packit Service 82fcde
#undef mcount
Packit Service 82fcde
weak_alias (_mcount, mcount)