bionic/libc
Christopher Ferris 5f45d583b0 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 2be91915dc)

Change-Id: Ia407b74d3287d0b6af0139a90b6eb3bfaebf2155
2013-08-15 11:13:39 -07:00
..
arch-arm Create optimized __strcpy_chk/__strcat_chk. 2013-08-15 11:13:39 -07:00
arch-mips [MIPS] __dso_handle.S and __dso_handle_so.S not needed. 2013-07-22 23:16:02 -07:00
arch-x86 Add ssse3 implementation of __memcmp16. 2013-08-02 17:57:23 -07:00
bionic Optimize __memset_chk, __memcpy_chk. DO NOT MERGE. 2013-08-14 18:14:43 -07:00
include Make ctype.h a little less unhygienic. 2013-08-13 14:30:59 -07:00
kernel Update kernel input headers 2013-08-14 13:30:20 -07:00
netbsd Fix the detection of alt-network in dns resolver. 2013-08-05 18:44:30 +00:00
private Optimize __memset_chk, __memcpy_chk. DO NOT MERGE. 2013-08-14 18:14:43 -07:00
stdio Upgrade mktemp.c to the current upstream version. 2013-07-19 15:20:31 -07:00
stdlib Make ctype.h a little less unhygienic. 2013-08-13 14:30:59 -07:00
string Optimize __memset_chk, __memcpy_chk. DO NOT MERGE. 2013-08-14 18:14:43 -07:00
tools Slight script cleanup; make gensyscalls work from any directory. 2013-06-17 10:39:33 -07:00
tzcode Upgrade to tzcode2013d. 2013-07-12 17:52:44 -07:00
unistd Switch to current upstream getopt_long. 2013-06-25 14:56:17 -07:00
upstream-dlmalloc Fix build warning of initialization but no use. 2012-09-06 09:59:13 -07:00
upstream-freebsd Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols. 2013-08-12 12:07:05 -07:00
upstream-netbsd Add more __restricts, clean up __format__ attributes. 2013-05-14 16:08:43 -07:00
wchar Switch to upstream-freebsd for the unmolested wchar code. 2013-03-01 18:35:56 -08:00
zoneinfo Upgrade to tzdata2013d. 2013-07-08 14:51:15 -07:00
Android.mk Optimize __memset_chk, __memcpy_chk. DO NOT MERGE. 2013-08-14 18:14:43 -07:00
CAVEATS auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
MODULE_LICENSE_BSD auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
NOTICE libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings. 2013-07-03 10:20:43 -07:00
SYSCALLS.TXT libc: add swapon and swapoff syscalls 2013-06-25 13:18:03 -07:00