Blame sysdeps/arm/__longjmp.S

Packit 6c4009
/* longjmp for ARM.
Packit 6c4009
   Copyright (C) 1997-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
#include <sysdep.h>
Packit 6c4009
#include <stap-probe.h>
Packit 6c4009
#include <bits/setjmp.h>
Packit 6c4009
#include <rtld-global-offsets.h>
Packit 6c4009
#include <arm-features.h>
Packit 6c4009
Packit 6c4009
/* __longjmp(jmpbuf, val) */
Packit 6c4009
Packit 6c4009
ENTRY (__longjmp)
Packit 6c4009
	mov	ip, r0
Packit 6c4009
Packit 6c4009
#ifdef CHECK_SP
Packit 6c4009
	ldr	r4, [ip]	/* jmpbuf's sp */
Packit 6c4009
	cfi_undefined (r4)
Packit 6c4009
#ifdef PTR_DEMANGLE
Packit 6c4009
	PTR_DEMANGLE (r4, r4, a3, a4)
Packit 6c4009
#endif
Packit 6c4009
	CHECK_SP (r4)
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifdef PTR_DEMANGLE
Packit 6c4009
	ldr	a4, [ip], #4
Packit 6c4009
	PTR_DEMANGLE (a4, a4, a3, r4)
Packit 6c4009
	cfi_undefined (r4)
Packit 6c4009
	ldr	r4, [ip], #4
Packit 6c4009
	PTR_DEMANGLE2 (r4, r4, a3)
Packit 6c4009
#else
Packit 6c4009
	ldr	a4, [ip], #4
Packit 6c4009
	ldr	r4, [ip], #4
Packit 6c4009
	cfi_undefined (r4)
Packit 6c4009
#endif
Packit 6c4009
	/* longjmp probe expects longjmp first argument (4@r0), second
Packit 6c4009
	   argument (-4@r1), and target address (4@r4), respectively.  */
Packit 6c4009
	LIBC_PROBE (longjmp, 3, 4@r0, -4@r1, 4@r4)
Packit 6c4009
	mov	sp, a4
Packit 6c4009
	mov	lr, r4
Packit 6c4009
	ldmia	ip!, JMP_BUF_REGLIST
Packit 6c4009
	cfi_restore (v1)
Packit 6c4009
	cfi_restore (v2)
Packit 6c4009
	cfi_restore (v3)
Packit 6c4009
	cfi_restore (v4)
Packit 6c4009
	cfi_restore (v5)
Packit 6c4009
	cfi_restore (v6)
Packit 6c4009
	cfi_restore (sl)
Packit 6c4009
	cfi_restore (fp)
Packit 6c4009
	cfi_restore (sp)
Packit 6c4009
	cfi_restore (lr)
Packit 6c4009
Packit 6c4009
#if !defined ARM_ASSUME_NO_IWMMXT || defined __SOFTFP__
Packit 6c4009
# define NEED_HWCAP 1
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifdef NEED_HWCAP
Packit 6c4009
# if IS_IN (rtld)
Packit 6c4009
	LDST_PCREL (ldr, a4, a3, \
Packit 6c4009
		    C_SYMBOL_NAME(_rtld_local_ro) \
Packit 6c4009
		    + RTLD_GLOBAL_RO_DL_HWCAP_OFFSET)
Packit 6c4009
# else
Packit 6c4009
#  ifdef SHARED
Packit 6c4009
	LDR_GLOBAL (a4, a3, C_SYMBOL_NAME(_rtld_global_ro), \
Packit 6c4009
		    RTLD_GLOBAL_RO_DL_HWCAP_OFFSET)
Packit 6c4009
#  else
Packit 6c4009
	LDR_GLOBAL (a4, a3, C_SYMBOL_NAME(_dl_hwcap), 0)
Packit 6c4009
#  endif
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifdef __SOFTFP__
Packit 6c4009
	tst	a4, #HWCAP_ARM_VFP
Packit 6c4009
	beq	.Lno_vfp
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
	/* Restore the VFP registers.  */
Packit 6c4009
	/* Following instruction is vldmia ip!, {d8-d15}.  */
Packit 6c4009
	ldc	p11, cr8, [r12], #64
Packit 6c4009
.Lno_vfp:
Packit 6c4009
Packit 6c4009
#ifndef ARM_ASSUME_NO_IWMMXT
Packit 6c4009
	tst	a4, #HWCAP_ARM_IWMMXT
Packit 6c4009
	beq	.Lno_iwmmxt
Packit 6c4009
Packit 6c4009
	/* Restore the call-preserved iWMMXt registers.  */
Packit 6c4009
	/* Following instructions are wldrd wr10, [ip], #8 (etc.)  */
Packit 6c4009
	ldcl	p1, cr10, [r12], #8
Packit 6c4009
	ldcl	p1, cr11, [r12], #8
Packit 6c4009
	ldcl	p1, cr12, [r12], #8
Packit 6c4009
	ldcl	p1, cr13, [r12], #8
Packit 6c4009
	ldcl	p1, cr14, [r12], #8
Packit 6c4009
	ldcl	p1, cr15, [r12], #8
Packit 6c4009
.Lno_iwmmxt:
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
	/* longjmp_target probe expects longjmp first argument (4@r0), second
Packit 6c4009
	   argument (-4@r1), and target address (4@r14), respectively.  */
Packit 6c4009
	LIBC_PROBE (longjmp_target, 3, 4@r0, -4@r1, 4@r14)
Packit 6c4009
Packit 6c4009
	movs	r0, r1		/* get the return value in place */
Packit 6c4009
	it	eq
Packit 6c4009
	moveq	r0, #1		/* can't let setjmp() return zero! */
Packit 6c4009
Packit 6c4009
	DO_RET(lr)
Packit 6c4009
Packit 6c4009
END (__longjmp)