Commit Graph

5308 Commits

Author SHA1 Message Date
The Android Automerger
de19a0c55d merge in klp-release history after reset to klp-dev 2013-08-14 06:04:54 -07:00
Christopher Ferris
f0c3d90913 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
Change-Id: Id5aec8c3cb14101d91bd125eaf3770c9c8aa3f57
(cherry picked from commit 2be91915dc)
2013-08-14 07:46:00 +00:00
Elliott Hughes
3912f90e56 Make ctype.h a little less unhygienic.
This caused trouble for stlport.

(cherry picked from commit 5e9b20f721)

Change-Id: I85d09c12c6de1e8502f83e0ef0f17747fdfe08a5
2013-08-13 14:42:43 -07:00
Elliott Hughes
5951e84646 Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols.
(cherry picked from commit aec2ffbc5a)

Change-Id: Ib61b52dc37e63493094a0a7af23bf89d4a9f0ce5
2013-08-13 14:41:07 -07:00
The Android Automerger
f63a467cdd merge in klp-release history after reset to klp-dev 2013-08-12 06:00:44 -07:00
Elliott Hughes
9e9d1e016f resolved conflicts for merge of 86125aca to klp-dev
Change-Id: I78622ecbad27301b285193a085fa04374aa60033
2013-08-08 18:08:33 -07:00
Elliott Hughes
598f3e9c4a Merge "resolved conflicts for merge of dce94165 to klp-dev-plus-aosp" into klp-dev-plus-aosp 2013-08-09 01:05:49 +00:00
Elliott Hughes
3c3a64616a resolved conflicts for merge of dce94165 to klp-dev-plus-aosp
Change-Id: If5f34f4a31c6a1218751f472ac949c324117a948
2013-08-08 18:03:38 -07:00
Elliott Hughes
14ec1b5886 am ceb670cf: Merge branch \'klp-dev\' of https://googleplex-android.googlesource.com/_direct/platform/bionic into klp-dev
* commit 'ceb670cfc09e407a30627d5044f45d5e28e1be5d':
  Add futimens.
2013-08-08 17:59:33 -07:00
Christopher Ferris
a07a955666 am 1036cd79: am 6beb3ea6: (-s ours) am d7d5049d: (-s ours) am 632fd518: (-s ours) Merge "Fix strcpy.c that should have been strcpy.S. DO NOT MERGE"
* commit '1036cd7939a4d6474d3f5762ea8bfdd95d3d0cfe':
2013-08-08 17:59:32 -07:00
Christopher Ferris
0a7e61d4a1 am 5ec2ab68: am 21b4ffa7: (-s ours) am 5427eb5c: (-s ours) am e2066293: (-s ours) Merge "Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE"
* commit '5ec2ab68f98af7fcb4975bafcb7293f835c9c4b6':
2013-08-08 17:59:31 -07:00
Elliott Hughes
ceb670cfc0 Merge branch 'klp-dev' of https://googleplex-android.googlesource.com/_direct/platform/bionic into klp-dev 2013-08-08 17:53:31 -07:00
Christopher Ferris
1036cd7939 am 6beb3ea6: (-s ours) am d7d5049d: (-s ours) am 632fd518: (-s ours) Merge "Fix strcpy.c that should have been strcpy.S. DO NOT MERGE"
* commit '6beb3ea6a1a49baef001ddd8c6872631f5e90f82':
  Fix strcpy.c that should have been strcpy.S. DO NOT MERGE
2013-08-08 17:53:19 -07:00
Christopher Ferris
5ec2ab68f9 am 21b4ffa7: (-s ours) am 5427eb5c: (-s ours) am e2066293: (-s ours) Merge "Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE"
* commit '21b4ffa7372b029e5a4898b877feb843da2831e9':
  Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE
2013-08-08 17:53:18 -07:00
Elliott Hughes
840a114eb1 Add futimens.
(cherry picked from commit d0be7c8f9a)

Bug: 10239370
Change-Id: I0087e85a94d83b6ce68ec6a0768c44cbe4bd0132
2013-08-08 17:52:06 -07:00
Elliott Hughes
86125acacd am dce94165: am ee48fed5: Merge "Add futimens."
* commit 'dce94165a5624935db9855e208420d36c763f771':
  Add futimens.
2013-08-08 17:45:45 -07:00
Christopher Ferris
6beb3ea6a1 am d7d5049d: (-s ours) am 632fd518: (-s ours) Merge "Fix strcpy.c that should have been strcpy.S. DO NOT MERGE"
* commit 'd7d5049d58427e23318fa1920d63712676fc7725':
  Fix strcpy.c that should have been strcpy.S. DO NOT MERGE
2013-08-08 17:45:45 -07:00
Christopher Ferris
21b4ffa737 am 5427eb5c: (-s ours) am e2066293: (-s ours) Merge "Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE"
* commit '5427eb5c63417c7bc59bbfe112c97917dcef4e8c':
  Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE
