-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathec440threads.h
More file actions
49 lines (43 loc) · 990 Bytes
/
ec440threads.h
File metadata and controls
49 lines (43 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef __EC440THREADS__
#define __EC440THREADS__
/*
* This file is derived from code provided by Prof. Egele
*/
static unsigned long int ptr_demangle(unsigned long int p)
{
unsigned long int ret;
asm("movq %1, %%rax;\n"
"rorq $0x11, %%rax;"
"xorq %%fs:0x30, %%rax;"
"movq %%rax, %0;"
: "=r"(ret)
: "r"(p)
: "%rax"
);
return ret;
}
static unsigned long int ptr_mangle(unsigned long int p)
{
unsigned long int ret;
asm("movq %1, %%rax;\n"
"xorq %%fs:0x30, %%rax;"
"rolq $0x11, %%rax;"
"movq %%rax, %0;"
: "=r"(ret)
: "r"(p)
: "%rax"
);
return ret;
}
static void *start_thunk() {
asm("popq %%rbp;\n" //clean up the function prologue
"movq %%r13, %%rdi;\n" //put arg in $rdi
"pushq %%r12;\n" //push &start_routine
"retq;\n" //return to &start_routine
:
:
: "%rdi"
);
__builtin_unreachable();
}
#endif