Blame sysdeps/arm/arm-mcount.S

Packit 6c4009
/* Implementation of profiling support.  ARM EABI version.
Packit 6c4009
   Copyright (C) 2008-2018 Free Software Foundation, Inc.
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
/* Don't call mcount when calling mcount...  */
Packit 6c4009
#undef PROF
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
Packit 6c4009
#undef mcount
Packit 6c4009
Packit 6c4009
#ifdef __thumb2__
Packit 6c4009
	.thumb
Packit 6c4009
#endif
Packit 6c4009
	.syntax unified
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Use an assembly stub with a special ABI.  The calling lr has been
Packit 6c4009
   pushed to the stack (which will be misaligned).  We should preserve
Packit 6c4009
   all registers except ip and pop a word off the stack.
Packit 6c4009
Packit 6c4009
   NOTE: This assumes mcount_internal does not clobber any non-core
Packit 6c4009
   (coprocessor) registers.  Currently this is true, but may require
Packit 6c4009
   additional attention in the future.
Packit 6c4009
Packit 6c4009
   The calling sequence looks something like:
Packit 6c4009
func:
Packit 6c4009
   push {lr}
Packit 6c4009
   bl __gnu_mcount_nc
Packit 6c4009
   <function body>
Packit 6c4009
*/
Packit 6c4009
Packit 6c4009
ENTRY(__gnu_mcount_nc)
Packit 6c4009
	push {r0, r1, r2, r3, lr}
Packit 6c4009
	cfi_adjust_cfa_offset (20)
Packit 6c4009
	cfi_rel_offset (r0, 0)
Packit 6c4009
	cfi_rel_offset (r1, 4)
Packit 6c4009
	cfi_rel_offset (r2, 8)
Packit 6c4009
	cfi_rel_offset (r3, 12)
Packit 6c4009
	cfi_rel_offset (lr, 16)
Packit 6c4009
	bic r1, lr, #1
Packit 6c4009
	ldr r0, [sp, #20]
Packit 6c4009
	bl __mcount_internal
Packit 6c4009
	pop {r0, r1, r2, r3, ip, lr}
Packit 6c4009
	cfi_adjust_cfa_offset (-24)
Packit 6c4009
	cfi_restore (r0)
Packit 6c4009
	cfi_restore (r1)
Packit 6c4009
	cfi_restore (r2)
Packit 6c4009
	cfi_restore (r3)
Packit 6c4009
	cfi_register (lr, ip)
Packit 6c4009
	bx ip
Packit 6c4009
END(__gnu_mcount_nc)
Packit 6c4009
Packit 6c4009
Packit 6c4009
#include <gcc-compat.h>
Packit 6c4009
#include <shlib-compat.h>
Packit 6c4009
Packit 6c4009
/* The new __gnu_mcount_nc entry point was introduced in 4.4, so the
Packit 6c4009
   static library needs the old one only to support older compilers.
Packit 6c4009
   Even in a configuration that only cares about newer compilers, the
Packit 6c4009
   shared library might need it only for strict ABI compatibility.  */
Packit 6c4009
Packit 6c4009
#if GCC_COMPAT (4, 3) || SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_19)
Packit 6c4009
Packit 6c4009
/* Provide old mcount for backwards compatibility.  This requires
Packit 6c4009
   code be compiled with APCS frame pointers.  */
Packit 6c4009
Packit 6c4009
ENTRY(__mcount_arm_compat)
Packit 6c4009
	push	{r0, r1, r2, r3, fp, lr}
Packit 6c4009
	cfi_adjust_cfa_offset (24)
Packit 6c4009
	cfi_rel_offset (r0, 0)
Packit 6c4009
	cfi_rel_offset (r1, 4)
Packit 6c4009
	cfi_rel_offset (r2, 8)
Packit 6c4009
	cfi_rel_offset (r3, 12)
Packit 6c4009
	cfi_rel_offset (fp, 16)
Packit 6c4009
	cfi_rel_offset (lr, 20)
Packit 6c4009
	movs r0, fp
Packit 6c4009
	ittt ne
Packit 6c4009
	ldrne r0, [r0, #-4]
Packit 6c4009
	movsne r1, lr
Packit 6c4009
	blne __mcount_internal
Packit 6c4009
# if defined (__ARM_ARCH_4T__) && defined (__THUMB_INTERWORK__)
Packit 6c4009
	pop	{r0, r1, r2, r3, fp, lr}
Packit 6c4009
	cfi_adjust_cfa_offset (-24)
Packit 6c4009
	cfi_restore (r0)
Packit 6c4009
	cfi_restore (r1)
Packit 6c4009
	cfi_restore (r2)
Packit 6c4009
	cfi_restore (r3)
Packit 6c4009
	cfi_restore (fp)
Packit 6c4009
	cfi_restore (lr)
Packit 6c4009
	bx lr
Packit 6c4009
# else
Packit 6c4009
	pop	{r0, r1, r2, r3, fp, pc}
Packit 6c4009
# endif
Packit 6c4009
END(__mcount_arm_compat)
Packit 6c4009
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#if GCC_COMPAT (4, 3)
Packit 6c4009
Packit 6c4009
strong_alias (__mcount_arm_compat, _mcount)
Packit 6c4009
Packit 6c4009
/* The canonical name for the function is `_mcount' in both C and asm,
Packit 6c4009
   but some old asm code might assume it's `mcount'.  */
Packit 6c4009
weak_alias (_mcount, mcount)
Packit 6c4009
Packit 6c4009
#elif SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_19)
Packit 6c4009
Packit 6c4009
compat_symbol (libc, __mcount_arm_compat, _mcount, GLIBC_2_0)
Packit 6c4009
Packit 6c4009
strong_alias (__mcount_arm_compat, __mcount_arm_compat_1)
Packit 6c4009
compat_symbol (libc, __mcount_arm_compat_1, mcount, GLIBC_2_0)
Packit 6c4009
Packit 6c4009
#endif