OSDN Git Service

Split our FORTIFY implementation into libc_fortify
authorGeorge Burgess IV <gbiv@google.com>
Fri, 21 Jul 2017 20:28:42 +0000 (13:28 -0700)
committerGeorge Burgess IV <gbiv@google.com>
Mon, 24 Jul 2017 21:20:16 +0000 (14:20 -0700)
As requested in the bug. This also rips __memcpy_chk out of memcpy.S,
which lets us cut down on copypasta (all of the implementations look
identical).

Bug: 12231437
Test: mma on aosp_{arm,arm64,mips,x86,x86_64} internal master;
checkbuild on bullhead internal master; CtsBionicTestCases on bullhead.
No new failures.
Change-Id: I88c39ca166bacde0b692aa3063e743bb046a5d2f

16 files changed:
libc/Android.bp
libc/arch-arm/cortex-a15/bionic/memcpy.S
libc/arch-arm/cortex-a53/bionic/memcpy.S
libc/arch-arm/cortex-a7/bionic/memcpy.S
libc/arch-arm/cortex-a9/bionic/memcpy.S
libc/arch-arm/denver/bionic/memcpy.S
libc/arch-arm/generic/bionic/__memcpy_chk.S [new file with mode: 0644]
libc/arch-arm/generic/bionic/memcpy.S
libc/arch-arm/krait/bionic/memcpy.S
libc/arch-arm/kryo/bionic/memcpy.S
libc/arch-arm64/denver64/bionic/memcpy.S
libc/arch-arm64/generic/bionic/__memcpy_chk.S [new file with mode: 0644]
libc/arch-arm64/generic/bionic/memcpy.S
libc/bionic/__memcpy_chk.cpp
libc/bionic/__strcpy_chk.cpp
libc/bionic/fortify.cpp

index 7b0ac23..49c3899 100644 (file)
@@ -776,6 +776,145 @@ cc_library_static {
 }
 
 // ========================================================