2013-08-08 17:45:44 -07:00
Christopher Ferris
d41e52a238 am d7d5049d: (-s ours) am 632fd518: (-s ours) Merge "Fix strcpy.c that should have been strcpy.S. DO NOT MERGE"
* commit 'd7d5049d58427e23318fa1920d63712676fc7725':
  Fix strcpy.c that should have been strcpy.S. DO NOT MERGE
2013-08-08 17:44:21 -07:00
Christopher Ferris
2e0a707f79 am 5427eb5c: (-s ours) am e2066293: (-s ours) Merge "Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE"
* commit '5427eb5c63417c7bc59bbfe112c97917dcef4e8c':
  Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE
2013-08-08 17:44:21 -07:00
Elliott Hughes
dce94165a5 am ee48fed5: Merge "Add futimens."
* commit 'ee48fed51894f3db324e957058ed2ddcf23dddc7':
  Add futimens.
2013-08-08 17:41:15 -07:00
Christopher Ferris
d7d5049d58 am 632fd518: (-s ours) Merge "Fix strcpy.c that should have been strcpy.S. DO NOT MERGE"
* commit '632fd5183a611b80e009be36f881f572acc41619':
  Fix strcpy.c that should have been strcpy.S. DO NOT MERGE
2013-08-08 17:41:15 -07:00
Christopher Ferris
5427eb5c63 am e2066293: (-s ours) Merge "Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE"
* commit 'e2066293e8279641d4abd13ec3fbdd6f42def83d':
  Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE
2013-08-08 17:41:14 -07:00
Elliott Hughes
ee48fed518 Merge "Add futimens." 2013-08-09 00:37:32 +00:00
Elliott Hughes
d0be7c8f9a Add futimens.
Bug: 10239370
Change-Id: I518340084103dc339ef8a065d4837d6258a1381d
2013-08-08 17:13:33 -07:00
Christopher Ferris
632fd5183a Merge "Fix strcpy.c that should have been strcpy.S. DO NOT MERGE" 2013-08-08 19:12:20 +00:00
Christopher Ferris
e2066293e8 Merge "Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE" 2013-08-08 19:12:00 +00:00
Christopher Ferris
b922ed3498 Fix strcpy.c that should have been strcpy.S. DO NOT MERGE
Merge from internal master.

(cherry-picked from 1ce6654163)

Change-Id: I376b831df42248baadde7202a30a68112f752ff7
2013-08-08 12:09:37 -07:00
Christopher Ferris
4e24dcc8d8 Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE
Create one version of strcat/strcpy/strlen for cortex-a15/krait and another
version for cortex-a9.

Tested with the libc_test strcat/strcpy/strlen tests.
Including new tests that verify that the src for strcat/strcpy do not
overread across page boundaries.

NOTE: The handling of unaligned strcpy (same code in strcat) could probably
be optimized further such that the src is read 64 bits at a time instead of
the partial reads occurring now.

strlen improves slightly since it was recently optimized.

Performance improvements for strcpy and strcat (using an empty dest string):

cortex-a9
- Small copies vary from about 5% to 20% as the size gets above 10 bytes.
- Copies >= 1024, about a 60% improvement.
- Unaligned copies, from about 40% improvement.

cortex-a15
- Most small copies exhibit a 100% improvement, a few copies only
  improve by 20%.
- Copies >= 1024, about 150% improvement.
- Unaligned copies, about 100% improvement.

krait
- Most small copies vary widely, but on average 20% improvement, then
  the performance gets better, hitting about a 100% improvement when
  copies 64 bytes of data.
- Copies >= 1024, about 100% improvement.
- When coping MBs of data, about 50% improvement.
- Unaligned copies, about 90% improvement.

As strcat destination strings get larger in size:

cortex-a9
- about 40% improvement for small dst strings (>= 32).
- about 250% improvement for dst strings >= 1024.

cortex-a15
- about 200% improvement for small dst strings (>=32).
- about 250% improvement for dst strings >= 1024.

krait
- about 25% improvement for small dst strings (>=32).
- about 100% improvement for dst strings >=1024.

Merge from internal master.

(cherry-picked from d119b7b6f4)

Change-Id: I296463b251ef9fab004ee4dded2793feca5b547a
2013-08-08 11:13:46 -07:00
The Android Automerger
b683cf117d merge in klp-release history after reset to klp-dev 2013-08-08 07:53:11 -07:00
Colin Cross
7f4074d17d bionic: name malloc'd regions
Use the new __bionic_name_mem function to name malloc'd memory as
"libc_malloc" on kernels that support it.

Change-Id: I7235eae6918fa107010039b9ab8b7cb362212272
2013-08-08 00:42:39 +00:00
Colin Cross
6771b9cef6 bionic: add function to name memory
Only works on some kernels, and only on page-aligned regions of
anonymous memory.  It will show up in /proc/pid/maps as
[anon:<name>] and in /proc/pid/smaps as Name: <name>

Change-Id: If31667cf45ff41cc2a79a140ff68707526def80e
2013-08-07 15:41:30 -07:00
Christopher Ferris
7c860db074 Optimize __memset_chk, __memcpy_chk.
This change creates assembler versions of __memcpy_chk/__memset_chk
that is implemented in the memcpy/memset assembler code. This change
avoids an extra call to memcpy/memset, instead allowing a simple fall
through to occur from the chk code into the body of the real
implementation.

