1/* PLT trampolines. x86-64 version.
2 Copyright (C) 2004-2022 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 <link-defines.h>
23
24#ifndef DL_STACK_ALIGNMENT
25/* Due to GCC bug:
26
27 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066
28
29 __tls_get_addr may be called with 8-byte stack alignment. Although
30 this bug has been fixed in GCC 4.9.4, 5.3 and 6, we can't assume
31 that stack will be always aligned at 16 bytes. We use unaligned
32 16-byte move to load and store SSE registers, which has no penalty
33 on modern processors if stack is 16-byte aligned. */
34# define DL_STACK_ALIGNMENT 8
35#endif
36
37/* True if _dl_runtime_resolve should align stack for STATE_SAVE or align
38 stack to 16 bytes before calling _dl_fixup. */
39#define DL_RUNTIME_RESOLVE_REALIGN_STACK \
40 (STATE_SAVE_ALIGNMENT > DL_STACK_ALIGNMENT \
41 || 16 > DL_STACK_ALIGNMENT)
42
43/* Area on stack to save and restore registers used for parameter
44 passing when calling _dl_fixup. */
45#define REGISTER_SAVE_RAX 0
46#define REGISTER_SAVE_RCX (REGISTER_SAVE_RAX + 8)
47#define REGISTER_SAVE_RDX (REGISTER_SAVE_RCX + 8)
48#define REGISTER_SAVE_RSI (REGISTER_SAVE_RDX + 8)
49#define REGISTER_SAVE_RDI (REGISTER_SAVE_RSI + 8)
50#define REGISTER_SAVE_R8 (REGISTER_SAVE_RDI + 8)
51#define REGISTER_SAVE_R9 (REGISTER_SAVE_R8 + 8)
52
53#define RESTORE_AVX
54
55#define VEC_SIZE 64
56#define VMOVA vmovdqa64
57#define VEC(i) zmm##i
58#define _dl_runtime_profile _dl_runtime_profile_avx512
59#include "dl-trampoline.h"
60#undef _dl_runtime_profile
61#undef VEC
62#undef VMOVA
63#undef VEC_SIZE
64
65#define VEC_SIZE 32
66#define VMOVA vmovdqa
67#define VEC(i) ymm##i
68#define _dl_runtime_profile _dl_runtime_profile_avx
69#include "dl-trampoline.h"
70#undef _dl_runtime_profile
71#undef VEC
72#undef VMOVA
73#undef VEC_SIZE
74
75/* movaps/movups is 1-byte shorter. */
76#define VEC_SIZE 16
77#define VMOVA movaps
78#define VEC(i) xmm##i
79#define _dl_runtime_profile _dl_runtime_profile_sse
80#undef RESTORE_AVX
81#include "dl-trampoline.h"
82#undef _dl_runtime_profile
83#undef VEC
84#undef VMOVA
85#undef VEC_SIZE
86
87#define USE_FXSAVE
88#define STATE_SAVE_ALIGNMENT 16
89#define _dl_runtime_resolve _dl_runtime_resolve_fxsave
90#include "dl-trampoline.h"
91#undef _dl_runtime_resolve
92#undef USE_FXSAVE
93#undef STATE_SAVE_ALIGNMENT
94
95#define USE_XSAVE
96#define STATE_SAVE_ALIGNMENT 64
97#define _dl_runtime_resolve _dl_runtime_resolve_xsave
98#include "dl-trampoline.h"
99#undef _dl_runtime_resolve
100#undef USE_XSAVE
101#undef STATE_SAVE_ALIGNMENT
102
103#define USE_XSAVEC
104#define STATE_SAVE_ALIGNMENT 64
105#define _dl_runtime_resolve _dl_runtime_resolve_xsavec
106#include "dl-trampoline.h"
107#undef _dl_runtime_resolve
108#undef USE_XSAVEC
109#undef STATE_SAVE_ALIGNMENT
110

source code of glibc/sysdeps/x86_64/dl-trampoline.S