1 /* { dg-do run { target *-*-linux* *-*-gnu* } } */
2 /* { dg-options "-fexceptions -fnon-call-exceptions -fasynchronous-unwind-tables -O2" } */
3 /* Test complex CFA value expressions. */
12 static _Unwind_Reason_Code
13 force_unwind_stop (int version
, _Unwind_Action actions
,
14 _Unwind_Exception_Class exc_class
,
15 struct _Unwind_Exception
*exc_obj
,
16 struct _Unwind_Context
*context
,
19 if (actions
& _UA_END_OF_STACK
)
21 return _URC_NO_REASON
;
27 struct _Unwind_Exception
*exc
= malloc (sizeof (*exc
));
28 memset (&exc
->exception_class
, 0, sizeof (exc
->exception_class
));
29 exc
->exception_cleanup
= 0;
31 _Unwind_ForcedUnwind (exc
, force_unwind_stop
, 0);
38 counter (void *p
__attribute__((unused
)))
44 handler (void *p
__attribute__((unused
)))
52 __attribute__((noinline
))
59 static int __attribute__((noinline
))
62 char dummy
__attribute__((cleanup (counter
)));
70 char dummy
__attribute__((cleanup (counter
)));
71 unsigned long tmp
[4] __attribute__((aligned(16)));
72 check ((intptr_t) tmp
);
76 void __attribute__((noinline
))
85 ".type _L_mutex_lock_%=, @function\n"
87 "1:\t" "leal %1, %%ecx\n"
90 "4:\t" ".size _L_mutex_lock_%=, .-_L_mutex_lock_%=\n\t"
92 ".section .eh_frame,\"a\",@progbits\n"
93 "5:\t" ".long 7f-6f # Length of Common Information Entry\n"
94 "6:\t" ".long 0x0 # CIE Identifier Tag\n\t"
95 ".byte 0x1 # CIE Version\n\t"
96 ".ascii \"zR\\0\" # CIE Augmentation\n\t"
97 ".uleb128 0x1 # CIE Code Alignment Factor\n\t"
98 ".sleb128 -4 # CIE Data Alignment Factor\n\t"
99 ".byte 0x8 # CIE RA Column\n\t"
100 ".uleb128 0x1 # Augmentation size\n\t"
101 ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t"
102 ".byte 0xc # DW_CFA_def_cfa\n\t"
106 "7:\t" ".long 17f-8f # FDE Length\n"
107 "8:\t" ".long 8b-5b # FDE CIE offset\n\t"
108 ".long 1b-. # FDE initial location\n\t"
109 ".long 4b-1b # FDE address range\n\t"
110 ".uleb128 0x0 # Augmentation size\n\t"
111 ".byte 0x16 # DW_CFA_val_expression\n\t"
114 "9:\t" ".byte 0x78 # DW_OP_breg8\n\t"
116 "10:\t" ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t"
117 ".byte 0x16 # DW_CFA_val_expression\n\t"
120 "11:\t" ".byte 0x78 # DW_OP_breg8\n\t"
122 "12:\t" ".byte 0x40 + (3b-2b-1) # DW_CFA_advance_loc\n\t"
123 ".byte 0x16 # DW_CFA_val_expression\n\t"
126 "13:\t" ".byte 0x78 # DW_OP_breg8\n\t"
127 ".sleb128 15f-14f\n\t"
128 ".byte 0x0d # DW_OP_const4s\n"
129 "14:\t" ".4byte 3b-.\n\t"
130 ".byte 0x1c # DW_OP_minus\n\t"
131 ".byte 0x0d # DW_OP_const4s\n"
132 "15:\t" ".4byte 18f-.\n\t"
133 ".byte 0x22 # DW_OP_plus\n"
135 "17:\t" ".previous\n"
137 : : "r" (x
), "m" (x
), "r" (buf
)
138 : "memory", "eax", "edx", "ecx");
139 #elif defined __x86_64__
144 ".type _L_mutex_lock_%=, @function\n"
145 "_L_mutex_lock_%=:\n"
146 "1:\t" "leaq %1, %%rdi\n"
147 "2:\t" "subq $136, %%rsp\n"
149 "4:\t" "addq $136, %%rsp\n"
151 "6:\t" ".size _L_mutex_lock_%=, .-_L_mutex_lock_%=\n\t"
153 ".section .eh_frame,\"a\",@progbits\n"
154 "7:\t" ".long 9f-8f # Length of Common Information Entry\n"
155 "8:\t" ".long 0x0 # CIE Identifier Tag\n\t"
156 ".byte 0x1 # CIE Version\n\t"
157 ".ascii \"zR\\0\" # CIE Augmentation\n\t"
158 ".uleb128 0x1 # CIE Code Alignment Factor\n\t"
159 ".sleb128 -8 # CIE Data Alignment Factor\n\t"
160 ".byte 0x10 # CIE RA Column\n\t"
161 ".uleb128 0x1 # Augmentation size\n\t"
162 ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t"
163 ".byte 0x12 # DW_CFA_def_cfa_sf\n\t"
167 "9:\t" ".long 23f-10f # FDE Length\n"
168 "10:\t" ".long 10b-7b # FDE CIE offset\n\t"
169 ".long 1b-. # FDE initial location\n\t"
170 ".long 6b-1b # FDE address range\n\t"
171 ".uleb128 0x0 # Augmentation size\n\t"
172 ".byte 0x16 # DW_CFA_val_expression\n\t"
175 "11:\t" ".byte 0x80 # DW_OP_breg16\n\t"
177 "12:\t" ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t"
178 ".byte 0x16 # DW_CFA_val_expression\n\t"
181 "13:\t" ".byte 0x80 # DW_OP_breg16\n\t"
183 "14:\t" ".byte 0x40 + (3b-2b) # DW_CFA_advance_loc\n\t"
184 ".byte 0x0e # DW_CFA_def_cfa_offset\n\t"
186 ".byte 0x16 # DW_CFA_val_expression\n\t"
189 "15:\t" ".byte 0x80 # DW_OP_breg16\n\t"
191 "16:\t" ".byte 0x40 + (4b-3b-1) # DW_CFA_advance_loc\n\t"
192 ".byte 0x0e # DW_CFA_def_cfa_offset\n\t"
194 ".byte 0x16 # DW_CFA_val_expression\n\t"
197 "17:\t" ".byte 0x80 # DW_OP_breg16\n\t"
198 ".sleb128 19f-18f\n\t"
199 ".byte 0x0d # DW_OP_const4s\n"
200 "18:\t" ".4byte 4b-.\n\t"
201 ".byte 0x1c # DW_OP_minus\n\t"
202 ".byte 0x0d # DW_OP_const4s\n"
203 "19:\t" ".4byte 24f-.\n\t"
204 ".byte 0x22 # DW_OP_plus\n"
205 "20:\t" ".byte 0x40 + (5b-4b+1) # DW_CFA_advance_loc\n\t"
206 ".byte 0x13 # DW_CFA_def_cfa_offset_sf\n\t"
208 ".byte 0x16 # DW_CFA_val_expression\n\t"
211 "21:\t" ".byte 0x80 # DW_OP_breg16\n\t"
214 "23:\t" ".previous\n"
216 : : "r" (x
), "m" (x
), "r" (buf
)
217 : "memory", "rax", "rdx", "rcx", "rsi", "rdi",
218 "r8", "r9", "r10", "r11");
220 # error Unsupported test architecture
224 static int __attribute__((noinline
))
231 static int __attribute__((noinline
))
241 char dummy
__attribute__((cleanup (handler
)));