1 | /* PLT trampolines. x86-64 version. |
2 | Copyright (C) 2004-2024 Free Software Foundation, Inc. |
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 |
16 | License along with the GNU C Library; if not, see |
17 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #include <config.h> |
20 | #include <sysdep.h> |
21 | #include <cpu-features-offsets.h> |
22 | #include <features-offsets.h> |
23 | #include <link-defines.h> |
24 | #include <isa-level.h> |
25 | #include "dl-trampoline-save.h" |
26 | |
27 | /* Area on stack to save and restore registers used for parameter |
28 | passing when calling _dl_fixup. */ |
29 | #define REGISTER_SAVE_RAX 0 |
30 | #define REGISTER_SAVE_RCX (REGISTER_SAVE_RAX + 8) |
31 | #define REGISTER_SAVE_RDX (REGISTER_SAVE_RCX + 8) |
32 | #define REGISTER_SAVE_RSI (REGISTER_SAVE_RDX + 8) |
33 | #define REGISTER_SAVE_RDI (REGISTER_SAVE_RSI + 8) |
34 | #define REGISTER_SAVE_R8 (REGISTER_SAVE_RDI + 8) |
35 | #define REGISTER_SAVE_R9 (REGISTER_SAVE_R8 + 8) |
36 | |
37 | #define RESTORE_AVX |
38 | |
39 | #ifdef SHARED |
40 | # define VEC_SIZE 64 |
41 | # define VMOVA vmovdqa64 |
42 | # define VEC(i) zmm##i |
43 | # define _dl_runtime_profile _dl_runtime_profile_avx512 |
44 | # define SECTION(p) p##.evex512 |
45 | # include "dl-trampoline.h" |
46 | # undef _dl_runtime_profile |
47 | # undef VEC |
48 | # undef VMOVA |
49 | # undef VEC_SIZE |
50 | # undef SECTION |
51 | |
52 | # if MINIMUM_X86_ISA_LEVEL <= AVX_X86_ISA_LEVEL |
53 | # define VEC_SIZE 32 |
54 | # define VMOVA vmovdqa |
55 | # define VEC(i) ymm##i |
56 | # define SECTION(p) p##.avx |
57 | # define _dl_runtime_profile _dl_runtime_profile_avx |
58 | # include "dl-trampoline.h" |
59 | # undef _dl_runtime_profile |
60 | # undef VEC |
61 | # undef VMOVA |
62 | # undef VEC_SIZE |
63 | # undef SECTION |
64 | # endif |
65 | |
66 | # if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL |
67 | /* movaps/movups is 1-byte shorter. */ |
68 | # define VEC_SIZE 16 |
69 | # define VMOVA movaps |
70 | # define VEC(i) xmm##i |
71 | # define _dl_runtime_profile _dl_runtime_profile_sse |
72 | # undef RESTORE_AVX |
73 | # include "dl-trampoline.h" |
74 | # undef _dl_runtime_profile |
75 | # undef VEC |
76 | # undef VMOVA |
77 | # undef VEC_SIZE |
78 | # endif |
79 | #endif /* SHARED */ |
80 | |
81 | #if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL |
82 | # define USE_FXSAVE |
83 | # define STATE_SAVE_ALIGNMENT 16 |
84 | # define _dl_runtime_resolve _dl_runtime_resolve_fxsave |
85 | # include "dl-trampoline.h" |
86 | # undef _dl_runtime_resolve |
87 | # undef USE_FXSAVE |
88 | # undef STATE_SAVE_ALIGNMENT |
89 | #endif |
90 | |
91 | #define USE_XSAVE |
92 | #define STATE_SAVE_ALIGNMENT 64 |
93 | #define _dl_runtime_resolve _dl_runtime_resolve_xsave |
94 | #include "dl-trampoline.h" |
95 | #undef _dl_runtime_resolve |
96 | #undef USE_XSAVE |
97 | #undef STATE_SAVE_ALIGNMENT |
98 | |
99 | #define USE_XSAVEC |
100 | #define STATE_SAVE_ALIGNMENT 64 |
101 | #define _dl_runtime_resolve _dl_runtime_resolve_xsavec |
102 | #include "dl-trampoline.h" |
103 | #undef _dl_runtime_resolve |
104 | #undef USE_XSAVEC |
105 | #undef STATE_SAVE_ALIGNMENT |
106 | |