Improve diagnostics from the assembler __memcpy_chk routines.
Change-Id: Iec16c92ed80beee505cba2121ea33e3550197b02
diff --git a/libc/arch-arm/krait/bionic/memcpy.S b/libc/arch-arm/krait/bionic/memcpy.S
index 189a097..de6f432 100644
--- a/libc/arch-arm/krait/bionic/memcpy.S
+++ b/libc/arch-arm/krait/bionic/memcpy.S
@@ -44,9 +44,14 @@
ENTRY(__memcpy_chk)
cmp r2, r3
- bhi .L_memcpy_chk_fail
+ bls memcpy
- // Fall through to memcpy...
+ // Preserve lr for backtrace.
+ push {lr}
+ .cfi_def_cfa_offset 4
+ .cfi_rel_offset lr, 0
+
+ bl __memcpy_chk_fail
END(__memcpy_chk)
ENTRY(memcpy)
@@ -57,25 +62,4 @@
.cfi_rel_offset lr, 4
#include "memcpy_base.S"
-
- // Undo the cfi directives from above.
- .cfi_adjust_cfa_offset -8
- .cfi_restore r0
- .cfi_restore lr
-.L_memcpy_chk_fail:
- // Preserve lr for backtrace.
- push {lr}
- .cfi_adjust_cfa_offset 4
- .cfi_rel_offset lr, 0
-
- ldr r0, error_message
-1:
- add r0, pc
- bl __fortify_fatal
-error_message:
- .word error_string-(1b+4)
END(memcpy)
-
- .data
-error_string:
- .string "memcpy: prevented write past end of buffer"