OSDN Git Service

Fix x86-64 __memset_chk.
authorElliott Hughes <enh@google.com>
Fri, 4 Mar 2016 00:46:25 +0000 (16:46 -0800)
committerElliott Hughes <enh@google.com>
Fri, 4 Mar 2016 00:46:25 +0000 (16:46 -0800)
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

index 1cf9f4b..fc502c0 100644 (file)
@@ -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)