annotate doc/disas_examples/x86.fastcall_gnu.disas @ 497:cb19b2fe2422

- more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
author Tassilo Philipp
date Wed, 23 Mar 2022 15:24:31 +0100
parents 79e76734bb5c
children fc614cb865c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
470
Tassilo Philipp
parents:
diff changeset
1 ; #include <stdlib.h>
Tassilo Philipp
parents:
diff changeset
2 ;
Tassilo Philipp
parents:
diff changeset
3 ; void __attribute__((fastcall)) leaf_call(int b, int c, int d, int e, int f, int g, int h)
Tassilo Philipp
parents:
diff changeset
4 ; {
Tassilo Philipp
parents:
diff changeset
5 ; }
Tassilo Philipp
parents:
diff changeset
6 ;
Tassilo Philipp
parents:
diff changeset
7 ; void __attribute__((fastcall)) nonleaf_call(int a, int b, int c, int d, int e, int f, int g, int h)
Tassilo Philipp
parents:
diff changeset
8 ; {
Tassilo Philipp
parents:
diff changeset
9 ; /* use some local data */
Tassilo Philipp
parents:
diff changeset
10 ; *(char*)alloca(220) = 'L';
Tassilo Philipp
parents:
diff changeset
11 ; leaf_call(b, c, d, e, f, g, h);
Tassilo Philipp
parents:
diff changeset
12 ; }
Tassilo Philipp
parents:
diff changeset
13 ;
Tassilo Philipp
parents:
diff changeset
14 ; int main()
Tassilo Philipp
parents:
diff changeset
15 ; {
Tassilo Philipp
parents:
diff changeset
16 ; nonleaf_call(0, 1, 2, 3, 4, 5, 6, 7);
Tassilo Philipp
parents:
diff changeset
17 ; return 0;
Tassilo Philipp
parents:
diff changeset
18 ; }
Tassilo Philipp
parents:
diff changeset
19
Tassilo Philipp
parents:
diff changeset
20
Tassilo Philipp
parents:
diff changeset
21
Tassilo Philipp
parents:
diff changeset
22 ; output from alpine_linux-3.11.3-x86 w/ gcc 9.2.0 (w/ flags to simplify: -fno-stack-protector -fno-pic)
Tassilo Philipp
parents:
diff changeset
23
Tassilo Philipp
parents:
diff changeset
24 00001205 <leaf_call>:
Tassilo Philipp
parents:
diff changeset
25 1205: 55 push %ebp ; |
Tassilo Philipp
parents:
diff changeset
26 1206: 89 e5 mov %esp,%ebp ; | prolog
Tassilo Philipp
parents:
diff changeset
27 1208: 83 ec 08 sub $0x8,%esp ; |
Tassilo Philipp
parents:
diff changeset
28 120b: 89 4d fc mov %ecx,-0x4(%ebp) ;
Tassilo Philipp
parents:
diff changeset
29 120e: 89 55 f8 mov %edx,-0x8(%ebp) ;
Tassilo Philipp
parents:
diff changeset
30 1211: 90 nop ;
Tassilo Philipp
parents:
diff changeset
31 1212: c9 leave ; |
Tassilo Philipp
parents:
diff changeset
32 1213: c2 14 00 ret $0x14 ; | epilog
Tassilo Philipp
parents:
diff changeset
33
Tassilo Philipp
parents:
diff changeset
34 00001216 <nonleaf_call>:
Tassilo Philipp
parents:
diff changeset
35 1216: 55 push %ebp ; |
Tassilo Philipp
parents:
diff changeset
36 1217: 89 e5 mov %esp,%ebp ; | prolog
Tassilo Philipp
parents:
diff changeset
37 1219: 83 ec 18 sub $0x18,%esp ; /
Tassilo Philipp
parents:
diff changeset
38 121c: 89 4d f4 mov %ecx,-0xc(%ebp) ; in arg 0 -> local area on stack
Tassilo Philipp
parents:
diff changeset
39 121f: 89 55 f0 mov %edx,-0x10(%ebp) ; in arg 1 -> local area on stack
Tassilo Philipp
parents:
diff changeset
40 1222: b8 10 00 00 00 mov $0x10,%eax ; |
Tassilo Philipp
parents:
diff changeset
41 1227: 83 e8 01 sub $0x1,%eax ; |
Tassilo Philipp
parents:
diff changeset
42 122a: 05 e8 00 00 00 add $0xe8,%eax ; |
Tassilo Philipp
parents:
diff changeset
43 122f: b9 10 00 00 00 mov $0x10,%ecx ; | alloca (seems like 220 is rounded up for stack alignment purposes)
Tassilo Philipp
parents:
diff changeset
44 1234: ba 00 00 00 00 mov $0x0,%edx ; |
Tassilo Philipp
parents:
diff changeset
45 1239: f7 f1 div %ecx ; |
Tassilo Philipp
parents:
diff changeset
46 123b: 6b c0 10 imul $0x10,%eax,%eax ; |
Tassilo Philipp
parents:
diff changeset
47 123e: 29 c4 sub %eax,%esp ; /
Tassilo Philipp
parents:
diff changeset
48 1240: 89 e0 mov %esp,%eax ; \
Tassilo Philipp
parents:
diff changeset
49 1242: 83 c0 0f add $0xf,%eax ; |
Tassilo Philipp
parents:
diff changeset
50 1245: c1 e8 04 shr $0x4,%eax ; | align alloca'd space
Tassilo Philipp
parents:
diff changeset
51 1248: c1 e0 04 shl $0x4,%eax ; |
Tassilo Philipp
parents:
diff changeset
52 124b: c6 00 4c movb $0x4c,(%eax) ; write 'L' to alloca'd space
Tassilo Philipp
parents:
diff changeset
53 124e: 8b 45 f0 mov -0x10(%ebp),%eax ; in arg 1 (from local area) -> eax (then copied to ecx/arg0, below, could be done directly)
Tassilo Philipp
parents:
diff changeset
54 1251: 83 ec 0c sub $0xc,%esp ; @@@ unsure why, alignment?
Tassilo Philipp
parents:
diff changeset
55 1254: ff 75 1c pushl 0x1c(%ebp) ; |
Tassilo Philipp
parents:
diff changeset
56 1257: ff 75 18 pushl 0x18(%ebp) ; |
Tassilo Philipp
parents:
diff changeset
57 125a: ff 75 14 pushl 0x14(%ebp) ; | read in args 3-7 from prev frame's param area, and ...
Tassilo Philipp
parents:
diff changeset
58 125d: ff 75 10 pushl 0x10(%ebp) ; | ... push onto stack as arg 2-6
Tassilo Philipp
parents:
diff changeset
59 1260: ff 75 0c pushl 0xc(%ebp) ; |
Tassilo Philipp
parents:
diff changeset
60 1263: 8b 55 08 mov 0x8(%ebp),%edx ; arg 1 (via reg, read in arg 2 from prev frame's param area)
Tassilo Philipp
parents:
diff changeset
61 1266: 89 c1 mov %eax,%ecx ; arg 0 (via reg)
Tassilo Philipp
parents:
diff changeset
62 1268: e8 98 ff ff ff call 1205 <leaf_call> ; push return address and call
Tassilo Philipp
parents:
diff changeset
63 126d: 83 c4 0c add $0xc,%esp ; @@@ restore esp to what it was before pushing args
Tassilo Philipp
parents:
diff changeset
64 1270: 90 nop ;
Tassilo Philipp
parents:
diff changeset
65 1271: c9 leave ; |
Tassilo Philipp
parents:
diff changeset
66 1272: c2 18 00 ret $0x18 ; | epilog
Tassilo Philipp
parents:
diff changeset
67
Tassilo Philipp
parents:
diff changeset
68 00001275 <main>:
Tassilo Philipp
parents:
diff changeset
69 1275: 8d 4c 24 04 lea 0x4(%esp),%ecx ; |
Tassilo Philipp
parents:
diff changeset
70 1279: 83 e4 f0 and $0xfffffff0,%esp ; | @@@? alignment?
Tassilo Philipp
parents:
diff changeset
71 127c: ff 71 fc pushl -0x4(%ecx) ; | prolog
Tassilo Philipp
parents:
diff changeset
72 127f: 55 push %ebp ; |
Tassilo Philipp
parents:
diff changeset
73 1280: 89 e5 mov %esp,%ebp ; |
Tassilo Philipp
parents:
diff changeset
74 1282: 51 push %ecx ; preserve ecx (so it can be used for passing arg 0)
Tassilo Philipp
parents:
diff changeset
75 1283: 83 ec 04 sub $0x4,%esp ; @@@ unsure why, alignment?
Tassilo Philipp
parents:
diff changeset
76 1286: 83 ec 08 sub $0x8,%esp ; @@@ unsure why, alignment? pointless
Tassilo Philipp
parents:
diff changeset
77 1289: 6a 07 push $0x7 ; arg 7
Tassilo Philipp
parents:
diff changeset
78 128b: 6a 06 push $0x6 ; arg 6
Tassilo Philipp
parents:
diff changeset
79 128d: 6a 05 push $0x5 ; arg 5
Tassilo Philipp
parents:
diff changeset
80 128f: 6a 04 push $0x4 ; arg 4
Tassilo Philipp
parents:
diff changeset
81 1291: 6a 03 push $0x3 ; arg 3
Tassilo Philipp
parents:
diff changeset
82 1293: 6a 02 push $0x2 ; arg 2
Tassilo Philipp
parents:
diff changeset
83 1295: ba 01 00 00 00 mov $0x1,%edx ; arg 1 (via reg)
Tassilo Philipp
parents:
diff changeset
84 129a: b9 00 00 00 00 mov $0x0,%ecx ; arg 0 (via reg)
Tassilo Philipp
parents:
diff changeset
85 129f: e8 72 ff ff ff call 1216 <nonleaf_call> ; push return address and call
Tassilo Philipp
parents:
diff changeset
86 12a4: 83 c4 08 add $0x8,%esp ; @@@ restore one of the two "sub...esp"s above
Tassilo Philipp
parents:
diff changeset
87 12a7: b8 00 00 00 00 mov $0x0,%eax ; return value
Tassilo Philipp
parents:
diff changeset
88 12ac: 8b 4d fc mov -0x4(%ebp),%ecx ; restore ecx
Tassilo Philipp
parents:
diff changeset
89 12af: c9 leave ; |
Tassilo Philipp
parents:
diff changeset
90 12b0: 8d 61 fc lea -0x4(%ecx),%esp ; | epilog
Tassilo Philipp
parents:
diff changeset
91 12b3: c3 ret ; |
Tassilo Philipp
parents:
diff changeset
92
Tassilo Philipp
parents:
diff changeset
93
Tassilo Philipp
parents:
diff changeset
94
Tassilo Philipp
parents:
diff changeset
95 ; ---------- vararg call (shows that all args are pushed) ---------->
Tassilo Philipp
parents:
diff changeset
96
Tassilo Philipp
parents:
diff changeset
97 ; void __attribute__((fastcall)) leaf_call(int a, short b, char c, ...)
Tassilo Philipp
parents:
diff changeset
98 ; {
Tassilo Philipp
parents:
diff changeset
99 ; }
Tassilo Philipp
parents:
diff changeset
100 ;
Tassilo Philipp
parents:
diff changeset
101 ; int main()
Tassilo Philipp
parents:
diff changeset
102 ; {
Tassilo Philipp
parents:
diff changeset
103 ; leaf_call(0, 1, 2, 3, 4, 5, 6, 7LL);
Tassilo Philipp
parents:
diff changeset
104 ; return 0;
Tassilo Philipp
parents:
diff changeset
105 ; }
Tassilo Philipp
parents:
diff changeset
106
Tassilo Philipp
parents:
diff changeset
107
Tassilo Philipp
parents:
diff changeset
108
Tassilo Philipp
parents:
diff changeset
109 ; output from alpine_linux-3.11.3-x86 w/ gcc 9.2.0 (w/ flags to simplify: -fno-stack-protector -fno-pic)
Tassilo Philipp
parents:
diff changeset
110
Tassilo Philipp
parents:
diff changeset
111 00001205 <leaf_call>:
Tassilo Philipp
parents:
diff changeset
112 1205: 55 push %ebp
Tassilo Philipp
parents:
diff changeset
113 1206: 89 e5 mov %esp,%ebp
Tassilo Philipp
parents:
diff changeset
114 1208: 90 nop
Tassilo Philipp
parents:
diff changeset
115 1209: 5d pop %ebp
Tassilo Philipp
parents:
diff changeset
116 120a: c3 ret
Tassilo Philipp
parents:
diff changeset
117
Tassilo Philipp
parents:
diff changeset
118 0000120b <main>:
Tassilo Philipp
parents:
diff changeset
119 120b: 55 push %ebp
Tassilo Philipp
parents:
diff changeset
120 120c: 89 e5 mov %esp,%ebp
Tassilo Philipp
parents:
diff changeset
121 120e: 6a 00 push $0x0
Tassilo Philipp
parents:
diff changeset
122 1210: 6a 07 push $0x7
Tassilo Philipp
parents:
diff changeset
123 1212: 6a 06 push $0x6
Tassilo Philipp
parents:
diff changeset
124 1214: 6a 05 push $0x5
Tassilo Philipp
parents:
diff changeset
125 1216: 6a 04 push $0x4
Tassilo Philipp
parents:
diff changeset
126 1218: 6a 03 push $0x3
Tassilo Philipp
parents:
diff changeset
127 121a: 6a 02 push $0x2
Tassilo Philipp
parents:
diff changeset
128 121c: 6a 01 push $0x1
Tassilo Philipp
parents:
diff changeset
129 121e: 6a 00 push $0x0
Tassilo Philipp
parents:
diff changeset
130 1220: e8 e0 ff ff ff call 1205 <leaf_call>
Tassilo Philipp
parents:
diff changeset
131 1225: 83 c4 24 add $0x24,%esp
Tassilo Philipp
parents:
diff changeset
132 1228: b8 00 00 00 00 mov $0x0,%eax
Tassilo Philipp
parents:
diff changeset
133 122d: c9 leave
Tassilo Philipp
parents:
diff changeset
134 122e: c3 ret
Tassilo Philipp
parents:
diff changeset
135
Tassilo Philipp
parents:
diff changeset
136
Tassilo Philipp
parents:
diff changeset
137
Tassilo Philipp
parents:
diff changeset
138 ; ---------- structs by value (arg and return value), struct arg not fitting in regs ---------->
Tassilo Philipp
parents:
diff changeset
139
Tassilo Philipp
parents:
diff changeset
140 ; struct A { int x; short y; char z; long long t; };
Tassilo Philipp
parents:
diff changeset
141 ;
Tassilo Philipp
parents:
diff changeset
142 ; struct A __attribute__((fastcall)) leaf_call(struct A a, short b, long long c, char d, int e, int f, int g, long long h)
Tassilo Philipp
parents:
diff changeset
143 ; {
Tassilo Philipp
parents:
diff changeset
144 ; a.x += 1;
Tassilo Philipp
parents:
diff changeset
145 ; return a;
Tassilo Philipp
parents:
diff changeset
146 ; }
Tassilo Philipp
parents:
diff changeset
147 ;
Tassilo Philipp
parents:
diff changeset
148 ; int main()
Tassilo Philipp
parents:
diff changeset
149 ; {
Tassilo Philipp
parents:
diff changeset
150 ; struct A a ={9, 99, 23, 12LL};
Tassilo Philipp
parents:
diff changeset
151 ; leaf_call(a, 1, 2, 3, 4, 5, 6, 7LL);
Tassilo Philipp
parents:
diff changeset
152 ; return 0;
Tassilo Philipp
parents:
diff changeset
153 ; }
Tassilo Philipp
parents:
diff changeset
154
Tassilo Philipp
parents:
diff changeset
155
Tassilo Philipp
parents:
diff changeset
156
Tassilo Philipp
parents:
diff changeset
157 ; output from alpine_linux-3.11.3-x86 w/ gcc 9.2.0 (w/ flags to simplify: -fno-stack-protector -fno-pic)
Tassilo Philipp
parents:
diff changeset
158
Tassilo Philipp
parents:
diff changeset
159 00001205 <leaf_call>:
Tassilo Philipp
parents:
diff changeset
160 1205: 55 push %ebp ; |
Tassilo Philipp
parents:
diff changeset
161 1206: 89 e5 mov %esp,%ebp ; | prolog
Tassilo Philipp
parents:
diff changeset
162 1208: 83 ec 20 sub $0x20,%esp ; |
Tassilo Philipp
parents:
diff changeset
163 120b: 89 4d fc mov %ecx,-0x4(%ebp) ; ptr to retval space for struct (hidden first arg) -> local area
Tassilo Philipp
parents:
diff changeset
164 120e: 8b 45 18 mov 0x18(%ebp),%eax ;
Tassilo Philipp
parents:
diff changeset
165 1211: 8b 55 24 mov 0x24(%ebp),%edx ;
Tassilo Philipp
parents:
diff changeset
166 1214: 66 89 45 f8 mov %ax,-0x8(%ebp) ;
Tassilo Philipp
parents:
diff changeset
167 1218: 8b 45 1c mov 0x1c(%ebp),%eax ;
Tassilo Philipp
parents:
diff changeset
168 121b: 89 45 f0 mov %eax,-0x10(%ebp) ;
Tassilo Philipp
parents:
diff changeset
169 121e: 8b 45 20 mov 0x20(%ebp),%eax ;
Tassilo Philipp
parents:
diff changeset
170 1221: 89 45 f4 mov %eax,-0xc(%ebp) ;
Tassilo Philipp
parents:
diff changeset
171 1224: 89 d0 mov %edx,%eax ;
Tassilo Philipp
parents:
diff changeset
172 1226: 88 45 ec mov %al,-0x14(%ebp) ;
Tassilo Philipp
parents:
diff changeset
173 1229: 8b 45 34 mov 0x34(%ebp),%eax ;
Tassilo Philipp
parents:
diff changeset
174 122c: 89 45 e0 mov %eax,-0x20(%ebp) ;
Tassilo Philipp
parents:
diff changeset
175 122f: 8b 45 38 mov 0x38(%ebp),%eax ;
Tassilo Philipp
parents:
diff changeset
176 1232: 89 45 e4 mov %eax,-0x1c(%ebp) ;
Tassilo Philipp
parents:
diff changeset
177 1235: 8b 45 08 mov 0x8(%ebp),%eax ; |
Tassilo Philipp
parents:
diff changeset
178 1238: 83 c0 01 add $0x1,%eax ; | a.x += 1 (written to param area of prev frame)
Tassilo Philipp
parents:
diff changeset
179 123b: 89 45 08 mov %eax,0x8(%ebp) ; /
Tassilo Philipp
parents:
diff changeset
180 123e: 8b 45 fc mov -0x4(%ebp),%eax ; \ ptr to retval space
Tassilo Philipp
parents:
diff changeset
181 1241: 8b 55 08 mov 0x8(%ebp),%edx ; |
Tassilo Philipp
parents:
diff changeset
182 1244: 89 10 mov %edx,(%eax) ; |
Tassilo Philipp
parents:
diff changeset
183 1246: 8b 55 0c mov 0xc(%ebp),%edx ; |
Tassilo Philipp
parents:
diff changeset
184 1249: 89 50 04 mov %edx,0x4(%eax) ; | copy struct from param area in prev frame to retval space
Tassilo Philipp
parents:
diff changeset
185 124c: 8b 55 10 mov 0x10(%ebp),%edx ; |
Tassilo Philipp
parents:
diff changeset
186 124f: 89 50 08 mov %edx,0x8(%eax) ; |
Tassilo Philipp
parents:
diff changeset
187 1252: 8b 55 14 mov 0x14(%ebp),%edx ; |
Tassilo Philipp
parents:
diff changeset
188 1255: 89 50 0c mov %edx,0xc(%eax) ; |
Tassilo Philipp
parents:
diff changeset
189 1258: 8b 45 fc mov -0x4(%ebp),%eax ; return value (passed-in hidden ptr)
Tassilo Philipp
parents:
diff changeset
190 125b: c9 leave ; |
Tassilo Philipp
parents:
diff changeset
191 125c: c2 34 00 ret $0x34 ; | epilog
Tassilo Philipp
parents:
diff changeset
192
Tassilo Philipp
parents:
diff changeset
193 0000125f <main>:
Tassilo Philipp
parents:
diff changeset
194 125f: 8d 4c 24 04 lea 0x4(%esp),%ecx ; |
Tassilo Philipp
parents:
diff changeset
195 1263: 83 e4 f0 and $0xfffffff0,%esp ; |
Tassilo Philipp
parents:
diff changeset
196 1266: ff 71 fc pushl -0x4(%ecx) ; | prolog
Tassilo Philipp
parents:
diff changeset
197 1269: 55 push %ebp ; |
Tassilo Philipp
parents:
diff changeset
198 126a: 89 e5 mov %esp,%ebp ; |
Tassilo Philipp
parents:
diff changeset
199 126c: 51 push %ecx ; preserve ecx (so it can be used for passing arg 0)
Tassilo Philipp
parents:
diff changeset
200 126d: 83 ec 24 sub $0x24,%esp ; reserve stack space for struct (local area)
Tassilo Philipp
parents:
diff changeset
201 1270: c7 45 e8 09 00 00 00 movl $0x9,-0x18(%ebp) ; | int x
Tassilo Philipp
parents:
diff changeset
202 1277: 66 c7 45 ec 63 00 movw $0x63,-0x14(%ebp) ; | short y
Tassilo Philipp
parents:
diff changeset
203 127d: c6 45 ee 17 movb $0x17,-0x12(%ebp) ; | struct values (local area) char z
Tassilo Philipp
parents:
diff changeset
204 1281: c7 45 f0 0c 00 00 00 movl $0xc,-0x10(%ebp) ; | |
Tassilo Philipp
parents:
diff changeset
205 1288: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) ; | | long long t
Tassilo Philipp
parents:
diff changeset
206 128f: 8d 45 d8 lea -0x28(%ebp),%eax ; ptr to space used for struct retval (passed as hidden first arg) -> eax
Tassilo Philipp
parents:
diff changeset
207 1292: 83 ec 04 sub $0x4,%esp ; @@@ unsure why, alignment? (also needed so what's in eax doesn't point below esp)
Tassilo Philipp
parents:
diff changeset
208 1295: 6a 00 push $0x0 ; |
Tassilo Philipp
parents:
diff changeset
209 1297: 6a 07 push $0x7 ; | arg 7
Tassilo Philipp
parents:
diff changeset
210 1299: 6a 06 push $0x6 ; arg 6
Tassilo Philipp
parents:
diff changeset
211 129b: 6a 05 push $0x5 ; arg 5
Tassilo Philipp
parents:
diff changeset
212 129d: 6a 04 push $0x4 ; arg 4
Tassilo Philipp
parents:
diff changeset
213 129f: 6a 03 push $0x3 ; arg 3
Tassilo Philipp
parents:
diff changeset
214 12a1: 6a 00 push $0x0 ; |
Tassilo Philipp
parents:
diff changeset
215 12a3: 6a 02 push $0x2 ; | arg 2 (via stack b/c not first arg and > 32 bits)
Tassilo Philipp
parents:
diff changeset
216 12a5: 6a 01 push $0x1 ; arg 1
Tassilo Philipp
parents:
diff changeset
217 12a7: ff 75 f4 pushl -0xc(%ebp) ; |
Tassilo Philipp
parents:
diff changeset
218 12aa: ff 75 f0 pushl -0x10(%ebp) ; | arg 0 (struct by value, pushed onto stack)
Tassilo Philipp
parents:
diff changeset
219 12ad: ff 75 ec pushl -0x14(%ebp) ; |
Tassilo Philipp
parents:
diff changeset
220 12b0: ff 75 e8 pushl -0x18(%ebp) ; |
Tassilo Philipp
parents:
diff changeset
221 12b3: 89 c1 mov %eax,%ecx ; ptr to free space for call's retval (struct), hidden first arg
Tassilo Philipp
parents:
diff changeset
222 12b5: e8 4b ff ff ff call 1205 <leaf_call> ; push return address and call
Tassilo Philipp
parents:
diff changeset
223 12ba: 83 c4 04 add $0x4,%esp ; @@@ restore esp to what it was before pushing args
Tassilo Philipp
parents:
diff changeset
224 12bd: b8 00 00 00 00 mov $0x0,%eax ; return value
Tassilo Philipp
parents:
diff changeset
225 12c2: 8b 4d fc mov -0x4(%ebp),%ecx ; restore ecx
Tassilo Philipp
parents:
diff changeset
226 12c5: c9 leave ; |
Tassilo Philipp
parents:
diff changeset
227 12c6: 8d 61 fc lea -0x4(%ecx),%esp ; | epilog
Tassilo Philipp
parents:
diff changeset
228 12c9: c3 ret ; |
Tassilo Philipp
parents:
diff changeset
229
Tassilo Philipp
parents:
diff changeset
230
Tassilo Philipp
parents:
diff changeset
231
Tassilo Philipp
parents:
diff changeset
232 ; ---------- small struct returned by value (shows it's never returned via regs) ---------->
Tassilo Philipp
parents:
diff changeset
233
Tassilo Philipp
parents:
diff changeset
234 ; struct A { short x; short y; };
Tassilo Philipp
parents:
diff changeset
235 ;
Tassilo Philipp
parents:
diff changeset
236 ; struct A __attribute__((fastcall)) leaf_call(int a, int b)
Tassilo Philipp
parents:
diff changeset
237 ; {
Tassilo Philipp
parents:
diff changeset
238 ; struct A r = { 13, 15 };
Tassilo Philipp
parents:
diff changeset
239 ; return r;
Tassilo Philipp
parents:
diff changeset
240 ; }
Tassilo Philipp
parents:
diff changeset
241 ;
Tassilo Philipp
parents:
diff changeset
242 ; int main()
Tassilo Philipp
parents:
diff changeset
243 ; {
Tassilo Philipp
parents:
diff changeset
244 ; leaf_call(99, 2);
Tassilo Philipp
parents:
diff changeset
245 ; return 0;
Tassilo Philipp
parents:
diff changeset
246 ; }
Tassilo Philipp
parents:
diff changeset
247
Tassilo Philipp
parents:
diff changeset
248
Tassilo Philipp
parents:
diff changeset
249
Tassilo Philipp
parents:
diff changeset
250 ; output from alpine_linux-3.11.3-x86 w/ gcc 9.2.0 (w/ flags to simplify: -fno-stack-protector -fno-pic)
Tassilo Philipp
parents:
diff changeset
251
Tassilo Philipp
parents:
diff changeset
252 00001205 <leaf_call>:
Tassilo Philipp
parents:
diff changeset
253 1205: 55 push %ebp ; |
Tassilo Philipp
parents:
diff changeset
254 1206: 89 e5 mov %esp,%ebp ; | prolog
Tassilo Philipp
parents:
diff changeset
255 1208: 83 ec 18 sub $0x18,%esp ; |
Tassilo Philipp
parents:
diff changeset
256 120b: 89 4d ec mov %ecx,-0x14(%ebp) ; ptr to retval space for struct (hidden first arg) -> local area
Tassilo Philipp
parents:
diff changeset
257 120e: 89 55 e8 mov %edx,-0x18(%ebp) ; in arg 0 -> local area
Tassilo Philipp
parents:
diff changeset
258 1211: 66 c7 45 fc 0d 00 movw $0xd,-0x4(%ebp) ; |
Tassilo Philipp
parents:
diff changeset
259 1217: 66 c7 45 fe 0f 00 movw $0xf,-0x2(%ebp) ; | struct values (local area)
Tassilo Philipp
parents:
diff changeset
260 121d: 8b 45 ec mov -0x14(%ebp),%eax ; ptr to retval space for struct (fetched from local area) -> eax
Tassilo Philipp
parents:
diff changeset
261 1220: 8b 55 fc mov -0x4(%ebp),%edx ; |
Tassilo Philipp
parents:
diff changeset
262 1223: 89 10 mov %edx,(%eax) ; | copy struct in local area to retval space
Tassilo Philipp
parents:
diff changeset
263 1225: 8b 45 ec mov -0x14(%ebp),%eax ; return value (passed-in hidden ptr)
Tassilo Philipp
parents:
diff changeset
264 1228: c9 leave ; |
Tassilo Philipp
parents:
diff changeset
265 1229: c2 04 00 ret $0x4 ; | epilog
Tassilo Philipp
parents:
diff changeset
266
Tassilo Philipp
parents:
diff changeset
267 0000122c <main>:
Tassilo Philipp
parents:
diff changeset
268 122c: 55 push %ebp ; |
Tassilo Philipp
parents:
diff changeset
269 122d: 89 e5 mov %esp,%ebp ; | prolog
Tassilo Philipp
parents:
diff changeset
270 122f: 83 ec 04 sub $0x4,%esp ; |
Tassilo Philipp
parents:
diff changeset
271 1232: 8d 45 fc lea -0x4(%ebp),%eax ; ptr to space used for struct retval (passed as hidden first arg)
Tassilo Philipp
parents:
diff changeset
272 1235: 6a 02 push $0x2 ; arg 1
Tassilo Philipp
parents:
diff changeset
273 1237: ba 63 00 00 00 mov $0x63,%edx ; arg 0 (via reg)
Tassilo Philipp
parents:
diff changeset
274 123c: 89 c1 mov %eax,%ecx ; ptr to free space for call's retval (struct), hidden first arg
Tassilo Philipp
parents:
diff changeset
275 123e: e8 c2 ff ff ff call 1205 <leaf_call> ; push return address and call
Tassilo Philipp
parents:
diff changeset
276 1243: b8 00 00 00 00 mov $0x0,%eax ; return value
Tassilo Philipp
parents:
diff changeset
277 1248: c9 leave ; |
Tassilo Philipp
parents:
diff changeset
278 1249: c3 ret ; | epilog
Tassilo Philipp
parents:
diff changeset
279
Tassilo Philipp
parents:
diff changeset
280
Tassilo Philipp
parents:
diff changeset
281
497
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
282 ; ---------- C++ trivial and non-trivial aggrs passed to C funcs ---------->
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
283 ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
284 ; struct Trivial { int a; };
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
285 ; struct NonTrivial {
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
286 ; int a;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
287 ; __attribute__((fastcall)) NonTrivial() : a(0) {}
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
288 ; __attribute__((fastcall)) NonTrivial(const NonTrivial& rhs) : a(rhs.a) { }
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
289 ; };
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
290 ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
291 ; extern "C" {
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
292 ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
293 ; void __attribute__((fastcall)) f1(struct Trivial s) { }
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
294 ; void __attribute__((fastcall)) f2(struct NonTrivial s) { }
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
295 ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
296 ; void __attribute__((fastcall)) f()
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
297 ; {
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
298 ; struct Trivial t;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
299 ; struct NonTrivial n;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
300 ; int a=1;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
301 ; a += 123;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
302 ; f1(t);
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
303 ; a -= 123;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
304 ; f2(n);
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
305 ; a -= 12;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
306 ; }
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
307 ; }
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
308
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
309
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
310
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
311 ; output from alpine_linux-3.11.3-x86 w/ gcc 9.2.0
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
312
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
313 00001215 <f1>:
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
314 1215: 55 push %ebp
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
315 1216: 89 e5 mov %esp,%ebp
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
316 1218: e8 f0 ff ff ff call 120d <__x86.get_pc_thunk.ax>
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
317 121d: 05 af 2d 00 00 add $0x2daf,%eax
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
318 1222: 90 nop
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
319 1223: 5d pop %ebp
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
320 1224: c2 04 00 ret $0x4
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
321
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
322 00001227 <f2>:
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
323 1227: 55 push %ebp
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
324 1228: 89 e5 mov %esp,%ebp
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
325 122a: 83 ec 04 sub $0x4,%esp
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
326 122d: e8 db ff ff ff call 120d <__x86.get_pc_thunk.ax>
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
327 1232: 05 9a 2d 00 00 add $0x2d9a,%eax
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
328 1237: 89 4d fc mov %ecx,-0x4(%ebp)
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
329 123a: 90 nop
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
330 123b: c9 leave
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
331 123c: c3 ret
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
332
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
333 0000123d <f>:
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
334 123d: 55 push %ebp ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
335 123e: 89 e5 mov %esp,%ebp ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
336 1240: 83 ec 28 sub $0x28,%esp ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
337 1243: e8 c5 ff ff ff call 120d <__x86.get_pc_thunk.ax> ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
338 1248: 05 84 2d 00 00 add $0x2d84,%eax ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
339 124d: 65 a1 14 00 00 00 mov %gs:0x14,%eax ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
340 1253: 89 45 f4 mov %eax,-0xc(%ebp) ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
341 1256: 31 c0 xor %eax,%eax ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
342 1258: 8d 45 e8 lea -0x18(%ebp),%eax ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
343 125b: 89 c1 mov %eax,%ecx ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
344 125d: e8 60 00 00 00 call 12c2 <_ZN10NonTrivialC1Ev> ; NonTrivial::NonTrivial() / ctor
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
345 1262: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
346 1269: 83 45 f0 7b addl $0x7b,-0x10(%ebp) ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
347 126d: 83 ec 0c sub $0xc,%esp ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
348 1270: ff 75 e4 pushl -0x1c(%ebp) ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
349 1273: e8 9d ff ff ff call 1215 <f1> ; call f1(struct Trivial)
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
350 1278: 83 c4 0c add $0xc,%esp ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
351 127b: 83 6d f0 7b subl $0x7b,-0x10(%ebp) ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
352 127f: 8d 55 e8 lea -0x18(%ebp),%edx ; | ptr to n
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
353 1282: 8d 45 ec lea -0x14(%ebp),%eax ; | |
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
354 1285: 89 c1 mov %eax,%ecx ; | copy n | ptr to dest of copy of n
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
355 1287: e8 56 00 00 00 call 12e2 <_ZN10NonTrivialC1ERKS_> ; / NonTrivial::NonTrivial(const NonTrivial&) / copy ctor
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
356 128c: 8d 45 ec lea -0x14(%ebp),%eax ; \
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
357 128f: 89 c1 mov %eax,%ecx ; | f2 arg 0 (ptr to copy of struct NonTrivial), via ptr as non-trivial
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
358 1291: e8 91 ff ff ff call 1227 <f2> ; call f2(struct NonTrivial)
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
359 1296: 83 6d f0 0c subl $0xc,-0x10(%ebp) ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
360 129a: 90 nop ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
361 129b: 8b 45 f4 mov -0xc(%ebp),%eax ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
362 129e: 65 33 05 14 00 00 00 xor %gs:0x14,%eax ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
363 12a5: 74 05 je 12ac <f+0x6f> ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
364 12a7: e8 59 00 00 00 call 1305 <__stack_chk_fail_local> ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
365 12ac: c9 leave ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
366 12ad: c3 ret ;
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
367
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
368 ; ... snip, removed code of ctor and copy ctor ...
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
369
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
370
cb19b2fe2422 - more disas examples to check behaviour of passing C++ non-trivial aggregates by value; they all behave the same, calling the copy ctor first, passing a pointer then
Tassilo Philipp
parents: 470
diff changeset
371
470
Tassilo Philipp
parents:
diff changeset
372 ; vim: ft=asm
Tassilo Philipp
parents:
diff changeset
373