2014-09-15 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
[official-gcc.git] / libsanitizer / asan / asan_asm_instrumentation.S
blob36a9d0b5e9753d5041ebefaca94a986dc8df6beb
1 // This file was generated by gen_asm_instrumentation.sh. Please, do not edit
2 .section .text
3 #if defined(__x86_64__) || defined(__i386__)
4 .globl __asan_report_store1
5 .globl __asan_report_load1
6 .globl __asan_report_store2
7 .globl __asan_report_load2
8 .globl __asan_report_store4
9 .globl __asan_report_load4
10 .globl __asan_report_store8
11 .globl __asan_report_load8
12 .globl __asan_report_store16
13 .globl __asan_report_load16
14 #endif //  defined(__x86_64__) || defined(__i386__)
15 #if defined(__i386__)
16 // Sanitize 1-byte store. Takes one 4-byte address as an argument on
17 // stack, nothing is returned.
18 .globl __sanitizer_sanitize_store1
19 .type __sanitizer_sanitize_store1, @function
20 __sanitizer_sanitize_store1:
21   pushl %ebp
22   movl %esp, %ebp
23   pushl %eax
24   pushl %ecx
25   pushl %edx
26   pushfl
27   movl 8(%ebp), %eax
28   movl %eax, %ecx
29   shrl $0x3, %ecx
30   movb 0x20000000(%ecx), %cl
31   testb %cl, %cl
32   je .sanitize_store1_done
33   movl %eax, %edx
34   andl $0x7, %edx
35   movsbl %cl, %ecx
36   cmpl %ecx, %edx
37   jl .sanitize_store1_done
38   pushl %eax
39   cld
40   emms
41   call __asan_report_store1@PLT
42 .sanitize_store1_done:
43   popfl
44   popl %edx
45   popl %ecx
46   popl %eax
47   leave
48   ret
49 // Sanitize 1-byte load. Takes one 4-byte address as an argument on
50 // stack, nothing is returned.
51 .globl __sanitizer_sanitize_load1
52 .type __sanitizer_sanitize_load1, @function
53 __sanitizer_sanitize_load1:
54   pushl %ebp
55   movl %esp, %ebp
56   pushl %eax
57   pushl %ecx
58   pushl %edx
59   pushfl
60   movl 8(%ebp), %eax
61   movl %eax, %ecx
62   shrl $0x3, %ecx
63   movb 0x20000000(%ecx), %cl
64   testb %cl, %cl
65   je .sanitize_load1_done
66   movl %eax, %edx
67   andl $0x7, %edx
68   movsbl %cl, %ecx
69   cmpl %ecx, %edx
70   jl .sanitize_load1_done
71   pushl %eax
72   cld
73   emms
74   call __asan_report_load1@PLT
75 .sanitize_load1_done:
76   popfl
77   popl %edx
78   popl %ecx
79   popl %eax
80   leave
81   ret
82 // Sanitize 2-byte store. Takes one 4-byte address as an argument on
83 // stack, nothing is returned.
84 .globl __sanitizer_sanitize_store2
85 .type __sanitizer_sanitize_store2, @function
86 __sanitizer_sanitize_store2:
87   pushl %ebp
88   movl %esp, %ebp
89   pushl %eax
90   pushl %ecx
91   pushl %edx
92   pushfl
93   movl 8(%ebp), %eax
94   movl %eax, %ecx
95   shrl $0x3, %ecx
96   movb 0x20000000(%ecx), %cl
97   testb %cl, %cl
98   je .sanitize_store2_done
99   movl %eax, %edx
100   andl $0x7, %edx
101   incl %edx
102   movsbl %cl, %ecx
103   cmpl %ecx, %edx
104   jl .sanitize_store2_done
105   pushl %eax
106   cld
107   emms
108   call __asan_report_store2@PLT
109 .sanitize_store2_done:
110   popfl
111   popl %edx
112   popl %ecx
113   popl %eax
114   leave
115   ret
116 // Sanitize 2-byte load. Takes one 4-byte address as an argument on
117 // stack, nothing is returned.
118 .globl __sanitizer_sanitize_load2
119 .type __sanitizer_sanitize_load2, @function
120 __sanitizer_sanitize_load2:
121   pushl %ebp
122   movl %esp, %ebp
123   pushl %eax
124   pushl %ecx
125   pushl %edx
126   pushfl
127   movl 8(%ebp), %eax
128   movl %eax, %ecx
129   shrl $0x3, %ecx
130   movb 0x20000000(%ecx), %cl
131   testb %cl, %cl
132   je .sanitize_load2_done
133   movl %eax, %edx
134   andl $0x7, %edx
135   incl %edx
136   movsbl %cl, %ecx
137   cmpl %ecx, %edx
138   jl .sanitize_load2_done
139   pushl %eax
140   cld
141   emms
142   call __asan_report_load2@PLT
143 .sanitize_load2_done:
144   popfl
145   popl %edx
146   popl %ecx
147   popl %eax
148   leave
149   ret
150 // Sanitize 4-byte store. Takes one 4-byte address as an argument on
151 // stack, nothing is returned.
152 .globl __sanitizer_sanitize_store4
153 .type __sanitizer_sanitize_store4, @function
154 __sanitizer_sanitize_store4:
155   pushl %ebp
156   movl %esp, %ebp
157   pushl %eax
158   pushl %ecx
159   pushl %edx
160   pushfl
161   movl 8(%ebp), %eax
162   movl %eax, %ecx
163   shrl $0x3, %ecx
164   movb 0x20000000(%ecx), %cl
165   testb %cl, %cl
166   je .sanitize_store4_done
167   movl %eax, %edx
168   andl $0x7, %edx
169   addl $0x3, %edx
170   movsbl %cl, %ecx
171   cmpl %ecx, %edx
172   jl .sanitize_store4_done
173   pushl %eax
174   cld
175   emms
176   call __asan_report_store4@PLT
177 .sanitize_store4_done:
178   popfl
179   popl %edx
180   popl %ecx
181   popl %eax
182   leave
183   ret
184 // Sanitize 4-byte load. Takes one 4-byte address as an argument on
185 // stack, nothing is returned.
186 .globl __sanitizer_sanitize_load4
187 .type __sanitizer_sanitize_load4, @function
188 __sanitizer_sanitize_load4:
189   pushl %ebp
190   movl %esp, %ebp
191   pushl %eax
192   pushl %ecx
193   pushl %edx
194   pushfl
195   movl 8(%ebp), %eax
196   movl %eax, %ecx
197   shrl $0x3, %ecx
198   movb 0x20000000(%ecx), %cl
199   testb %cl, %cl
200   je .sanitize_load4_done
201   movl %eax, %edx
202   andl $0x7, %edx
203   addl $0x3, %edx
204   movsbl %cl, %ecx
205   cmpl %ecx, %edx
206   jl .sanitize_load4_done
207   pushl %eax
208   cld
209   emms
210   call __asan_report_load4@PLT
211 .sanitize_load4_done:
212   popfl
213   popl %edx
214   popl %ecx
215   popl %eax
216   leave
217   ret
218 // Sanitize 8-byte store. Takes one 4-byte address as an argument on
219 // stack, nothing is returned.
220 .globl __sanitizer_sanitize_store8
221 .type __sanitizer_sanitize_store8, @function
222 __sanitizer_sanitize_store8:
223   pushl %ebp
224   movl %esp, %ebp
225   pushl %eax
226   pushl %ecx
227   pushfl
228   movl 8(%ebp), %eax
229   movl %eax, %ecx
230   shrl $0x3, %ecx
231   cmpb $0x0, 0x20000000(%ecx)
232   je .sanitize_store8_done
233   pushl %eax
234   cld
235   emms
236   call __asan_report_store8@PLT
237 .sanitize_store8_done:
238   popfl
239   popl %ecx
240   popl %eax
241   leave
242   ret
243 // Sanitize 8-byte load. Takes one 4-byte address as an argument on
244 // stack, nothing is returned.
245 .globl __sanitizer_sanitize_load8
246 .type __sanitizer_sanitize_load8, @function
247 __sanitizer_sanitize_load8:
248   pushl %ebp
249   movl %esp, %ebp
250   pushl %eax
251   pushl %ecx
252   pushfl
253   movl 8(%ebp), %eax
254   movl %eax, %ecx
255   shrl $0x3, %ecx
256   cmpb $0x0, 0x20000000(%ecx)
257   je .sanitize_load8_done
258   pushl %eax
259   cld
260   emms
261   call __asan_report_load8@PLT
262 .sanitize_load8_done:
263   popfl
264   popl %ecx
265   popl %eax
266   leave
267   ret
268 // Sanitize 16-byte store. Takes one 4-byte address as an argument on
269 // stack, nothing is returned.
270 .globl __sanitizer_sanitize_store16
271 .type __sanitizer_sanitize_store16, @function
272 __sanitizer_sanitize_store16:
273   pushl %ebp
274   movl %esp, %ebp
275   pushl %eax
276   pushl %ecx
277   pushfl
278   movl 8(%ebp), %eax
279   movl %eax, %ecx
280   shrl $0x3, %ecx
281   cmpw $0x0, 0x20000000(%ecx)
282   je .sanitize_store16_done
283   pushl %eax
284   cld
285   emms
286   call __asan_report_store16@PLT
287 .sanitize_store16_done:
288   popfl
289   popl %ecx
290   popl %eax
291   leave
292   ret
293 // Sanitize 16-byte load. Takes one 4-byte address as an argument on
294 // stack, nothing is returned.
295 .globl __sanitizer_sanitize_load16
296 .type __sanitizer_sanitize_load16, @function
297 __sanitizer_sanitize_load16:
298   pushl %ebp
299   movl %esp, %ebp
300   pushl %eax
301   pushl %ecx
302   pushfl
303   movl 8(%ebp), %eax
304   movl %eax, %ecx
305   shrl $0x3, %ecx
306   cmpw $0x0, 0x20000000(%ecx)
307   je .sanitize_load16_done
308   pushl %eax
309   cld
310   emms
311   call __asan_report_load16@PLT
312 .sanitize_load16_done:
313   popfl
314   popl %ecx
315   popl %eax
316   leave
317   ret
318 #endif // defined(__i386__)
319 #if defined(__x86_64__)
320 // Sanitize 1-byte store. Takes one 8-byte address as an argument in %rdi,
321 // nothing is returned.
322 .globl __sanitizer_sanitize_store1
323 .type __sanitizer_sanitize_store1, @function
324 __sanitizer_sanitize_store1:
325   leaq -128(%rsp), %rsp
326   pushq %rax
327   pushq %rcx
328   pushfq
329   movq %rdi, %rax
330   shrq $0x3, %rax
331   movb 0x7fff8000(%rax), %al
332   test %al, %al
333   je .sanitize_store1_done
334   movl %edi, %ecx
335   andl $0x7, %ecx
336   movsbl %al, %eax
337   cmpl %eax, %ecx
338   jl .sanitize_store1_done
339   subq $8, %rsp
340   andq $-16, %rsp
341   cld
342   emms
343   call __asan_report_store1@PLT
344 .sanitize_store1_done:
345   popfq
346   popq %rcx
347   popq %rax
348   leaq 128(%rsp), %rsp
349   ret
350 // Sanitize 1-byte load. Takes one 8-byte address as an argument in %rdi,
351 // nothing is returned.
352 .globl __sanitizer_sanitize_load1
353 .type __sanitizer_sanitize_load1, @function
354 __sanitizer_sanitize_load1:
355   leaq -128(%rsp), %rsp
356   pushq %rax
357   pushq %rcx
358   pushfq
359   movq %rdi, %rax
360   shrq $0x3, %rax
361   movb 0x7fff8000(%rax), %al
362   test %al, %al
363   je .sanitize_load1_done
364   movl %edi, %ecx
365   andl $0x7, %ecx
366   movsbl %al, %eax
367   cmpl %eax, %ecx
368   jl .sanitize_load1_done
369   subq $8, %rsp
370   andq $-16, %rsp
371   cld
372   emms
373   call __asan_report_load1@PLT
374 .sanitize_load1_done:
375   popfq
376   popq %rcx
377   popq %rax
378   leaq 128(%rsp), %rsp
379   ret
380 // Sanitize 2-byte store. Takes one 8-byte address as an argument in %rdi,
381 // nothing is returned.
382 .globl __sanitizer_sanitize_store2
383 .type __sanitizer_sanitize_store2, @function
384 __sanitizer_sanitize_store2:
385   leaq -128(%rsp), %rsp
386   pushq %rax
387   pushq %rcx
388   pushfq
389   movq %rdi, %rax
390   shrq $0x3, %rax
391   movb 0x7fff8000(%rax), %al
392   test %al, %al
393   je .sanitize_store2_done
394   movl %edi, %ecx
395   andl $0x7, %ecx
396   incl %ecx
397   movsbl %al, %eax
398   cmpl %eax, %ecx
399   jl .sanitize_store2_done
400   subq $8, %rsp
401   andq $-16, %rsp
402   cld
403   emms
404   call __asan_report_store2@PLT
405 .sanitize_store2_done:
406   popfq
407   popq %rcx
408   popq %rax
409   leaq 128(%rsp), %rsp
410   ret
411 // Sanitize 2-byte load. Takes one 8-byte address as an argument in %rdi,
412 // nothing is returned.
413 .globl __sanitizer_sanitize_load2
414 .type __sanitizer_sanitize_load2, @function
415 __sanitizer_sanitize_load2:
416   leaq -128(%rsp), %rsp
417   pushq %rax
418   pushq %rcx
419   pushfq
420   movq %rdi, %rax
421   shrq $0x3, %rax
422   movb 0x7fff8000(%rax), %al
423   test %al, %al
424   je .sanitize_load2_done
425   movl %edi, %ecx
426   andl $0x7, %ecx
427   incl %ecx
428   movsbl %al, %eax
429   cmpl %eax, %ecx
430   jl .sanitize_load2_done
431   subq $8, %rsp
432   andq $-16, %rsp
433   cld
434   emms
435   call __asan_report_load2@PLT
436 .sanitize_load2_done:
437   popfq
438   popq %rcx
439   popq %rax
440   leaq 128(%rsp), %rsp
441   ret
442 // Sanitize 4-byte store. Takes one 8-byte address as an argument in %rdi,
443 // nothing is returned.
444 .globl __sanitizer_sanitize_store4
445 .type __sanitizer_sanitize_store4, @function
446 __sanitizer_sanitize_store4:
447   leaq -128(%rsp), %rsp
448   pushq %rax
449   pushq %rcx
450   pushfq
451   movq %rdi, %rax
452   shrq $0x3, %rax
453   movb 0x7fff8000(%rax), %al
454   test %al, %al
455   je .sanitize_store4_done
456   movl %edi, %ecx
457   andl $0x7, %ecx
458   addl $0x3, %ecx
459   movsbl %al, %eax
460   cmpl %eax, %ecx
461   jl .sanitize_store4_done
462   subq $8, %rsp
463   andq $-16, %rsp
464   cld
465   emms
466   call __asan_report_store4@PLT
467 .sanitize_store4_done:
468   popfq
469   popq %rcx
470   popq %rax
471   leaq 128(%rsp), %rsp
472   ret
473 // Sanitize 4-byte load. Takes one 8-byte address as an argument in %rdi,
474 // nothing is returned.
475 .globl __sanitizer_sanitize_load4
476 .type __sanitizer_sanitize_load4, @function
477 __sanitizer_sanitize_load4:
478   leaq -128(%rsp), %rsp
479   pushq %rax
480   pushq %rcx
481   pushfq
482   movq %rdi, %rax
483   shrq $0x3, %rax
484   movb 0x7fff8000(%rax), %al
485   test %al, %al
486   je .sanitize_load4_done
487   movl %edi, %ecx
488   andl $0x7, %ecx
489   addl $0x3, %ecx
490   movsbl %al, %eax
491   cmpl %eax, %ecx
492   jl .sanitize_load4_done
493   subq $8, %rsp
494   andq $-16, %rsp
495   cld
496   emms
497   call __asan_report_load4@PLT
498 .sanitize_load4_done:
499   popfq
500   popq %rcx
501   popq %rax
502   leaq 128(%rsp), %rsp
503   ret
504 // Sanitize 8-byte store. Takes one 8-byte address as an argument in %rdi,
505 // nothing is returned.
506 .globl __sanitizer_sanitize_store8
507 .type __sanitizer_sanitize_store8, @function
508 __sanitizer_sanitize_store8:
509   leaq -128(%rsp), %rsp
510   pushq %rax
511   pushfq
512   movq %rdi, %rax
513   shrq $0x3, %rax
514   cmpb $0x0, 0x7fff8000(%rax)
515   je .sanitize_store8_done
516   subq $8, %rsp
517   andq $-16, %rsp
518   cld
519   emms
520   call __asan_report_store8@PLT
521 .sanitize_store8_done:
522   popfq
523   popq %rax
524   leaq 128(%rsp), %rsp
525   ret
526 // Sanitize 8-byte load. Takes one 8-byte address as an argument in %rdi,
527 // nothing is returned.
528 .globl __sanitizer_sanitize_load8
529 .type __sanitizer_sanitize_load8, @function
530 __sanitizer_sanitize_load8:
531   leaq -128(%rsp), %rsp
532   pushq %rax
533   pushfq
534   movq %rdi, %rax
535   shrq $0x3, %rax
536   cmpb $0x0, 0x7fff8000(%rax)
537   je .sanitize_load8_done
538   subq $8, %rsp
539   andq $-16, %rsp
540   cld
541   emms
542   call __asan_report_load8@PLT
543 .sanitize_load8_done:
544   popfq
545   popq %rax
546   leaq 128(%rsp), %rsp
547   ret
548 // Sanitize 16-byte store. Takes one 8-byte address as an argument in %rdi,
549 // nothing is returned.
550 .globl __sanitizer_sanitize_store16
551 .type __sanitizer_sanitize_store16, @function
552 __sanitizer_sanitize_store16:
553   leaq -128(%rsp), %rsp
554   pushq %rax
555   pushfq
556   movq %rdi, %rax
557   shrq $0x3, %rax
558   cmpw $0x0, 0x7fff8000(%rax)
559   je .sanitize_store16_done
560   subq $8, %rsp
561   andq $-16, %rsp
562   cld
563   emms
564   call __asan_report_store16@PLT
565 .sanitize_store16_done:
566   popfq
567   popq %rax
568   leaq 128(%rsp), %rsp
569   ret
570 // Sanitize 16-byte load. Takes one 8-byte address as an argument in %rdi,
571 // nothing is returned.
572 .globl __sanitizer_sanitize_load16
573 .type __sanitizer_sanitize_load16, @function
574 __sanitizer_sanitize_load16:
575   leaq -128(%rsp), %rsp
576   pushq %rax
577   pushfq
578   movq %rdi, %rax
579   shrq $0x3, %rax
580   cmpw $0x0, 0x7fff8000(%rax)
581   je .sanitize_load16_done
582   subq $8, %rsp
583   andq $-16, %rsp
584   cld
585   emms
586   call __asan_report_load16@PLT
587 .sanitize_load16_done:
588   popfq
589   popq %rax
590   leaq 128(%rsp), %rsp
591   ret
592 #endif // defined(__x86_64__)
593 /* We do not need executable stack. */
594 #if defined(__arm__)
595   .section .note.GNU-stack,"",%progbits
596 #else
597   .section .note.GNU-stack,"",@progbits
598 #endif // defined(__arm__)
599 #endif // __linux__