From a80ddc8a34b913f0fdbb2c5febe61b8a9f0e6015 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 3 Mar 2016 16:46:25 -0800 Subject: [PATCH] Fix x86-64 __memset_chk. I can only assume I was testing the 32-bit implementation when I claimed this worked. While improving the 32-bit code I realized that I'd used signed comparisons instead of unsigned, and came back to find that the 64-bit code didn't work. By way of apology, make x86-64 the first architecture where __memset_chk falls through to memset. Change-Id: I54d9eee5349b6a2abb2ce81e161fdcde09556561 --- libc/arch-x86_64/string/sse2-memset-slm.S | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libc/arch-x86_64/string/sse2-memset-slm.S b/libc/arch-x86_64/string/sse2-memset-slm.S index 1cf9f4be4..fc502c021 100644 --- a/libc/arch-x86_64/string/sse2-memset-slm.S +++ b/libc/arch-x86_64/string/sse2-memset-slm.S @@ -43,11 +43,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ENTRY(__memset_chk) # %rdi = dst, %rsi = byte, %rdx = n, %rcx = dst_len - cmp %rdx, %rcx - jl memset - - # TODO: include __memset_chk_fail in the backtrace? - call PIC_PLT(__memset_chk_fail) + cmp %rcx, %rdx + ja __memset_chk_fail + // Fall through to memset... END(__memset_chk)