Commit f9b4747785b1a3f3706ac05b872b18654dc8059c
1 parent
4ee37b10
presque apres les trames de pile 64 . 32
Showing
2 changed files
with
159 additions
and
1 deletions
Show diff stats
answerstoquestions
... | ... | @@ -111,7 +111,126 @@ le printf est stocké dans une fonction à l'adresse 0xb7242f00 ? |
111 | 111 | |
112 | 112 | |
113 | 113 | |
114 | -/////////////////////////////////////////////////////////////////////////////////////// | |
114 | +/////////////////////////////////////////////////////////////////////////////////////// 4/5 /////////////////////////////////////////////////////////////////////////// | |
115 | + | |
116 | +Le code du petit programme en assembleur (64 bits) : | |
117 | + | |
118 | +.file "tramedepile.c" | |
119 | + .section .rodata | |
120 | +.LC0: | |
121 | + .string "a+b=%d\n" | |
122 | + .text | |
123 | + .globl addition | |
124 | + .type addition, @function | |
125 | +addition: | |
126 | +.LFB0: | |
127 | + .cfi_startproc | |
128 | + pushq %rbp | |
129 | + .cfi_def_cfa_offset 16 | |
130 | + .cfi_offset 6, -16 | |
131 | + movq %rsp, %rbp | |
132 | + .cfi_def_cfa_register 6 | |
133 | + subq $32, %rsp | |
134 | + movl %edi, -20(%rbp) | |
135 | + movl %esi, -24(%rbp) | |
136 | + movl -20(%rbp), %edx | |
137 | + movl -24(%rbp), %eax | |
138 | + addl %edx, %eax | |
139 | + movl %eax, -4(%rbp) | |
140 | + movl -4(%rbp), %eax | |
141 | + movl %eax, %esi | |
142 | + movl $.LC0, %edi | |
143 | + movl $0, %eax | |
144 | + call printf | |
145 | + leave | |
146 | + .cfi_def_cfa 7, 8 | |
147 | + ret | |
148 | + .cfi_endproc | |
149 | +.LFE0: | |
150 | + .size addition, .-addition | |
151 | + .globl main | |
152 | + .type main, @function | |
153 | +main: | |
154 | +.LFB1: | |
155 | + .cfi_startproc | |
156 | + pushq %rbp | |
157 | + .cfi_def_cfa_offset 16 | |
158 | + .cfi_offset 6, -16 | |
159 | + movq %rsp, %rbp | |
160 | + .cfi_def_cfa_register 6 | |
161 | + movl $1, %esi | |
162 | + movl $1, %edi | |
163 | + call addition | |
164 | + movl $0, %eax | |
165 | + popq %rbp | |
166 | + .cfi_def_cfa 7, 8 | |
167 | + ret | |
168 | + .cfi_endproc | |
169 | +.LFE1: | |
170 | + .size main, .-main | |
171 | + .ident "GCC: (Debian 4.9.2-10) 4.9.2" | |
172 | + .section .note.GNU-stack,"",@progbits | |
173 | + | |
174 | + | |
175 | +rip (8 octets) | |
176 | +rpb (8 octets) | |
177 | +eax/1 (4 octets) | |
178 | +.. (4 octets) | |
179 | +.. (4 octets) | |
180 | +.. (4 octets) | |
181 | +edi/1 (4 octets) | |
182 | +esi/1 (4 octets) | |
183 | +.. (4 octets) | |
184 | + | |
185 | + | |
186 | + | |
187 | + | |
188 | + | |
189 | + | |
190 | +en (normalement) 32 bits : | |
191 | + | |
192 | +.file "tramedepile32.c" | |
193 | + .section .rodata | |
194 | +.LC0: | |
195 | + .string "a+b=%d\n" | |
196 | + .text | |
197 | +.globl addition | |
198 | + .type addition, @function | |
199 | +addition: | |
200 | + pushl %ebp | |
201 | + movl %esp, %ebp | |
202 | + subl $40, %esp | |
203 | + movl 12(%ebp), %eax | |
204 | + movl 8(%ebp), %edx | |
205 | + leal (%edx,%eax), %eax | |
206 | + movl %eax, -12(%ebp) | |
207 | + movl $.LC0, %eax | |
208 | + movl -12(%ebp), %edx | |
209 | + movl %edx, 4(%esp) | |
210 | + movl %eax, (%esp) | |
211 | + call printf | |
212 | + leave | |
213 | + ret | |
214 | + .size addition, .-addition | |
215 | +.globl main | |
216 | + .type main, @function | |
217 | +main: | |
218 | + pushl %ebp | |
219 | + movl %esp, %ebp | |
220 | + andl $-16, %esp | |
221 | + subl $16, %esp | |
222 | + movl $1, 4(%esp) | |
223 | + movl $1, (%esp) | |
224 | + call addition | |
225 | + movl $0, %eax | |
226 | + leave | |
227 | + ret | |
228 | + .size main, .-main | |
229 | + .ident "GCC: (Debian 4.4.5-8) 4.4.5" | |
230 | + .section .note.GNU-stack,"",@progbits | |
231 | + | |
232 | + | |
233 | + | |
115 | 234 | |
116 | 235 | |
117 | 236 | ... | ... |
... | ... | @@ -0,0 +1,39 @@ |
1 | + .file "tramedepile32.c" | |
2 | + .section .rodata | |
3 | +.LC0: | |
4 | + .string "a+b=%d\n" | |
5 | + .text | |
6 | +.globl addition | |
7 | + .type addition, @function | |
8 | +addition: | |
9 | + pushl %ebp | |
10 | + movl %esp, %ebp | |
11 | + subl $40, %esp | |
12 | + movl 12(%ebp), %eax | |
13 | + movl 8(%ebp), %edx | |
14 | + leal (%edx,%eax), %eax | |
15 | + movl %eax, -12(%ebp) | |
16 | + movl $.LC0, %eax | |
17 | + movl -12(%ebp), %edx | |
18 | + movl %edx, 4(%esp) | |
19 | + movl %eax, (%esp) | |
20 | + call printf | |
21 | + leave | |
22 | + ret | |
23 | + .size addition, .-addition | |
24 | +.globl main | |
25 | + .type main, @function | |
26 | +main: | |
27 | + pushl %ebp | |
28 | + movl %esp, %ebp | |
29 | + andl $-16, %esp | |
30 | + subl $16, %esp | |
31 | + movl $1, 4(%esp) | |
32 | + movl $1, (%esp) | |
33 | + call addition | |
34 | + movl $0, %eax | |
35 | + leave | |
36 | + ret | |
37 | + .size main, .-main | |
38 | + .ident "GCC: (Debian 4.4.5-8) 4.4.5" | |
39 | + .section .note.GNU-stack,"",@progbits | ... | ... |