File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 9
9
# }
10
10
_Py_trampoline_func_start:
11
11
#ifdef __x86_64__
12
+ #if defined(__CET__) && (__CET__ & 1 )
13
+ endbr64
14
+ #endif
12
15
sub $ 8 , % rsp
13
16
call * % rcx
14
17
add $ 8 , % rsp
@@ -34,3 +37,22 @@ _Py_trampoline_func_start:
34
37
.globl _Py_trampoline_func_end
35
38
_Py_trampoline_func_end:
36
39
. section .note.GNU - stack , "" , @progbits
40
+ # Note for indicating the assembly code supports CET
41
+ #if defined(__x86_64__) && defined(__CET__) && (__CET__ & 1 )
42
+ . section .note.gnu.property , "a"
43
+ . align 8
44
+ .long 1f - 0f
45
+ .long 4f - 1f
46
+ .long 5
47
+ 0 :
48
+ .string "GNU"
49
+ 1 :
50
+ . align 8
51
+ .long 0xc0000002
52
+ .long 3f - 2f
53
+ 2 :
54
+ .long 0x3
55
+ 3 :
56
+ . align 8
57
+ 4 :
58
+ #endif // __x86_64__
Original file line number Diff line number Diff line change @@ -869,7 +869,11 @@ static void elf_init_ehframe(ELFObjectContext* ctx) {
869
869
*/
870
870
#ifdef __x86_64__
871
871
/* x86_64 calling convention unwinding rules */
872
+ # if defined(__CET__ ) && (__CET__ & 1 )
873
+ DWRF_U8 (DWRF_CFA_advance_loc | 8 ); // Advance location by 8 bytes when CET protection is enabled
874
+ # else
872
875
DWRF_U8 (DWRF_CFA_advance_loc | 4 ); // Advance location by 4 bytes
876
+ # endif
873
877
DWRF_U8 (DWRF_CFA_def_cfa_offset ); // Redefine CFA offset
874
878
DWRF_UV (16 ); // New offset: SP + 16
875
879
DWRF_U8 (DWRF_CFA_advance_loc | 6 ); // Advance location by 6 bytes
You can’t perform that action at this time.
0 commit comments