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

Packit 6c4009
/* 64 bit S/390-specific implementation of profiling support.
Packit 6c4009
   Copyright (C) 2001-2018 Free Software Foundation, Inc.
Packit 6c4009
   Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com)
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
Packit 6c4009
/* How profiling works on 64 bit S/390:
Packit 6c4009
   On the start of each function _mcount is called with the address of a
Packit 6c4009
   data word in %r1 (initialized to 0, used for counting). The compiler
Packit 6c4009
   with the option -p generates code of the form:
Packit 6c4009
Packit 6c4009
           STM    6,15,24(15)
Packit 6c4009
           BRAS   13,.LTN0_0
Packit 6c4009
   .LT0_0:
Packit 6c4009
   .LC13:  .long  .LP0
Packit 6c4009
           .data
Packit 6c4009
           .align 4
Packit 6c4009
   .LP0:   .long  0
Packit 6c4009
           .text
Packit 6c4009
   # function profiler
Packit 6c4009
           stg    14,4(15)
Packit 6c4009
           lg     1,.LC13-.LT0_0(13)
Packit 6c4009
           brasl  14,_mcount
Packit 6c4009
           lg     14,4(15)
Packit 6c4009
Packit 6c4009
   The _mcount implementation now has to call __mcount_internal with the
Packit 6c4009
   address of .LP0 as first parameter and the return address as second
Packit 6c4009
   parameter. &.LP0 was loaded to %r1 and the return address is in %r14.
Packit 6c4009
   _mcount may not modify any register.  */
Packit 6c4009
Packit 6c4009
	.globl C_SYMBOL_NAME(_mcount)
Packit 6c4009
	.type C_SYMBOL_NAME(_mcount), @function
Packit 6c4009
	cfi_startproc
Packit 6c4009
	.align ALIGNARG(4)
Packit 6c4009
C_LABEL(_mcount)
Packit 6c4009
	/* Save the caller-clobbered registers.  */
Packit 6c4009
        aghi  %r15,-224
Packit 6c4009
	cfi_adjust_cfa_offset (224)
Packit 6c4009
        stmg  %r14,%r5,160(%r15)
Packit 6c4009
	cfi_offset (r14, 0)
Packit 6c4009
	cfi_offset (r15, 8)
Packit 6c4009
        lg    %r2,232(%r15)       # callers address  = first parameter
Packit 6c4009
        la    %r2,0(%r2)          # clear bit 0
Packit 6c4009
        la    %r3,0(%r14)         # callees address  = second parameter
Packit 6c4009
Packit 6c4009
#ifdef PIC
Packit 6c4009
	brasl %r14,__mcount_internal@PLT
Packit 6c4009
#else
Packit 6c4009
	brasl %r14,__mcount_internal
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
	/* Pop the saved registers.  Please note that `mcount' has no
Packit 6c4009
	   return value.  */
Packit 6c4009
	lmg   %r14,%r5,160(%r15)
Packit 6c4009
        aghi   %r15,224
Packit 6c4009
	cfi_adjust_cfa_offset (-224)
Packit 6c4009
        br    %r14
Packit 6c4009
	cfi_endproc
Packit 6c4009
	ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(_mcount))
Packit 6c4009
Packit 6c4009
#undef mcount
Packit 6c4009
weak_alias (_mcount, mcount)