+// libc_fortify.a - container for our FORITFY
+// implementation details
+// ========================================================
+cc_library_static {
+    defaults: ["libc_defaults"],
+    srcs: [
+        "bionic/__memcpy_chk.cpp",
+        "bionic/__strcat_chk.cpp",
+        "bionic/__strcpy_chk.cpp",
+        "bionic/fortify.cpp",
+    ],
+
+    name: "libc_fortify",
+
+    // Disable FORTIFY for the compilation of these, so we don't end up having
+    // FORTIFY silently call itself.
+    cflags: ["-U_FORTIFY_SOURCE"],
+
+    arch: {
+        arm: {
+            srcs: [
+                "arch-arm/generic/bionic/__memcpy_chk.S",
+            ],
+            exclude_srcs: [
+                "bionic/__memcpy_chk.cpp",
+            ],
+            cortex_a7: {
+                srcs: [
+                    "arch-arm/cortex-a7/bionic/__strcat_chk.S",
+                    "arch-arm/cortex-a7/bionic/__strcpy_chk.S",
+                ],
+                exclude_srcs: [
+                    "bionic/__strcat_chk.cpp",
+                    "bionic/__strcpy_chk.cpp",
+                ],
+            },
+            cortex_a53: {
+                srcs: [
+                    "arch-arm/cortex-a53/bionic/__strcat_chk.S",
+                    "arch-arm/cortex-a53/bionic/__strcpy_chk.S",
+                ],
+                exclude_srcs: [
+                    "bionic/__strcat_chk.cpp",
+                    "bionic/__strcpy_chk.cpp",
+                ],
+            },
+            cortex_a53_a57: {
+                srcs: [
+                    "arch-arm/cortex-a15/bionic/__strcat_chk.S",
+                    "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
+                ],
+                exclude_srcs: [
+                    "bionic/__strcat_chk.cpp",
+                    "bionic/__strcpy_chk.cpp",
+                ],
+            },
+            cortex_a8: {
+                srcs: [
+                    "arch-arm/cortex-a15/bionic/__strcat_chk.S",
+                    "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
+                ],
+                exclude_srcs: [
+                    "bionic/__strcat_chk.cpp",
+                    "bionic/__strcpy_chk.cpp",
+                ],
+            },
+            cortex_a9: {
+                srcs: [
+                    "arch-arm/cortex-a9/bionic/__strcat_chk.S",
+                    "arch-arm/cortex-a9/bionic/__strcpy_chk.S",
+                ],
+                exclude_srcs: [
+                    "bionic/__strcat_chk.cpp",
+                    "bionic/__strcpy_chk.cpp",
+                ],
+            },
+            cortex_a15: {
+                srcs: [
+                    "arch-arm/cortex-a15/bionic/__strcat_chk.S",
+                    "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
+                ],
+                exclude_srcs: [
+                    "bionic/__strcat_chk.cpp",
+                    "bionic/__strcpy_chk.cpp",
+                ],
+            },
+            cortex_a73: {
+                srcs: [
+                    "arch-arm/denver/bionic/__strcat_chk.S",
+                    "arch-arm/denver/bionic/__strcpy_chk.S",
+                ],
+                exclude_srcs: [
+                    "bionic/__strcat_chk.cpp",
+                    "bionic/__strcpy_chk.cpp",
+                ],
+            },
+            denver: {
+                srcs: [
+                    "arch-arm/denver/bionic/__strcat_chk.S",
+                    "arch-arm/denver/bionic/__strcpy_chk.S",
+                ],
+                exclude_srcs: [
+                    "bionic/__strcat_chk.cpp",
+                    "bionic/__strcpy_chk.cpp",
+                ],
+            },
+            krait: {
+                srcs: [
+                    "arch-arm/krait/bionic/__strcat_chk.S",
+                    "arch-arm/krait/bionic/__strcpy_chk.S",
+                ],
+                exclude_srcs: [
+                    "bionic/__strcat_chk.cpp",
+                    "bionic/__strcpy_chk.cpp",
+                ],
+            },
+            kryo: {
+                srcs: [
+                    "arch-arm/krait/bionic/__strcat_chk.S",
+                    "arch-arm/krait/bionic/__strcpy_chk.S",
+                ],
+                exclude_srcs: [
+                    "bionic/__strcat_chk.cpp",
+                    "bionic/__strcpy_chk.cpp",
+                ],
+            },
+        },
+        arm64: {
+            srcs: [
+                "arch-arm64/generic/bionic/__memcpy_chk.S",
+            ],
+            exclude_srcs: [
+                "bionic/__memcpy_chk.cpp",
+            ],
+        },
+    },
+}
+
+// ========================================================
 // libc_bionic.a - home-grown C library code
 // ========================================================
 
