| 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 | |
| 26 | /* Area on stack to save and restore registers used for parameter |
| 27 | passing when calling _dl_fixup. */ |
| 28 | #define REGISTER_SAVE_RAX 0 |
| 29 | #define REGISTER_SAVE_RCX (REGISTER_SAVE_RAX + 8) |
| 30 | #define REGISTER_SAVE_RDX (REGISTER_SAVE_RCX + 8) |
| 31 | #define REGISTER_SAVE_RSI (REGISTER_SAVE_RDX + 8) |
| 32 | #define REGISTER_SAVE_RDI (REGISTER_SAVE_RSI + 8) |
| 33 | #define REGISTER_SAVE_R8 (REGISTER_SAVE_RDI + 8) |
| 34 | #define REGISTER_SAVE_R9 (REGISTER_SAVE_R8 + 8) |
| 35 | |
| 36 | #define RESTORE_AVX |
| 37 | |
| 38 | #ifdef SHARED |
| 39 | # define VEC_SIZE 64 |
| 40 | # define VMOVA vmovdqa64 |
| 41 | # define VEC(i) zmm##i |
| 42 | # define _dl_runtime_profile _dl_runtime_profile_avx512 |
| 43 | # define SECTION(p) p##.evex512 |
| 44 | # include "dl-trampoline.h" |
| 45 | # undef _dl_runtime_profile |
| 46 | # undef VEC |
| 47 | # undef VMOVA |
| 48 | # undef VEC_SIZE |
| 49 | # undef SECTION |
| 50 | |
| 51 | # if MINIMUM_X86_ISA_LEVEL <= AVX_X86_ISA_LEVEL |
| 52 | # define VEC_SIZE 32 |
| 53 | # define VMOVA vmovdqa |
| 54 | # define VEC(i) ymm##i |
| 55 | # define SECTION(p) p##.avx |
| 56 | # define _dl_runtime_profile _dl_runtime_profile_avx |
| 57 | # include "dl-trampoline.h" |
| 58 | # undef _dl_runtime_profile |
| 59 | # undef VEC |
| 60 | # undef VMOVA |
| 61 | # undef VEC_SIZE |
| 62 | # undef SECTION |
| 63 | # endif |
| 64 | |
| 65 | # if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL |
| 66 | /* movaps/movups is 1-byte shorter. */ |
| 67 | # define VEC_SIZE 16 |
| 68 | # define VMOVA movaps |
| 69 | # define VEC(i) xmm##i |
| 70 | # define _dl_runtime_profile _dl_runtime_profile_sse |
| 71 | # undef RESTORE_AVX |
| 72 | # include "dl-trampoline.h" |
| 73 | # undef _dl_runtime_profile |
| 74 | # undef VEC |
| 75 | # undef VMOVA |
| 76 | # undef VEC_SIZE |
| 77 | # endif |
| 78 | #endif /* SHARED */ |
| 79 | |
| 80 | #if MINIMUM_X86_ISA_LEVEL < AVX_X86_ISA_LEVEL |
| 81 | # define USE_FXSAVE |
| 82 | # define STATE_SAVE_ALIGNMENT 16 |
| 83 | # define _dl_runtime_resolve _dl_runtime_resolve_fxsave |
| 84 | # include "dl-trampoline.h" |
| 85 | # undef _dl_runtime_resolve |
| 86 | # undef USE_FXSAVE |
| 87 | # undef STATE_SAVE_ALIGNMENT |
| 88 | #endif |
| 89 | |
| 90 | #define USE_XSAVE |
| 91 | #define STATE_SAVE_ALIGNMENT 64 |
| 92 | #define _dl_runtime_resolve _dl_runtime_resolve_xsave |
| 93 | #include "dl-trampoline.h" |
| 94 | #undef _dl_runtime_resolve |
| 95 | #undef USE_XSAVE |
| 96 | #undef STATE_SAVE_ALIGNMENT |
| 97 | |
| 98 | #define USE_XSAVEC |
| 99 | #define STATE_SAVE_ALIGNMENT 64 |
| 100 | #define _dl_runtime_resolve _dl_runtime_resolve_xsavec |
| 101 | #include "dl-trampoline.h" |
| 102 | #undef _dl_runtime_resolve |
| 103 | #undef USE_XSAVEC |
| 104 | #undef STATE_SAVE_ALIGNMENT |
| 105 | |