Index: lib/asan/asan_asm_instrumentation.S =================================================================== --- lib/asan/asan_asm_instrumentation.S +++ lib/asan/asan_asm_instrumentation.S @@ -1,6 +1,7 @@ // This file was generated by gen_asm_instrumentation.sh. Please, do not edit // manually. #ifdef __linux__ +.intel_syntax noprefix; .section .text #if defined(__x86_64__) || defined(__i386__) .globl __asan_report_store1 @@ -20,32 +21,32 @@ .globl __sanitizer_sanitize_store1 .type __sanitizer_sanitize_store1, @function __sanitizer_sanitize_store1: - pushl %ebp - movl %esp, %ebp - pushl %eax - pushl %ecx - pushl %edx - pushfl - movl 8(%ebp), %eax - movl %eax, %ecx - shrl $0x3, %ecx - movb 0x20000000(%ecx), %cl - testb %cl, %cl + push ebp + mov ebp, esp + push eax + push ecx + push edx + pushfd + mov eax, dword ptr [ebp + 8] + mov ecx, eax + shr ecx, 0x3 + mov cl, byte ptr [ecx + 0x20000000] + test cl, cl je .sanitize_store1_done - movl %eax, %edx - andl $0x7, %edx - movsbl %cl, %ecx - cmpl %ecx, %edx + mov edx, eax + and edx, 0x7 + movsx ecx, cl + cmp edx, ecx jl .sanitize_store1_done - pushl %eax + push eax cld emms call __asan_report_store1@PLT .sanitize_store1_done: - popfl - popl %edx - popl %ecx - popl %eax + popfd + pop edx + pop ecx + pop eax leave ret // Sanitize 1-byte load. Takes one 4-byte address as an argument on @@ -53,32 +54,32 @@ .globl __sanitizer_sanitize_load1 .type __sanitizer_sanitize_load1, @function __sanitizer_sanitize_load1: - pushl %ebp - movl %esp, %ebp - pushl %eax - pushl %ecx - pushl %edx - pushfl - movl 8(%ebp), %eax - movl %eax, %ecx - shrl $0x3, %ecx - movb 0x20000000(%ecx), %cl - testb %cl, %cl + push ebp + mov ebp, esp + push eax + push ecx + push edx + pushfd + mov eax, dword ptr [ebp + 8] + mov ecx, eax + shr ecx, 0x3 + mov cl, byte ptr [ecx + 0x20000000] + test cl, cl je .sanitize_load1_done - movl %eax, %edx - andl $0x7, %edx - movsbl %cl, %ecx - cmpl %ecx, %edx + mov edx, eax + and edx, 0x7 + movsx ecx, cl + cmp edx, ecx jl .sanitize_load1_done - pushl %eax + push eax cld emms call __asan_report_load1@PLT .sanitize_load1_done: - popfl - popl %edx - popl %ecx - popl %eax + popfd + pop edx + pop ecx + pop eax leave ret // Sanitize 2-byte store. Takes one 4-byte address as an argument on @@ -86,33 +87,33 @@ .globl __sanitizer_sanitize_store2 .type __sanitizer_sanitize_store2, @function __sanitizer_sanitize_store2: - pushl %ebp - movl %esp, %ebp - pushl %eax - pushl %ecx - pushl %edx - pushfl - movl 8(%ebp), %eax - movl %eax, %ecx - shrl $0x3, %ecx - movb 0x20000000(%ecx), %cl - testb %cl, %cl + push ebp + mov ebp, esp + push eax + push ecx + push edx + pushfd + mov eax, dword ptr [ebp + 8] + mov ecx, eax + shr ecx, 0x3 + mov cl, byte ptr [ecx + 0x20000000] + test cl, cl je .sanitize_store2_done - movl %eax, %edx - andl $0x7, %edx - incl %edx - movsbl %cl, %ecx - cmpl %ecx, %edx + mov edx, eax + and edx, 0x7 + inc edx + movsx ecx, cl + cmp edx, ecx jl .sanitize_store2_done - pushl %eax + push eax cld emms call __asan_report_store2@PLT .sanitize_store2_done: - popfl - popl %edx - popl %ecx - popl %eax + popfd + pop edx + pop ecx + pop eax leave ret // Sanitize 2-byte load. Takes one 4-byte address as an argument on @@ -120,33 +121,33 @@ .globl __sanitizer_sanitize_load2 .type __sanitizer_sanitize_load2, @function __sanitizer_sanitize_load2: - pushl %ebp - movl %esp, %ebp - pushl %eax - pushl %ecx - pushl %edx - pushfl - movl 8(%ebp), %eax - movl %eax, %ecx - shrl $0x3, %ecx - movb 0x20000000(%ecx), %cl - testb %cl, %cl + push ebp + mov ebp, esp + push eax + push ecx + push edx + pushfd + mov eax, dword ptr [ebp + 8] + mov ecx, eax + shr ecx, 0x3 + mov cl, byte ptr [ecx + 0x20000000] + test cl, cl je .sanitize_load2_done - movl %eax, %edx - andl $0x7, %edx - incl %edx - movsbl %cl, %ecx - cmpl %ecx, %edx + mov edx, eax + and edx, 0x7 + inc edx + movsx ecx, cl + cmp edx, ecx jl .sanitize_load2_done - pushl %eax + push eax cld emms call __asan_report_load2@PLT .sanitize_load2_done: - popfl - popl %edx - popl %ecx - popl %eax + popfd + pop edx + pop ecx + pop eax leave ret // Sanitize 4-byte store. Takes one 4-byte address as an argument on @@ -154,33 +155,33 @@ .globl __sanitizer_sanitize_store4 .type __sanitizer_sanitize_store4, @function __sanitizer_sanitize_store4: - pushl %ebp - movl %esp, %ebp - pushl %eax - pushl %ecx - pushl %edx - pushfl - movl 8(%ebp), %eax - movl %eax, %ecx - shrl $0x3, %ecx - movb 0x20000000(%ecx), %cl - testb %cl, %cl + push ebp + mov ebp, esp + push eax + push ecx + push edx + pushfd + mov eax, dword ptr [ebp + 8] + mov ecx, eax + shr ecx, 0x3 + mov cl, byte ptr [ecx + 0x20000000] + test cl, cl je .sanitize_store4_done - movl %eax, %edx - andl $0x7, %edx - addl $0x3, %edx - movsbl %cl, %ecx - cmpl %ecx, %edx + mov edx, eax + and edx, 0x7 + add edx, 0x3 + movsx ecx, cl + cmp edx, ecx jl .sanitize_store4_done - pushl %eax + push eax cld emms call __asan_report_store4@PLT .sanitize_store4_done: - popfl - popl %edx - popl %ecx - popl %eax + popfd + pop edx + pop ecx + pop eax leave ret // Sanitize 4-byte load. Takes one 4-byte address as an argument on @@ -188,33 +189,33 @@ .globl __sanitizer_sanitize_load4 .type __sanitizer_sanitize_load4, @function __sanitizer_sanitize_load4: - pushl %ebp - movl %esp, %ebp - pushl %eax - pushl %ecx - pushl %edx - pushfl - movl 8(%ebp), %eax - movl %eax, %ecx - shrl $0x3, %ecx - movb 0x20000000(%ecx), %cl - testb %cl, %cl + push ebp + mov ebp, esp + push eax + push ecx + push edx + pushfd + mov eax, dword ptr [ebp + 8] + mov ecx, eax + shr ecx, 0x3 + mov cl, byte ptr [ecx + 0x20000000] + test cl, cl je .sanitize_load4_done - movl %eax, %edx - andl $0x7, %edx - addl $0x3, %edx - movsbl %cl, %ecx - cmpl %ecx, %edx + mov edx, eax + and edx, 0x7 + add edx, 0x3 + movsx ecx, cl + cmp edx, ecx jl .sanitize_load4_done - pushl %eax + push eax cld emms call __asan_report_load4@PLT .sanitize_load4_done: - popfl - popl %edx - popl %ecx - popl %eax + popfd + pop edx + pop ecx + pop eax leave ret // Sanitize 8-byte store. Takes one 4-byte address as an argument on @@ -222,24 +223,24 @@ .globl __sanitizer_sanitize_store8 .type __sanitizer_sanitize_store8, @function __sanitizer_sanitize_store8: - pushl %ebp - movl %esp, %ebp - pushl %eax - pushl %ecx - pushfl - movl 8(%ebp), %eax - movl %eax, %ecx - shrl $0x3, %ecx - cmpb $0x0, 0x20000000(%ecx) + push ebp + mov ebp, esp + push eax + push ecx + pushfd + mov eax, dword ptr [ebp + 8] + mov ecx, eax + shr ecx, 0x3 + cmp byte ptr [ecx + 0x20000000], 0x0 je .sanitize_store8_done - pushl %eax + push eax cld emms call __asan_report_store8@PLT .sanitize_store8_done: - popfl - popl %ecx - popl %eax + popfd + pop ecx + pop eax leave ret // Sanitize 8-byte load. Takes one 4-byte address as an argument on @@ -247,24 +248,24 @@ .globl __sanitizer_sanitize_load8 .type __sanitizer_sanitize_load8, @function __sanitizer_sanitize_load8: - pushl %ebp - movl %esp, %ebp - pushl %eax - pushl %ecx - pushfl - movl 8(%ebp), %eax - movl %eax, %ecx - shrl $0x3, %ecx - cmpb $0x0, 0x20000000(%ecx) + push ebp + mov ebp, esp + push eax + push ecx + pushfd + mov eax, dword ptr [ebp + 8] + mov ecx, eax + shr ecx, 0x3 + cmp byte ptr [ecx + 0x20000000], 0x0 je .sanitize_load8_done - pushl %eax + push eax cld emms call __asan_report_load8@PLT .sanitize_load8_done: - popfl - popl %ecx - popl %eax + popfd + pop ecx + pop eax leave ret // Sanitize 16-byte store. Takes one 4-byte address as an argument on @@ -272,24 +273,24 @@ .globl __sanitizer_sanitize_store16 .type __sanitizer_sanitize_store16, @function __sanitizer_sanitize_store16: - pushl %ebp - movl %esp, %ebp - pushl %eax - pushl %ecx - pushfl - movl 8(%ebp), %eax - movl %eax, %ecx - shrl $0x3, %ecx - cmpw $0x0, 0x20000000(%ecx) + push ebp + mov ebp, esp + push eax + push ecx + pushfd + mov eax, dword ptr [ebp + 8] + mov ecx, eax + shr ecx, 0x3 + cmp word ptr [ecx + 0x20000000], 0x0 je .sanitize_store16_done - pushl %eax + push eax cld emms call __asan_report_store16@PLT .sanitize_store16_done: - popfl - popl %ecx - popl %eax + popfd + pop ecx + pop eax leave ret // Sanitize 16-byte load. Takes one 4-byte address as an argument on @@ -297,24 +298,24 @@ .globl __sanitizer_sanitize_load16 .type __sanitizer_sanitize_load16, @function __sanitizer_sanitize_load16: - pushl %ebp - movl %esp, %ebp - pushl %eax - pushl %ecx - pushfl - movl 8(%ebp), %eax - movl %eax, %ecx - shrl $0x3, %ecx - cmpw $0x0, 0x20000000(%ecx) + push ebp + mov ebp, esp + push eax + push ecx + pushfd + mov eax, dword ptr [ebp + 8] + mov ecx, eax + shr ecx, 0x3 + cmp word ptr [ecx + 0x20000000], 0x0 je .sanitize_load16_done - pushl %eax + push eax cld emms call __asan_report_load16@PLT .sanitize_load16_done: - popfl - popl %ecx - popl %eax + popfd + pop ecx + pop eax leave ret #endif // defined(__i386__) @@ -324,272 +325,272 @@ .globl __sanitizer_sanitize_store1 .type __sanitizer_sanitize_store1, @function __sanitizer_sanitize_store1: - subq $128, %rsp - pushq %rax - pushq %rcx + sub rsp, 128 + push rax + push rcx pushfq - movq %rdi, %rax - shrq $0x3, %rax - movb 0x7fff8000(%rax), %al - test %al, %al + mov rax, rdi + shr rax, 0x3 + mov al, byte ptr [rax + 0x7fff8000] + test al, al je .sanitize_store1_done - movl %edi, %ecx - andl $0x7, %ecx - movsbl %al, %eax - cmpl %eax, %ecx + mov ecx, edi + and ecx, 0x7 + movsx eax, al + cmp ecx, eax jl .sanitize_store1_done - subq $8, %rsp - andq $-16, %rsp + sub rsp, 8 + and rsp, -16 cld emms call __asan_report_store1@PLT .sanitize_store1_done: popfq - popq %rcx - popq %rax - addq $128, %rsp + pop rcx + pop rax + add rsp, 128 ret // Sanitize 1-byte load. Takes one 8-byte address as an argument in %rdi, // nothing is returned. .globl __sanitizer_sanitize_load1 .type __sanitizer_sanitize_load1, @function __sanitizer_sanitize_load1: - subq $128, %rsp - pushq %rax - pushq %rcx + sub rsp, 128 + push rax + push rcx pushfq - movq %rdi, %rax - shrq $0x3, %rax - movb 0x7fff8000(%rax), %al - test %al, %al + mov rax, rdi + shr rax, 0x3 + mov al, byte ptr [rax + 0x7fff8000] + test al, al je .sanitize_load1_done - movl %edi, %ecx - andl $0x7, %ecx - movsbl %al, %eax - cmpl %eax, %ecx + mov ecx, edi + and ecx, 0x7 + movsx eax, al + cmp ecx, eax jl .sanitize_load1_done - subq $8, %rsp - andq $-16, %rsp + sub rsp, 8 + and rsp, -16 cld emms call __asan_report_load1@PLT .sanitize_load1_done: popfq - popq %rcx - popq %rax - addq $128, %rsp + pop rcx + pop rax + add rsp, 128 ret // Sanitize 2-byte store. Takes one 8-byte address as an argument in %rdi, // nothing is returned. .globl __sanitizer_sanitize_store2 .type __sanitizer_sanitize_store2, @function __sanitizer_sanitize_store2: - subq $128, %rsp - pushq %rax - pushq %rcx + sub rsp, 128 + push rax + push rcx pushfq - movq %rdi, %rax - shrq $0x3, %rax - movb 0x7fff8000(%rax), %al - test %al, %al + mov rax, rdi + shr rax, 0x3 + mov al, byte ptr [rax + 0x7fff8000] + test al, al je .sanitize_store2_done - movl %edi, %ecx - andl $0x7, %ecx - incl %ecx - movsbl %al, %eax - cmpl %eax, %ecx + mov ecx, edi + and ecx, 0x7 + inc ecx + movsx eax, al + cmp ecx, eax jl .sanitize_store2_done - subq $8, %rsp - andq $-16, %rsp + sub rsp, 8 + and rsp, -16 cld emms call __asan_report_store2@PLT .sanitize_store2_done: popfq - popq %rcx - popq %rax - addq $128, %rsp + pop rcx + pop rax + add rsp, 128 ret // Sanitize 2-byte load. Takes one 8-byte address as an argument in %rdi, // nothing is returned. .globl __sanitizer_sanitize_load2 .type __sanitizer_sanitize_load2, @function __sanitizer_sanitize_load2: - subq $128, %rsp - pushq %rax - pushq %rcx + sub rsp, 128 + push rax + push rcx pushfq - movq %rdi, %rax - shrq $0x3, %rax - movb 0x7fff8000(%rax), %al - test %al, %al + mov rax, rdi + shr rax, 0x3 + mov al, byte ptr [rax + 0x7fff8000] + test al, al je .sanitize_load2_done - movl %edi, %ecx - andl $0x7, %ecx - incl %ecx - movsbl %al, %eax - cmpl %eax, %ecx + mov ecx, edi + and ecx, 0x7 + inc ecx + movsx eax, al + cmp ecx, eax jl .sanitize_load2_done - subq $8, %rsp - andq $-16, %rsp + sub rsp, 8 + and rsp, -16 cld emms call __asan_report_load2@PLT .sanitize_load2_done: popfq - popq %rcx - popq %rax - addq $128, %rsp + pop rcx + pop rax + add rsp, 128 ret // Sanitize 4-byte store. Takes one 8-byte address as an argument in %rdi, // nothing is returned. .globl __sanitizer_sanitize_store4 .type __sanitizer_sanitize_store4, @function __sanitizer_sanitize_store4: - subq $128, %rsp - pushq %rax - pushq %rcx + sub rsp, 128 + push rax + push rcx pushfq - movq %rdi, %rax - shrq $0x3, %rax - movb 0x7fff8000(%rax), %al - test %al, %al + mov rax, rdi + shr rax, 0x3 + mov al, byte ptr [rax + 0x7fff8000] + test al, al je .sanitize_store4_done - movl %edi, %ecx - andl $0x7, %ecx - addl $0x3, %ecx - movsbl %al, %eax - cmpl %eax, %ecx + mov ecx, edi + and ecx, 0x7 + add ecx, 0x3 + movsx eax, al + cmp ecx, eax jl .sanitize_store4_done - subq $8, %rsp - andq $-16, %rsp + sub rsp, 8 + and rsp, -16 cld emms call __asan_report_store4@PLT .sanitize_store4_done: popfq - popq %rcx - popq %rax - addq $128, %rsp + pop rcx + pop rax + add rsp, 128 ret // Sanitize 4-byte load. Takes one 8-byte address as an argument in %rdi, // nothing is returned. .globl __sanitizer_sanitize_load4 .type __sanitizer_sanitize_load4, @function __sanitizer_sanitize_load4: - subq $128, %rsp - pushq %rax - pushq %rcx + sub rsp, 128 + push rax + push rcx pushfq - movq %rdi, %rax - shrq $0x3, %rax - movb 0x7fff8000(%rax), %al - test %al, %al + mov rax, rdi + shr rax, 0x3 + mov al, byte ptr [rax + 0x7fff8000] + test al, al je .sanitize_load4_done - movl %edi, %ecx - andl $0x7, %ecx - addl $0x3, %ecx - movsbl %al, %eax - cmpl %eax, %ecx + mov ecx, edi + and ecx, 0x7 + add ecx, 0x3 + movsx eax, al + cmp ecx, eax jl .sanitize_load4_done - subq $8, %rsp - andq $-16, %rsp + sub rsp, 8 + and rsp, -16 cld emms call __asan_report_load4@PLT .sanitize_load4_done: popfq - popq %rcx - popq %rax - addq $128, %rsp + pop rcx + pop rax + add rsp, 128 ret // Sanitize 8-byte store. Takes one 8-byte address as an argument in %rdi, // nothing is returned. .globl __sanitizer_sanitize_store8 .type __sanitizer_sanitize_store8, @function __sanitizer_sanitize_store8: - subq $128, %rsp - pushq %rax + sub rsp, 128 + push rax pushfq - movq %rdi, %rax - shrq $0x3, %rax - cmpb $0x0, 0x7fff8000(%rax) + mov rax, rdi + shr rax, 0x3 + cmp byte ptr [rax + 0x7fff8000], 0x0 je .sanitize_store8_done - subq $8, %rsp - andq $-16, %rsp + sub rsp, 8 + and rsp, -16 cld emms call __asan_report_store8@PLT .sanitize_store8_done: popfq - popq %rax - addq $128, %rsp + pop rax + add rsp, 128 ret // Sanitize 8-byte load. Takes one 8-byte address as an argument in %rdi, // nothing is returned. .globl __sanitizer_sanitize_load8 .type __sanitizer_sanitize_load8, @function __sanitizer_sanitize_load8: - subq $128, %rsp - pushq %rax + sub rsp, 128 + push rax pushfq - movq %rdi, %rax - shrq $0x3, %rax - cmpb $0x0, 0x7fff8000(%rax) + mov rax, rdi + shr rax, 0x3 + cmp byte ptr [rax + 0x7fff8000], 0x0 je .sanitize_load8_done - subq $8, %rsp - andq $-16, %rsp + sub rsp, 8 + and rsp, -16 cld emms call __asan_report_load8@PLT .sanitize_load8_done: popfq - popq %rax - addq $128, %rsp + pop rax + add rsp, 128 ret // Sanitize 16-byte store. Takes one 8-byte address as an argument in %rdi, // nothing is returned. .globl __sanitizer_sanitize_store16 .type __sanitizer_sanitize_store16, @function __sanitizer_sanitize_store16: - subq $128, %rsp - pushq %rax + sub rsp, 128 + push rax pushfq - movq %rdi, %rax - shrq $0x3, %rax - cmpw $0x0, 0x7fff8000(%rax) + mov rax, rdi + shr rax, 0x3 + cmp word ptr [rax + 0x7fff8000], 0x0 je .sanitize_store16_done - subq $8, %rsp - andq $-16, %rsp + sub rsp, 8 + and rsp, -16 cld emms call __asan_report_store16@PLT .sanitize_store16_done: popfq - popq %rax - addq $128, %rsp + pop rax + add rsp, 128 ret // Sanitize 16-byte load. Takes one 8-byte address as an argument in %rdi, // nothing is returned. .globl __sanitizer_sanitize_load16 .type __sanitizer_sanitize_load16, @function __sanitizer_sanitize_load16: - subq $128, %rsp - pushq %rax + sub rsp, 128 + push rax pushfq - movq %rdi, %rax - shrq $0x3, %rax - cmpw $0x0, 0x7fff8000(%rax) + mov rax, rdi + shr rax, 0x3 + cmp word ptr [rax + 0x7fff8000], 0x0 je .sanitize_load16_done - subq $8, %rsp - andq $-16, %rsp + sub rsp, 8 + and rsp, -16 cld emms call __asan_report_load16@PLT .sanitize_load16_done: popfq - popq %rax - addq $128, %rsp + pop rax + add rsp, 128 ret #endif // defined(__x86_64__) /* We do not need executable stack. */ Index: lib/asan/scripts/gen_asm_instrumentation.sh =================================================================== --- lib/asan/scripts/gen_asm_instrumentation.sh +++ lib/asan/scripts/gen_asm_instrumentation.sh @@ -49,8 +49,8 @@ emit_stack_align() { cat <&2; exit 1 ;; esac cat <&2; exit 1 ;; esac cat <&2; exit 1 ;; esac cat <&2; exit 1 ;; esac @@ -247,8 +248,8 @@ $(emit_call_report $at $as) $(func_label $at $as): popfq - popq %rax - addq \$128, %rsp + pop rax + add rsp, 128 ret EOF done