]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/x86_64/dl-trampoline.S
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / x86_64 / dl-trampoline.S
CommitLineData
9dcafc55 1/* PLT trampolines. x86-64 version.
dff8da6b 2 Copyright (C) 2004-2024 Free Software Foundation, Inc.
9dcafc55
UD
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
9dcafc55 18
b0ecde3a 19#include <config.h>
9dcafc55 20#include <sysdep.h>
fb4c32ae 21#include <cpu-features-offsets.h>
b0ecde3a 22#include <link-defines.h>
cfdc4df6 23#include <isa-level.h>
9dcafc55 24
f3dcae82
L
25#ifndef DL_STACK_ALIGNMENT
26/* Due to GCC bug:
27
28 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066
29
30 __tls_get_addr may be called with 8-byte stack alignment. Although
31 this bug has been fixed in GCC 4.9.4, 5.3 and 6, we can't assume
32 that stack will be always aligned at 16 bytes. We use unaligned
33 16-byte move to load and store SSE registers, which has no penalty
34 on modern processors if stack is 16-byte aligned. */
35# define DL_STACK_ALIGNMENT 8
36#endif
37
b52b0d79
L
38/* True if _dl_runtime_resolve should align stack for STATE_SAVE or align
39 stack to 16 bytes before calling _dl_fixup. */
8d9c9201 40#define DL_RUNTIME_RESOLVE_REALIGN_STACK \
b52b0d79
L
41 (STATE_SAVE_ALIGNMENT > DL_STACK_ALIGNMENT \
42 || 16 > DL_STACK_ALIGNMENT)
f3dcae82 43
a4c75cfd
IZ
44/* Area on stack to save and restore registers used for parameter
45 passing when calling _dl_fixup. */
b52b0d79 46#define REGISTER_SAVE_RAX 0
a4c75cfd
IZ
47#define REGISTER_SAVE_RCX (REGISTER_SAVE_RAX + 8)
48#define REGISTER_SAVE_RDX (REGISTER_SAVE_RCX + 8)
49#define REGISTER_SAVE_RSI (REGISTER_SAVE_RDX + 8)
50#define REGISTER_SAVE_RDI (REGISTER_SAVE_RSI + 8)
51#define REGISTER_SAVE_R8 (REGISTER_SAVE_RDI + 8)
52#define REGISTER_SAVE_R9 (REGISTER_SAVE_R8 + 8)
53
0a5768fe
L
54#define RESTORE_AVX
55
55f41ef8
AZ
56#ifdef SHARED
57# define VEC_SIZE 64
58# define VMOVA vmovdqa64
59# define VEC(i) zmm##i
60# define _dl_runtime_profile _dl_runtime_profile_avx512
61# define SECTION(p) p##.evex512
cfdc4df6
L
62# include "dl-trampoline.h"
63# undef _dl_runtime_profile
64# undef VEC
65# undef VMOVA
66# undef VEC_SIZE
58bcf7b7 67# undef SECTION
f3dcae82 68
55f41ef8
AZ
69# if MINIMUM_X86_ISA_LEVEL <= AVX_X86_ISA_LEVEL
70# define VEC_SIZE 32
71# define VMOVA vmovdqa
72# define VEC(i) ymm##i
73# define SECTION(p) p##.avx
74# define _dl_runtime_profile _dl_runtime_profile_avx
75# include "dl-trampoline.h"
76# undef _dl_runtime_profile
77# undef VEC
78# undef VMOVA
79# undef VEC_SIZE
80# undef SECTION
81# endif
82
83# if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL
f3dcae82 84/* movaps/movups is 1-byte shorter. */
55f41ef8
AZ
85# define VEC_SIZE 16
86# define VMOVA movaps
87# define VEC(i) xmm##i
88# define _dl_runtime_profile _dl_runtime_profile_sse
89# undef RESTORE_AVX
90# include "dl-trampoline.h"
91# undef _dl_runtime_profile
92# undef VEC
93# undef VMOVA
94# undef VEC_SIZE
95# endif
96#endif /* SHARED */
cfdc4df6 97
55f41ef8 98#if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL
cfdc4df6
L
99# define USE_FXSAVE
100# define STATE_SAVE_ALIGNMENT 16
101# define _dl_runtime_resolve _dl_runtime_resolve_fxsave
102# include "dl-trampoline.h"
103# undef _dl_runtime_resolve
104# undef USE_FXSAVE
105# undef STATE_SAVE_ALIGNMENT
106#endif
b52b0d79
L
107
108#define USE_XSAVE
109#define STATE_SAVE_ALIGNMENT 64
110#define _dl_runtime_resolve _dl_runtime_resolve_xsave
111#include "dl-trampoline.h"
112#undef _dl_runtime_resolve
113#undef USE_XSAVE
114#undef STATE_SAVE_ALIGNMENT
115
116#define USE_XSAVEC
117#define STATE_SAVE_ALIGNMENT 64
118#define _dl_runtime_resolve _dl_runtime_resolve_xsavec
fb0f7a67 119#include "dl-trampoline.h"
b52b0d79
L
120#undef _dl_runtime_resolve
121#undef USE_XSAVEC
122#undef STATE_SAVE_ALIGNMENT