@@ -804,9 +943,6 @@ cc_library_static {
         // debuggerd will look for the abort message in libc.so's copy.
         "bionic/android_set_abort_message.cpp",
 
-        "bionic/__memcpy_chk.cpp",
-        "bionic/__strcat_chk.cpp",
-        "bionic/__strcpy_chk.cpp",
         "bionic/strchr.cpp",
         "bionic/strnlen.c",
         "bionic/strrchr.cpp",
@@ -832,15 +968,10 @@ cc_library_static {
                 "arch-arm/bionic/syscall.S",
                 "arch-arm/bionic/vfork.S",
             ],
-            exclude_srcs: [
-                "bionic/__memcpy_chk.cpp",
-            ],
             cortex_a7: {
                 srcs: [
                     "arch-arm/cortex-a7/bionic/memset.S",
                     "arch-arm/cortex-a7/bionic/memcpy.S",
-                    "arch-arm/cortex-a7/bionic/__strcat_chk.S",
-                    "arch-arm/cortex-a7/bionic/__strcpy_chk.S",
 
                     "arch-arm/cortex-a15/bionic/stpcpy.S",
                     "arch-arm/cortex-a15/bionic/strcat.S",
@@ -856,15 +987,11 @@ cc_library_static {
                     "arch-arm/generic/bionic/strcmp.S",
                     "arch-arm/generic/bionic/strcpy.S",
                     "arch-arm/generic/bionic/strlen.c",
-                    "bionic/__strcat_chk.cpp",
-                    "bionic/__strcpy_chk.cpp",
                 ],
             },
             cortex_a53: {
                 srcs: [
                     "arch-arm/cortex-a53/bionic/memcpy.S",
-                    "arch-arm/cortex-a53/bionic/__strcat_chk.S",
-                    "arch-arm/cortex-a53/bionic/__strcpy_chk.S",
 
                     "arch-arm/cortex-a7/bionic/memset.S",
 
@@ -882,8 +1009,6 @@ cc_library_static {
                     "arch-arm/generic/bionic/strcmp.S",
                     "arch-arm/generic/bionic/strcpy.S",
                     "arch-arm/generic/bionic/strlen.c",
-                    "bionic/__strcat_chk.cpp",
-                    "bionic/__strcpy_chk.cpp",
                 ],
             },
             cortex_a53_a57: {
@@ -892,10 +1017,8 @@ cc_library_static {
                     "arch-arm/cortex-a15/bionic/memset.S",
                     "arch-arm/cortex-a15/bionic/stpcpy.S",
                     "arch-arm/cortex-a15/bionic/strcat.S",
-                    "arch-arm/cortex-a15/bionic/__strcat_chk.S",
                     "arch-arm/cortex-a15/bionic/strcmp.S",
                     "arch-arm/cortex-a15/bionic/strcpy.S",
-                    "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
                     "arch-arm/cortex-a15/bionic/strlen.S",
 
                     "arch-arm/denver/bionic/memmove.S",
@@ -906,8 +1029,6 @@ cc_library_static {
                     "arch-arm/generic/bionic/strcmp.S",
                     "arch-arm/generic/bionic/strcpy.S",
                     "arch-arm/generic/bionic/strlen.c",
-                    "bionic/__strcat_chk.cpp",
-                    "bionic/__strcpy_chk.cpp",
                 ],
             },
             cortex_a8: {
@@ -916,10 +1037,8 @@ cc_library_static {
                     "arch-arm/cortex-a15/bionic/memset.S",
                     "arch-arm/cortex-a15/bionic/stpcpy.S",
                     "arch-arm/cortex-a15/bionic/strcat.S",
-                    "arch-arm/cortex-a15/bionic/__strcat_chk.S",
                     "arch-arm/cortex-a15/bionic/strcmp.S",
                     "arch-arm/cortex-a15/bionic/strcpy.S",
-                    "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
                     "arch-arm/cortex-a15/bionic/strlen.S",
 
                     "arch-arm/denver/bionic/memmove.S",
@@ -930,8 +1049,6 @@ cc_library_static {
                     "arch-arm/generic/bionic/strcmp.S",
                     "arch-arm/generic/bionic/strcpy.S",
                     "arch-arm/generic/bionic/strlen.c",
-                    "bionic/__strcat_chk.cpp",
-                    "bionic/__strcpy_chk.cpp",
                 ],
             },
             cortex_a9: {
@@ -940,10 +1057,8 @@ cc_library_static {
                     "arch-arm/cortex-a9/bionic/memset.S",
                     "arch-arm/cortex-a9/bionic/stpcpy.S",
                     "arch-arm/cortex-a9/bionic/strcat.S",
-                    "arch-arm/cortex-a9/bionic/__strcat_chk.S",
                     "arch-arm/cortex-a9/bionic/strcmp.S",
                     "arch-arm/cortex-a9/bionic/strcpy.S",
-                    "arch-arm/cortex-a9/bionic/__strcpy_chk.S",
                     "arch-arm/cortex-a9/bionic/strlen.S",
 
                     "arch-arm/denver/bionic/memmove.S",
@@ -954,8 +1069,6 @@ cc_library_static {
                     "arch-arm/generic/bionic/strcmp.S",
                     "arch-arm/generic/bionic/strcpy.S",
                     "arch-arm/generic/bionic/strlen.c",
-                    "bionic/__strcat_chk.cpp",
-                    "bionic/__strcpy_chk.cpp",
                 ],
             },
             cortex_a15: {
@@ -964,10 +1077,8 @@ cc_library_static {
                     "arch-arm/cortex-a15/bionic/memset.S",
                     "arch-arm/cortex-a15/bionic/stpcpy.S",
                     "arch-arm/cortex-a15/bionic/strcat.S",
-                    "arch-arm/cortex-a15/bionic/__strcat_chk.S",
                     "arch-arm/cortex-a15/bionic/strcmp.S",
                     "arch-arm/cortex-a15/bionic/strcpy.S",
-                    "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
                     "arch-arm/cortex-a15/bionic/strlen.S",
 
                     "arch-arm/denver/bionic/memmove.S",
@@ -978,8 +1089,6 @@ cc_library_static {
                     "arch-arm/generic/bionic/strcmp.S",
                     "arch-arm/generic/bionic/strcpy.S",
                     "arch-arm/generic/bionic/strlen.c",
-                    "bionic/__strcat_chk.cpp",
-                    "bionic/__strcpy_chk.cpp",
                 ],
             },
             cortex_a73: {
@@ -988,8 +1097,6 @@ cc_library_static {
 
                     "arch-arm/denver/bionic/memcpy.S",
                     "arch-arm/denver/bionic/memmove.S",
-                    "arch-arm/denver/bionic/__strcat_chk.S",
-                    "arch-arm/denver/bionic/__strcpy_chk.S",
 
                     "arch-arm/krait/bionic/strcmp.S",
 
@@ -1004,8 +1111,6 @@ cc_library_static {
                     "arch-arm/generic/bionic/strcmp.S",
                     "arch-arm/generic/bionic/strcpy.S",
                     "arch-arm/generic/bionic/strlen.c",
-                    "bionic/__strcat_chk.cpp",
-                    "bionic/__strcpy_chk.cpp",
                 ],
             },
             denver: {
@@ -1013,8 +1118,6 @@ cc_library_static {
                     "arch-arm/denver/bionic/memcpy.S",
                     "arch-arm/denver/bionic/memmove.S",
                     "arch-arm/denver/bionic/memset.S",
-                    "arch-arm/denver/bionic/__strcat_chk.S",
-                    "arch-arm/denver/bionic/__strcpy_chk.S",
 
                     // Use cortex-a15 versions of strcat/strcpy/strlen.
                     "arch-arm/cortex-a15/bionic/stpcpy.S",
@@ -1029,8 +1132,6 @@ cc_library_static {
                     "arch-arm/generic/bionic/strcmp.S",
                     "arch-arm/generic/bionic/strcpy.S",
                     "arch-arm/generic/bionic/strlen.c",
-                    "bionic/__strcat_chk.cpp",
-                    "bionic/__strcpy_chk.cpp",
                 ],
             },
             krait: {
@@ -1038,8 +1139,6 @@ cc_library_static {
                     "arch-arm/krait/bionic/memcpy.S",
                     "arch-arm/krait/bionic/memset.S",
                     "arch-arm/krait/bionic/strcmp.S",
-                    "arch-arm/krait/bionic/__strcat_chk.S",
-                    "arch-arm/krait/bionic/__strcpy_chk.S",
 
                     // Use cortex-a15 versions of strcat/strcpy/strlen.
                     "arch-arm/cortex-a15/bionic/stpcpy.S",
@@ -1055,8 +1154,6 @@ cc_library_static {
                     "arch-arm/generic/bionic/strcmp.S",
                     "arch-arm/generic/bionic/strcpy.S",
                     "arch-arm/generic/bionic/strlen.c",
-                    "bionic/__strcat_chk.cpp",
-                    "bionic/__strcpy_chk.cpp",
                 ],
             },
             kryo: {
@@ -1064,8 +1161,6 @@ cc_library_static {
                     "arch-arm/kryo/bionic/memcpy.S",
                     "arch-arm/cortex-a7/bionic/memset.S",
                     "arch-arm/krait/bionic/strcmp.S",
-                    "arch-arm/krait/bionic/__strcat_chk.S",
-                    "arch-arm/krait/bionic/__strcpy_chk.S",
 
                     // Use cortex-a15 versions of strcat/strcpy/strlen.
                     "arch-arm/cortex-a15/bionic/stpcpy.S",
@@ -1081,8 +1176,6 @@ cc_library_static {
                     "arch-arm/generic/bionic/strcmp.S",
                     "arch-arm/generic/bionic/strcpy.S",
                     "arch-arm/generic/bionic/strlen.c",
-                    "bionic/__strcat_chk.cpp",
-                    "bionic/__strcpy_chk.cpp",
                 ],
             },
         },
@@ -1378,7 +1471,6 @@ cc_library_static {
         "bionic/fgetxattr.cpp",
         "bionic/flistxattr.cpp",
         "bionic/flockfile.cpp",
-        "bionic/fortify.cpp",
         "bionic/fpclassify.cpp",
         "bionic/fsetxattr.cpp",
         "bionic/ftruncate.cpp",
@@ -1644,6 +1736,7 @@ cc_library_static {
 
     whole_static_libs: [
         "libc_bionic_ndk",
+        "libc_fortify",
         "libc_freebsd",
         "libc_freebsd_large_stack",
         "libc_gdtoa",
@@ -1678,6 +1771,7 @@ cc_library_static {
         "libc_bionic",
         "libc_bionic_ndk",
         "libc_dns",
+        "libc_fortify",
         "libc_freebsd",
         "libc_freebsd_large_stack",
         "libc_gdtoa",
index 7ad0093..4297cd6 100644 (file)
         // arch. The code generated is exactly the same.
         .arch armv7-a
 
-ENTRY(__memcpy_chk)
-        cmp r2, r3
-        bls memcpy
-
-        // Preserve lr for backtrace.
-        push        {lr}
-        .cfi_def_cfa_offset 4
-        .cfi_rel_offset lr, 0
-        bl          __memcpy_chk_fail
-END(__memcpy_chk)
-
 // Prototype: void *memcpy (void *dst, const void *src, size_t count).
 ENTRY(memcpy)
         pld     [r1, #64]
index 7ad0093..4297cd6 100644 (file)
         // arch. The code generated is exactly the same.
         .arch armv7-a
 
-ENTRY(__memcpy_chk)
-        cmp r2, r3
-        bls memcpy
-
-        // Preserve lr for backtrace.
-        push        {lr}
-        .cfi_def_cfa_offset 4
-        .cfi_rel_offset lr, 0
-        bl          __memcpy_chk_fail
-END(__memcpy_chk)
-
 // Prototype: void *memcpy (void *dst, const void *src, size_t count).
 ENTRY(memcpy)
         pld     [r1, #64]
index 7ad0093..4297cd6 100644 (file)
         // arch. The code generated is exactly the same.
         .arch armv7-a
 
-ENTRY(__memcpy_chk)
-        cmp r2, r3
-        bls memcpy
-
-        // Preserve lr for backtrace.
-        push        {lr}
-        .cfi_def_cfa_offset 4
-        .cfi_rel_offset lr, 0
-        bl          __memcpy_chk_fail
-END(__memcpy_chk)
-
 // Prototype: void *memcpy (void *dst, const void *src, size_t count).
 ENTRY(memcpy)
         pld     [r1, #64]
index 93a8629..5a986d1 100644 (file)
         .thumb
         .thumb_func
 
-ENTRY(__memcpy_chk)
-        cmp         r2, r3
-        bls         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)
         pld     [r1, #0]
         stmfd   sp!, {r0, lr}
index 743c74b..8528f28 100644 (file)
         // arch. The code generated is exactly the same.
         .arch armv7-a
 
-ENTRY(__memcpy_chk)
-        cmp     r2, r3
-        bls     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)
         pld     [r1, #64]
         push    {r0, lr}
diff --git a/libc/arch-arm/generic/bionic/__memcpy_chk.S b/libc/arch-arm/generic/bionic/__memcpy_chk.S
new file mode 100644 (file)
index 0000000..7044e5f
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <private/bionic_asm.h>
+
+         .syntax unified
+
+ENTRY(__memcpy_chk)
+        cmp         r2, r3
+        bls         memcpy
+
+        // Preserve lr for backtrace.
+        push        {lr}
+        .cfi_def_cfa_offset 4
+        .cfi_rel_offset lr, 0
+
+        bl          __memcpy_chk_fail
+END(__memcpy_chk)
index a3ebb95..d1e4372 100644 (file)
 
          .syntax unified
 
-ENTRY(__memcpy_chk)
-        cmp         r2, r3
-        bls         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)
         /* The stack must always be 64-bits aligned to be compliant with the
          * ARM ABI. Since we have to save R0, we might as well save R4
index de6f432..f22c063 100644 (file)
         .thumb
         .thumb_func
 
-ENTRY(__memcpy_chk)
-        cmp         r2, r3
-        bls         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)
         pld     [r1, #64]
         stmfd   sp!, {r0, lr}
index 7e96f7d..e9ee2ac 100644 (file)
 #define PLDSIZE (128) /* L2 cache line size */
 
         .code 32
-ENTRY(__memcpy_chk)
-        cmp         r2, r3
-        bls         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)
         push            {r0}
         .cfi_def_cfa_offset 4
index 0be2aac..fc487d3 100644 (file)
 
 #include <private/bionic_asm.h>
 
-ENTRY(__memcpy_chk)
-  cmp x2, x3
-  bls memcpy
-
-  // Preserve for accurate backtrace.
-  stp x29, x30, [sp, -16]!
-  .cfi_def_cfa_offset 16
-  .cfi_rel_offset x29, 0
-  .cfi_rel_offset x30, 8
-
-  bl __memcpy_chk_fail
-END(__memcpy_chk)
-
 ENTRY(memcpy)
   #include "memcpy_base.S"
 END(memcpy)
diff --git a/libc/arch-arm64/generic/bionic/__memcpy_chk.S b/libc/arch-arm64/generic/bionic/__memcpy_chk.S
new file mode 100644 (file)
index 0000000..4217775
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <private/bionic_asm.h>
+
+ENTRY(__memcpy_chk)
+  cmp x2, x3
+  bls memcpy
+
+  // Preserve for accurate backtrace.
+  stp x29, x30, [sp, -16]!
+  .cfi_def_cfa_offset 16
+  .cfi_rel_offset x29, 0
+  .cfi_rel_offset x30, 8
+
+  bl __memcpy_chk_fail
+END(__memcpy_chk)
index 0be2aac..fc487d3 100644 (file)
 
 #include <private/bionic_asm.h>
 
-ENTRY(__memcpy_chk)
-  cmp x2, x3
-  bls memcpy
-
-  // Preserve for accurate backtrace.
-  stp x29, x30, [sp, -16]!
-  .cfi_def_cfa_offset 16
-  .cfi_rel_offset x29, 0
-  .cfi_rel_offset x30, 8
-
-  bl __memcpy_chk_fail
-END(__memcpy_chk)
-
 ENTRY(memcpy)
   #include "memcpy_base.S"
 END(memcpy)
index 7b42d99..9463954 100644 (file)
@@ -26,8 +26,6 @@
  * SUCH DAMAGE.
  */
 
-#undef _FORTIFY_SOURCE
-
 #include <string.h>
 
 #include "private/bionic_fortify.h"
index 116fff4..6fbfb8b 100644 (file)
@@ -26,8 +26,6 @@
  * SUCH DAMAGE.
  */
 
-#undef _FORTIFY_SOURCE
-
 #include <string.h>
 
 #include "private/bionic_fortify.h"
index 144e133..b888f09 100644 (file)
@@ -55,8 +55,6 @@
  * SUCH DAMAGE.
  */
 
-#undef _FORTIFY_SOURCE
-
 #include <poll.h>
 #include <stdarg.h>
 #include <stddef.h>