2003-10-23 22:53:02 +02:00
|
|
|
/* stuff needed for libgcc on win32.
|
|
|
|
*
|
2021-01-04 10:26:59 +01:00
|
|
|
* Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
2003-10-23 22:53:02 +02:00
|
|
|
* Written By Steve Chamberlain
|
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
2009-04-09 17:00:19 +02:00
|
|
|
* Free Software Foundation; either version 3, or (at your option) any
|
2003-10-23 22:53:02 +02:00
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
2009-04-09 17:00:19 +02:00
|
|
|
* Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
* permissions described in the GCC Runtime Library Exception, version
|
|
|
|
* 3.1, as published by the Free Software Foundation.
|
2003-10-23 22:53:02 +02:00
|
|
|
*
|
2009-04-09 17:00:19 +02:00
|
|
|
* You should have received a copy of the GNU General Public License and
|
|
|
|
* a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
* see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2003-10-23 22:53:02 +02:00
|
|
|
*/
|
1996-02-03 02:03:27 +01:00
|
|
|
|
2018-02-28 09:59:15 +01:00
|
|
|
#include "i386-asm.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_AS_CFI_SECTIONS
|
2010-09-26 06:02:24 +02:00
|
|
|
.cfi_sections .debug_frame
|
re PR debug/83917 (with -mcall-ms2sysv-xlogues, stepping into x86 tail-call restore stub gives bad backtrace)
PR debug/83917
* config/i386/i386-asm.h (PACKAGE_VERSION, PACKAGE_NAME,
PACKAGE_STRING, PACKAGE_TARNAME, PACKAGE_URL): Undefine between
inclusion of auto-target.h and auto-host.h.
(USE_GAS_CFI_DIRECTIVES): Define if not defined already based on
__GCC_HAVE_DWARF2_CFI_ASM.
(cfi_startproc, cfi_endproc, cfi_adjust_cfa_offset,
cfi_def_cfa_register, cfi_def_cfa, cfi_register, cfi_offset, cfi_push,
cfi_pop): Define.
* config/i386/cygwin.S: Don't include auto-host.h here, just
define USE_GAS_CFI_DIRECTIVES to 1 or 0 and include i386-asm.h.
(cfi_startproc, cfi_endproc, cfi_adjust_cfa_offset,
cfi_def_cfa_register, cfi_register, cfi_push, cfi_pop): Remove.
* config/i386/resms64fx.h: Add cfi_* directives.
* config/i386/resms64x.h: Likewise.
From-SVN: r258010
2018-02-26 20:46:34 +01:00
|
|
|
#endif
|
1996-02-03 02:03:27 +01:00
|
|
|
|
2010-09-26 06:02:24 +02:00
|
|
|
#ifdef L_chkstk
|
|
|
|
/* Function prologue calls __chkstk to probe the stack when allocating more
|
2003-10-23 22:53:02 +02:00
|
|
|
than CHECK_STACK_LIMIT bytes in one go. Touching the stack at 4K
|
|
|
|
increments is necessary to ensure that the guard pages used
|
|
|
|
by the OS virtual memory manger are allocated in correct sequence. */
|
|
|
|
|
1996-02-03 02:03:27 +01:00
|
|
|
.global ___chkstk
|
|
|
|
.global __alloca
|
2013-03-25 15:54:30 +01:00
|
|
|
#ifdef __x86_64__
|
2010-09-26 06:02:24 +02:00
|
|
|
/* __alloca is a normal function call, which uses %rcx as the argument. */
|
|
|
|
cfi_startproc()
|
1996-02-03 02:03:27 +01:00
|
|
|
__alloca:
|
2010-09-26 06:02:24 +02:00
|
|
|
movq %rcx, %rax
|
|
|
|
/* FALLTHRU */
|
1996-02-03 02:03:27 +01:00
|
|
|
|
2010-09-26 06:02:24 +02:00
|
|
|
/* ___chkstk is a *special* function call, which uses %rax as the argument.
|
|
|
|
We avoid clobbering the 4 integer argument registers, %rcx, %rdx,
|
|
|
|
%r8 and %r9, which leaves us with %rax, %r10, and %r11 to use. */
|
|
|
|
.align 4
|
|
|
|
___chkstk:
|
|
|
|
popq %r11 /* pop return address */
|
|
|
|
cfi_adjust_cfa_offset(-8) /* indicate return address in r11 */
|
|
|
|
cfi_register(%rip, %r11)
|
|
|
|
movq %rsp, %r10
|
|
|
|
cmpq $0x1000, %rax /* > 4k ?*/
|
|
|
|
jb 2f
|
1996-02-03 02:03:27 +01:00
|
|
|
|
2010-09-26 06:02:24 +02:00
|
|
|
1: subq $0x1000, %r10 /* yes, move pointer down 4k*/
|
|
|
|
orl $0x0, (%r10) /* probe there */
|
|
|
|
subq $0x1000, %rax /* decrement count */
|
|
|
|
cmpq $0x1000, %rax
|
|
|
|
ja 1b /* and do it again */
|
1996-02-03 02:03:27 +01:00
|
|
|
|
2010-09-26 06:02:24 +02:00
|
|
|
2: subq %rax, %r10
|
|
|
|
movq %rsp, %rax /* hold CFA until return */
|
|
|
|
cfi_def_cfa_register(%rax)
|
|
|
|
orl $0x0, (%r10) /* less than 4k, just peek here */
|
|
|
|
movq %r10, %rsp /* decrement stack */
|
1996-02-03 02:03:27 +01:00
|
|
|
|
2007-03-30 23:45:03 +02:00
|
|
|
/* Push the return value back. Doing this instead of just
|
2010-09-26 06:02:24 +02:00
|
|
|
jumping to %r11 preserves the cached call-return stack
|
2007-03-30 23:45:03 +02:00
|
|
|
used by most modern processors. */
|
2010-09-26 06:02:24 +02:00
|
|
|
pushq %r11
|
2007-03-30 23:45:03 +02:00
|
|
|
ret
|
2010-09-26 06:02:24 +02:00
|
|
|
cfi_endproc()
|
2007-03-30 23:45:03 +02:00
|
|
|
#else
|
2010-09-26 06:02:24 +02:00
|
|
|
cfi_startproc()
|
|
|
|
___chkstk:
|
2007-03-30 23:45:03 +02:00
|
|
|
__alloca:
|
2010-09-26 06:02:24 +02:00
|
|
|
pushl %ecx /* save temp */
|
|
|
|
cfi_push(%eax)
|
|
|
|
leal 8(%esp), %ecx /* point past return addr */
|
|
|
|
cmpl $0x1000, %eax /* > 4k ?*/
|
|
|
|
jb 2f
|
|
|
|
|
|
|
|
1: subl $0x1000, %ecx /* yes, move pointer down 4k*/
|
|
|
|
orl $0x0, (%ecx) /* probe there */
|
|
|
|
subl $0x1000, %eax /* decrement count */
|
|
|
|
cmpl $0x1000, %eax
|
|
|
|
ja 1b /* and do it again */
|
2008-02-11 10:02:06 +01:00
|
|
|
|
2010-09-26 06:02:24 +02:00
|
|
|
2: subl %eax, %ecx
|
|
|
|
orl $0x0, (%ecx) /* less than 4k, just peek here */
|
|
|
|
movl %esp, %eax /* save current stack pointer */
|
|
|
|
cfi_def_cfa_register(%eax)
|
|
|
|
movl %ecx, %esp /* decrement stack */
|
|
|
|
movl (%eax), %ecx /* recover saved temp */
|
2008-02-11 10:02:06 +01:00
|
|
|
|
2010-09-26 06:02:24 +02:00
|
|
|
/* Copy the return register. Doing this instead of just jumping to
|
|
|
|
the address preserves the cached call-return stack used by most
|
|
|
|
modern processors. */
|
|
|
|
pushl 4(%eax)
|
2008-02-11 10:02:06 +01:00
|
|
|
ret
|
2010-09-26 06:02:24 +02:00
|
|
|
cfi_endproc()
|
2013-03-25 15:54:30 +01:00
|
|
|
#endif /* __x86_64__ */
|
2010-09-26 06:02:24 +02:00
|
|
|
#endif /* L_chkstk */
|
2007-03-30 23:45:03 +02:00
|
|
|
|
2010-09-26 06:02:24 +02:00
|
|
|
#ifdef L_chkstk_ms
|
|
|
|
/* ___chkstk_ms is a *special* function call, which uses %rax as the argument.
|
|
|
|
We avoid clobbering any registers. Unlike ___chkstk, it just probes the
|
|
|
|
stack and does no stack allocation. */
|
|
|
|
.global ___chkstk_ms
|
2013-03-25 15:54:30 +01:00
|
|
|
#ifdef __x86_64__
|
2010-09-26 06:02:24 +02:00
|
|
|
cfi_startproc()
|
|
|
|
___chkstk_ms:
|
|
|
|
pushq %rcx /* save temps */
|
|
|
|
cfi_push(%rcx)
|
|
|
|
pushq %rax
|
|
|
|
cfi_push(%rax)
|
|
|
|
cmpq $0x1000, %rax /* > 4k ?*/
|
|
|
|
leaq 24(%rsp), %rcx /* point past return addr */
|
|
|
|
jb 2f
|
|
|
|
|
|
|
|
1: subq $0x1000, %rcx /* yes, move pointer down 4k */
|
|
|
|
orq $0x0, (%rcx) /* probe there */
|
2007-03-30 23:45:03 +02:00
|
|
|
subq $0x1000, %rax /* decrement count */
|
|
|
|
cmpq $0x1000, %rax
|
2010-09-26 06:02:24 +02:00
|
|
|
ja 1b /* and do it again */
|
2007-03-30 23:45:03 +02:00
|
|
|
|
2010-09-26 06:02:24 +02:00
|
|
|
2: subq %rax, %rcx
|
|
|
|
orq $0x0, (%rcx) /* less than 4k, just peek here */
|
2007-03-30 23:45:03 +02:00
|
|
|
|
2010-09-26 06:02:24 +02:00
|
|
|
popq %rax
|
|
|
|
cfi_pop(%rax)
|
|
|
|
popq %rcx
|
|
|
|
cfi_pop(%rcx)
|
|
|
|
ret
|
|
|
|
cfi_endproc()
|
|
|
|
#else
|
|
|
|
cfi_startproc()
|
|
|
|
___chkstk_ms:
|
|
|
|
pushl %ecx /* save temp */
|
|
|
|
cfi_push(%ecx)
|
|
|
|
pushl %eax
|
|
|
|
cfi_push(%eax)
|
|
|
|
cmpl $0x1000, %eax /* > 4k ?*/
|
|
|
|
leal 12(%esp), %ecx /* point past return addr */
|
|
|
|
jb 2f
|
|
|
|
|
|
|
|
1: subl $0x1000, %ecx /* yes, move pointer down 4k*/
|
|
|
|
orl $0x0, (%ecx) /* probe there */
|
|
|
|
subl $0x1000, %eax /* decrement count */
|
|
|
|
cmpl $0x1000, %eax
|
|
|
|
ja 1b /* and do it again */
|
|
|
|
|
|
|
|
2: subl %eax, %ecx
|
|
|
|
orl $0x0, (%ecx) /* less than 4k, just peek here */
|
|
|
|
|
|
|
|
popl %eax
|
|
|
|
cfi_pop(%eax)
|
|
|
|
popl %ecx
|
|
|
|
cfi_pop(%ecx)
|
2007-03-30 23:45:03 +02:00
|
|
|
ret
|
2010-09-26 06:02:24 +02:00
|
|
|
cfi_endproc()
|
2013-03-25 15:54:30 +01:00
|
|
|
#endif /* __x86_64__ */
|
2010-09-26 06:02:24 +02:00
|
|
|
#endif /* L_chkstk_ms */
|