31
31
* *
32
32
****************************************************************************************/
33
33
34
- # if defined __CET__
35
- # include <cet.h>
36
- # define SHSTK_ENABLED (__CET__ & 0x2 )
37
- # define BOOST_CONTEXT_SHADOW_STACK (SHSTK_ENABLED && SHADOW_STACK_SYSCALL)
34
+ # ifdef __i386__
35
+ # include "make_i386_sysv_elf_gas.S"
38
36
# else
39
- # define _CET_ENDBR
40
- # endif
37
+ # if defined __CET__
38
+ # include <cet.h>
39
+ # define SHSTK_ENABLED (__CET__ & 0x2 )
40
+ # define BOOST_CONTEXT_SHADOW_STACK (SHSTK_ENABLED && SHADOW_STACK_SYSCALL)
41
+ # else
42
+ # define _CET_ENDBR
43
+ # endif
41
44
.file "make_x86_64_sysv_elf_gas.S"
42
45
.text
43
46
.globl make_fcontext
47
+ .hidden make_fcontext
44
48
.type make_fcontext,@function
45
49
.align 16
46
50
make_fcontext:
47
51
_CET_ENDBR
52
+
48
53
#if BOOST_CONTEXT_SHADOW_STACK
49
54
/* the new shadow stack pointer (SSP) */
50
55
movq -0x8 (%rdi ), %r9
@@ -88,7 +93,8 @@ make_fcontext:
88
93
movq %rcx , 0x38 (%rax )
89
94
90
95
#if BOOST_CONTEXT_SHADOW_STACK
91
- /* Populate the shadow stack and normal stack */
96
+ /* Populate the shadow stack */
97
+
92
98
/* get original SSP */
93
99
rdsspq %r8
94
100
/* restore new shadow stack */
@@ -110,6 +116,14 @@ make_fcontext:
110
116
/* save the restore token on the new shadow stack. */
111
117
saveprevssp
112
118
119
+ /* now the new shadow stack looks like:
120
+ base-> +------------------------------+
121
+ | address of "jmp trampoline" |
122
+ SSP-> +------------------------------+
123
+ | restore token |
124
+ +------------------------------+
125
+ */
126
+
113
127
/* reserve space for the new SSP */
114
128
leaq -0x8 (%rax ), %rax
115
129
/* save the new SSP to this fcontext */
@@ -119,9 +133,9 @@ make_fcontext:
119
133
ret /* return pointer to context-data */
120
134
121
135
trampoline:
122
- _CET_ENDBR
123
136
/* store return address on stack */
124
137
/* fix stack alignment */
138
+ _CET_ENDBR
125
139
#if BOOST_CONTEXT_SHADOW_STACK
126
140
/* save address of "jmp *%rbp" as return-address */
127
141
/* on stack and shadow stack */
@@ -145,3 +159,4 @@ finish:
145
159
146
160
/* Mark that we don't need executable stack. */
147
161
.section .note.GNU-stack,"",%progbits
162
+ # endif
0 commit comments