Testing:

- Ran the libc_test on __memcpy_chk/__memset_chk on all nexus devices.
- Wrote a small test executable that has three calls to __memcpy_chk and
  three calls to __memset_chk. First call dest_len is length + 1. Second
  call dest_len is length. Third call dest_len is length - 1.
  Verified that the first two calls pass, and the third fails. Examined
  the logcat output on all nexus devices to verify that the fortify
  error message was sent properly.
- I benchmarked the new __memcpy_chk and __memset_chk on all systems. For
  __memcpy_chk and large copies, the savings is relatively small (about 1%).
  For small copies, the savings is large on cortex-a15/krait devices
  (between 5% to 30%).
  For cortex-a9 and small copies, the speed up is present, but relatively
  small (about 3% to 5%).
  For __memset_chk and large copies, the savings is also small (about 1%).
  However, all processors show larger speed-ups on small copies (about 30% to
  100%).

Bug: 9293744

Change-Id: I8926d59fe2673e36e8a27629e02a7b7059ebbc98
2013-08-06 15:38:29 -07:00
The Android Automerger
2b899b04e9 merge in klp-release history after reset to master 2013-08-06 08:16:59 -07:00
Christopher Ferris
1ce6654163 Fix strcpy.c that should have been strcpy.S.
Change-Id: Ib4609baad3a14c8b0f37556269781fa2b06916dc
2013-08-05 17:08:06 -07:00
Christopher Ferris
e1857431e8 Merge "Optimize strcat/strcpy, small tweaks to strlen." 2013-08-05 23:32:06 +00:00
Elliott Hughes
e66ffef900 am cd927519: Merge "Fix stdint.h intptr_t/uintptr_t for x86_64/x32"
* commit 'cd927519a94939f2ebc307544f827baade529bc9':
  Fix stdint.h intptr_t/uintptr_t for x86_64/x32
2013-08-05 15:51:54 -07:00
Elliott Hughes
28e0ec8d61 am a0473d77: Merge "syslog needs a valid socket path for _PATH_LOG"
* commit 'a0473d77b2d3a6f26e29cc8c2fdaeb2a4b3ab8f8':
  syslog needs a valid socket path for _PATH_LOG
2013-08-05 15:51:53 -07:00
Elliott Hughes
cd927519a9 Merge "Fix stdint.h intptr_t/uintptr_t for x86_64/x32" 2013-08-05 20:55:24 +00:00
Elliott Hughes
a0473d77b2 Merge "syslog needs a valid socket path for _PATH_LOG" 2013-08-05 20:41:50 +00:00
Robert Greenwalt
662bb875e4 am a9c5bb97: Merge "Fix the detection of alt-network in dns resolver."
* commit 'a9c5bb972df7cbb4e65cfb53673b26f9d42deacd':
  Fix the detection of alt-network in dns resolver.
2013-08-05 11:55:53 -07:00
Robert Greenwalt
a9c5bb972d Merge "Fix the detection of alt-network in dns resolver." 2013-08-05 18:45:03 +00:00
Robert Greenwalt
1d8d9a308c Fix the detection of alt-network in dns resolver.
Used to determine proper A/AAAA record request.

bug:10132565
Change-Id: I7229f6672e879920a6fae58672cddd72db78546c
2013-08-05 18:44:30 +00:00
The Android Automerger
1714c787b6 merge in klp-release history after reset to master 2013-08-05 06:00:46 -07:00
Elliott Hughes
49b24b4efb am 3287dccf: Merge "Add ssse3 implementation of __memcmp16."
* commit '3287dccf2ecced89bb39b857abc8eba997bc3f51':
  Add ssse3 implementation of __memcmp16.
2013-08-02 18:04:01 -07:00
Ben Cheng
b78f43579f am aa2733d1: Merge "Update the comments to reflect the current status."
* commit 'aa2733d17b87c607fccbd6e6a0f44d2d411ffd77':
  Update the comments to reflect the current status.
2013-08-02 17:58:47 -07:00
Elliott Hughes
3287dccf2e Merge "Add ssse3 implementation of __memcmp16." 2013-08-03 00:58:46 +00:00
Elliott Hughes
d0313e7a2a am a6ed05c1: Merge "libgcc_compat: Introduce __aeabi_lasr for cortex-a9 and higher"
* commit 'a6ed05c1c4c787241b56df132e77512c64cbc595':
  libgcc_compat: Introduce __aeabi_lasr for cortex-a9 and higher
2013-08-02 17:58:46 -07:00
Alexander Ivchenko
baa91f4f89 Add ssse3 implementation of __memcmp16.
__memcmp16 was missing in x86. Also added C-version for backward
compatibility. Added bionic test for __memcmp16 and for wmemcmp.

Change-Id: I33718441e7ee343cdb021d91dbeaf9ce2d4d7eb4
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
2013-08-02 17:57:23 -07:00
Ben Cheng
aa2733d17b Merge "Update the comments to reflect the current status." 2013-08-02 23:06:10 +00:00