summaryrefslogtreecommitdiffstats
path: root/libc/arch-arm/generic
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2013-08-07 13:09:51 -0700
committerChristopher Ferris <cferris@google.com>2013-08-15 11:13:39 -0700
commit5f45d583b0cfb4f7bed1447e8eed003a529cc69e (patch)
treeea1e26b29309f4d81b853e9686786bffa62ff90e /libc/arch-arm/generic
parentc5cf53701a5e04aeead70b1298bb38c51633e96d (diff)
downloadbionic-5f45d583b0cfb4f7bed1447e8eed003a529cc69e.zip
bionic-5f45d583b0cfb4f7bed1447e8eed003a529cc69e.tar.gz
bionic-5f45d583b0cfb4f7bed1447e8eed003a529cc69e.tar.bz2
Create optimized __strcpy_chk/__strcat_chk.
This change pulls the memcpy code out into a new file so that the __strcpy_chk and __strcat_chk can use it with an include. The new versions of the two chk functions uses assembly versions of strlen and memcpy to implement this check. This allows near parity with the assembly versions of strcpy/strcat. It also means that as memcpy implementations get faster, so do the chk functions. Other included changes: - Change all of the assembly labels to local labels. The other labels confuse gdb and mess up backtracing. - Add .cfi_startproc and .cfi_endproc directives so that gdb is not confused when falling through from one function to another. - Change all functions to use cfi directives since they are more powerful. - Move the memcpy_chk fail code outside of the memcpy function definition so that backtraces work properly. - Preserve lr before the calls to __fortify_chk_fail so that the backtrace actually works. Testing: - Ran the bionic unit tests. Verified all error messages in logs are set correctly. - Ran libc_test, replacing strcpy with __strcpy_chk and replacing strcat with __strcat_chk. - Ran the debugger on nexus10, nexus4, and old nexus7. Verified that the backtrace is correct for all fortify check failures. Also verify that when falling through from __memcpy_chk to memcpy that the backtrace is still correct. Also verified the same for __memset_chk and bzero. Verified the two different paths in the cortex-a9 memset routine that save variables to the stack still show the backtrace properly. Bug: 9293744 (cherry-picked from 2be91915dcecc956d14ff281db0c7d216ca98af2) Change-Id: Ia407b74d3287d0b6af0139a90b6eb3bfaebf2155
Diffstat (limited to 'libc/arch-arm/generic')
-rw-r--r--libc/arch-arm/generic/generic.mk2
1 files changed, 2 insertions, 0 deletions
diff --git a/libc/arch-arm/generic/generic.mk b/libc/arch-arm/generic/generic.mk
index c3a5aa5..e230003 100644
--- a/libc/arch-arm/generic/generic.mk
+++ b/libc/arch-arm/generic/generic.mk
@@ -4,3 +4,5 @@ $(call libc-add-cpu-variant-src,STRCAT,string/strcat.c)
$(call libc-add-cpu-variant-src,STRCMP,arch-arm/generic/bionic/strcmp.S)
$(call libc-add-cpu-variant-src,STRCPY,arch-arm/generic/bionic/strcpy.S)
$(call libc-add-cpu-variant-src,STRLEN,arch-arm/generic/bionic/strlen.c)
+$(call libc-add-cpu-variant-src,__STRCAT_CHK,bionic/__strcat_chk.cpp)
+$(call libc-add-cpu-variant-src,__STRCPY_CHK,bionic/__strcpy_chk.cpp)