Commit | Line | Data |
---|---|---|
2ebaa23b AM |
1 | .text |
2 | ||
3 | #; func_locvars | |
4 | #; - function with a space on the stack | |
5 | #; allocated for local variables | |
6 | ||
7 | .type func_locvars,@function | |
8 | func_locvars: | |
9 | .cfi_startproc | |
10 | ||
11 | #; alocate space for local vars | |
12 | sub $0x1234,%esp | |
13 | .cfi_adjust_cfa_offset 0x1234 | |
14 | ||
15 | #; dummy body | |
16 | movl $1,%eax | |
17 | ||
18 | #; release space of local vars and return | |
19 | add $0x1234,%esp | |
20 | .cfi_adjust_cfa_offset -0x1234 | |
21 | ret | |
22 | .cfi_endproc | |
23 | ||
24 | #; func_prologue | |
25 | #; - functions that begins with standard | |
26 | #; prologue: "pushq %rbp; movq %rsp,%rbp" | |
27 | ||
28 | .type func_prologue,@function | |
29 | func_prologue: | |
30 | .cfi_startproc | |
31 | ||
32 | #; prologue, CFI is valid after | |
33 | #; each instruction. | |
34 | pushl %ebp | |
35 | .cfi_def_cfa_offset 8 | |
36 | .cfi_offset ebp,-8 | |
37 | movl %esp, %ebp | |
38 | .cfi_def_cfa_register ebp | |
39 | ||
40 | #; function body | |
41 | call func_locvars | |
42 | addl $3, %eax | |
43 | ||
44 | #; epilogue with valid CFI | |
45 | #; (we're better than gcc :-) | |
46 | leave | |
47 | .cfi_def_cfa_register esp | |
48 | ret | |
49 | .cfi_endproc | |
50 | ||
51 | #; func_otherreg | |
52 | #; - function that moves frame pointer to | |
a60de03c | 53 | #; another register (ebx) and then allocates |
2ebaa23b AM |
54 | #; a space for local variables |
55 | ||
56 | .type func_otherreg,@function | |
57 | func_otherreg: | |
58 | .cfi_startproc | |
59 | ||
60 | #; save frame pointer to ebx | |
61 | mov %esp,%ebx | |
62 | .cfi_def_cfa_register ebx | |
63 | ||
64 | #; alocate space for local vars | |
65 | #; (no .cfi_{def,adjust}_cfa_offset here, | |
a60de03c | 66 | #; because CFA is computed from ebx!) |
2ebaa23b AM |
67 | sub $100,%esp |
68 | ||
69 | #; function body | |
70 | call func_prologue | |
71 | add $2, %eax | |
72 | ||
a60de03c | 73 | #; restore frame pointer from ebx |
2ebaa23b AM |
74 | mov %ebx,%esp |
75 | .cfi_def_cfa esp,4 | |
76 | ret | |
77 | .cfi_endproc | |
78 | ||
79 | #; main | |
80 | #; - typical function | |
81 | .type main,@function | |
82 | main: | |
83 | .cfi_startproc | |
84 | ||
85 | #; only function body that doesn't | |
86 | #; touch the stack at all. | |
87 | call func_otherreg | |
88 | ||
89 | #; return | |
90 | ret | |
91 | .cfi_endproc | |
92 | ||
93 | #; _start | |
94 | #; - standard entry point | |
95 | ||
96 | .type _start,@function | |
97 | .globl _start | |
98 | _start: | |
99 | .cfi_startproc | |
100 | call main | |
101 | movl %eax,%edi | |
102 | movl $0x1,%eax | |
103 | int $0x80 | |
104 | hlt | |
105 | .cfi_endproc | |
a60de03c JB |
106 | |
107 | #; func_all_registers | |
108 | #; - test for all .cfi register numbers. | |
109 | #; This function is never called and the CFI info doesn't make sense. | |
110 | ||
111 | .type func_all_registers,@function | |
112 | func_all_registers: | |
113 | .cfi_startproc simple | |
114 | ||
115 | .cfi_undefined eip ; nop | |
116 | .cfi_undefined eax ; nop | |
117 | .cfi_undefined ecx ; nop | |
118 | .cfi_undefined edx ; nop | |
119 | .cfi_undefined ebx ; nop | |
120 | .cfi_undefined esp ; nop | |
121 | .cfi_undefined ebp ; nop | |
122 | .cfi_undefined esi ; nop | |
123 | .cfi_undefined edi ; nop | |
124 | .cfi_undefined eflags ; nop | |
125 | ||
126 | .cfi_undefined es ; nop | |
127 | .cfi_undefined cs ; nop | |
128 | .cfi_undefined ds ; nop | |
129 | .cfi_undefined ss ; nop | |
130 | .cfi_undefined fs ; nop | |
131 | .cfi_undefined gs ; nop | |
132 | .cfi_undefined tr ; nop | |
133 | .cfi_undefined ldtr ; nop | |
134 | ||
135 | .cfi_undefined mxcsr ; nop | |
136 | .cfi_undefined xmm0 ; nop | |
137 | .cfi_undefined xmm1 ; nop | |
138 | .cfi_undefined xmm2 ; nop | |
139 | .cfi_undefined xmm3 ; nop | |
140 | .cfi_undefined xmm4 ; nop | |
141 | .cfi_undefined xmm5 ; nop | |
142 | .cfi_undefined xmm6 ; nop | |
143 | .cfi_undefined xmm7 ; nop | |
144 | ||
145 | .cfi_undefined fcw ; nop | |
146 | .cfi_undefined fsw ; nop | |
147 | .cfi_undefined st ; nop | |
148 | .cfi_undefined st(1) ; nop | |
149 | .cfi_undefined st(2) ; nop | |
150 | .cfi_undefined st(3) ; nop | |
151 | .cfi_undefined st(4) ; nop | |
152 | .cfi_undefined st(5) ; nop | |
153 | .cfi_undefined st(6) ; nop | |
154 | .cfi_undefined st(7) ; nop | |
155 | ||
156 | .cfi_undefined mm0 ; nop | |
157 | .cfi_undefined mm1 ; nop | |
158 | .cfi_undefined mm2 ; nop | |
159 | .cfi_undefined mm3 ; nop | |
160 | .cfi_undefined mm4 ; nop | |
161 | .cfi_undefined mm5 ; nop | |
162 | .cfi_undefined mm6 ; nop | |
163 | .cfi_undefined mm7 ; nop | |
164 | ||
c0f3af97 L |
165 | .cfi_undefined ymm0 ; nop |
166 | .cfi_undefined ymm1 ; nop | |
167 | .cfi_undefined ymm2 ; nop | |
168 | .cfi_undefined ymm3 ; nop | |
169 | .cfi_undefined ymm4 ; nop | |
170 | .cfi_undefined ymm5 ; nop | |
171 | .cfi_undefined ymm6 ; nop | |
172 | .cfi_undefined ymm7 ; nop | |
173 | ||
a60de03c | 174 | .cfi_endproc |