Merge changes from topic "r16-cp" into ndk-release-r16

* changes:
  Move crt sources out of API specific directories.
  Cleanup crtend names.
  Unify the arm32 crtbegin sources.
diff --git a/ndk/platforms/android-9/arch-arm/src/__dso_handle.h b/ndk/crt/arm/__dso_handle.h
similarity index 100%
rename from ndk/platforms/android-9/arch-arm/src/__dso_handle.h
rename to ndk/crt/arm/__dso_handle.h
diff --git a/ndk/platforms/android-9/arch-arm/src/__dso_handle_so.h b/ndk/crt/arm/__dso_handle_so.h
similarity index 100%
rename from ndk/platforms/android-9/arch-arm/src/__dso_handle_so.h
rename to ndk/crt/arm/__dso_handle_so.h
diff --git a/ndk/platforms/android-21/arch-arm64/src/atexit.h b/ndk/crt/arm/atexit.h
similarity index 100%
rename from ndk/platforms/android-21/arch-arm64/src/atexit.h
rename to ndk/crt/arm/atexit.h
diff --git a/ndk/platforms/android-21/arch-arm/src/crtbegin.c b/ndk/crt/arm/crtbegin.c
similarity index 93%
rename from ndk/platforms/android-21/arch-arm/src/crtbegin.c
rename to ndk/crt/arm/crtbegin.c
index 01e85c6..0753d14 100644
--- a/ndk/platforms/android-21/arch-arm/src/crtbegin.c
+++ b/ndk/crt/arm/crtbegin.c
@@ -84,4 +84,8 @@
 }
 
 #include "__dso_handle.h"
+// Old releases included atexit() details in libc.a, not in crtbegin_static.o.
+// It was, however, in crtbegin_dynamic.o rather than libc.so.
+#if PLATFORM_SDK_VERSION >= 21 || defined(BUILDING_DYNAMIC)
 #include "atexit.h"
+#endif
diff --git a/ndk/platforms/android-21/arch-arm64/src/crtbegin_so.c b/ndk/crt/arm/crtbegin_so.c
similarity index 100%
rename from ndk/platforms/android-21/arch-arm64/src/crtbegin_so.c
rename to ndk/crt/arm/crtbegin_so.c
diff --git a/ndk/platforms/android-9/arch-arm/src/crtend.S b/ndk/crt/arm/crtend_android.S
similarity index 100%
rename from ndk/platforms/android-9/arch-arm/src/crtend.S
rename to ndk/crt/arm/crtend_android.S
diff --git a/ndk/platforms/android-9/arch-arm/src/crtend_so.S b/ndk/crt/arm/crtend_so.S
similarity index 100%
rename from ndk/platforms/android-9/arch-arm/src/crtend_so.S
rename to ndk/crt/arm/crtend_so.S
diff --git a/ndk/platforms/android-21/arch-arm64/src/atexit.h b/ndk/crt/arm64/atexit.h
similarity index 100%
copy from ndk/platforms/android-21/arch-arm64/src/atexit.h
copy to ndk/crt/arm64/atexit.h
diff --git a/ndk/platforms/android-21/arch-arm64/src/crtbegin.c b/ndk/crt/arm64/crtbegin.c
similarity index 100%
rename from ndk/platforms/android-21/arch-arm64/src/crtbegin.c
rename to ndk/crt/arm64/crtbegin.c
diff --git a/ndk/platforms/android-21/arch-arm64/src/crtbegin_so.c b/ndk/crt/arm64/crtbegin_so.c
similarity index 100%
copy from ndk/platforms/android-21/arch-arm64/src/crtbegin_so.c
copy to ndk/crt/arm64/crtbegin_so.c
diff --git a/ndk/platforms/android-21/arch-arm64/src/crtend.S b/ndk/crt/arm64/crtend_android.S
similarity index 100%
rename from ndk/platforms/android-21/arch-arm64/src/crtend.S
rename to ndk/crt/arm64/crtend_android.S
diff --git a/ndk/platforms/android-21/arch-arm64/src/crtend_so.S b/ndk/crt/arm64/crtend_so.S
similarity index 100%
rename from ndk/platforms/android-21/arch-arm64/src/crtend_so.S
rename to ndk/crt/arm64/crtend_so.S
diff --git a/ndk/platforms/android-9/arch-mips/src/atexit.h b/ndk/crt/mips/atexit.h
similarity index 100%
rename from ndk/platforms/android-9/arch-mips/src/atexit.h
rename to ndk/crt/mips/atexit.h
diff --git a/ndk/platforms/android-9/arch-mips/src/crtbegin.c b/ndk/crt/mips/crtbegin.c
similarity index 100%
rename from ndk/platforms/android-9/arch-mips/src/crtbegin.c
rename to ndk/crt/mips/crtbegin.c
diff --git a/ndk/platforms/android-9/arch-mips/src/crtbegin_so.c b/ndk/crt/mips/crtbegin_so.c
similarity index 100%
rename from ndk/platforms/android-9/arch-mips/src/crtbegin_so.c
rename to ndk/crt/mips/crtbegin_so.c
diff --git a/ndk/platforms/android-9/arch-mips/src/crtend_android.S b/ndk/crt/mips/crtend_android.S
similarity index 100%
rename from ndk/platforms/android-9/arch-mips/src/crtend_android.S
rename to ndk/crt/mips/crtend_android.S
diff --git a/ndk/platforms/android-9/arch-mips/src/crtend_so.S b/ndk/crt/mips/crtend_so.S
similarity index 100%
rename from ndk/platforms/android-9/arch-mips/src/crtend_so.S
rename to ndk/crt/mips/crtend_so.S
diff --git a/ndk/platforms/android-9/arch-x86/src/asm_multiarch.h b/ndk/crt/mips64/asm_multiarch.h
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/asm_multiarch.h
rename to ndk/crt/mips64/asm_multiarch.h
diff --git a/ndk/platforms/android-9/arch-mips/src/atexit.h b/ndk/crt/mips64/atexit.h
similarity index 100%
copy from ndk/platforms/android-9/arch-mips/src/atexit.h
copy to ndk/crt/mips64/atexit.h
diff --git a/ndk/platforms/android-21/arch-mips64/src/crtbegin.c b/ndk/crt/mips64/crtbegin.c
similarity index 100%
rename from ndk/platforms/android-21/arch-mips64/src/crtbegin.c
rename to ndk/crt/mips64/crtbegin.c
diff --git a/ndk/platforms/android-9/arch-mips/src/crtbegin_so.c b/ndk/crt/mips64/crtbegin_so.c
similarity index 100%
copy from ndk/platforms/android-9/arch-mips/src/crtbegin_so.c
copy to ndk/crt/mips64/crtbegin_so.c
diff --git a/ndk/platforms/android-21/arch-mips64/src/crtend_android.S b/ndk/crt/mips64/crtend_android.S
similarity index 100%
rename from ndk/platforms/android-21/arch-mips64/src/crtend_android.S
rename to ndk/crt/mips64/crtend_android.S
diff --git a/ndk/platforms/android-21/arch-mips64/src/crtend_so.S b/ndk/crt/mips64/crtend_so.S
similarity index 100%
rename from ndk/platforms/android-21/arch-mips64/src/crtend_so.S
rename to ndk/crt/mips64/crtend_so.S
diff --git a/ndk/platforms/android-9/arch-x86/src/__stack_chk_fail_local.h b/ndk/crt/x86/__stack_chk_fail_local.h
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/__stack_chk_fail_local.h
rename to ndk/crt/x86/__stack_chk_fail_local.h
diff --git a/ndk/platforms/android-9/arch-x86/src/asm_multiarch.h b/ndk/crt/x86/asm_multiarch.h
similarity index 100%
copy from ndk/platforms/android-9/arch-x86/src/asm_multiarch.h
copy to ndk/crt/x86/asm_multiarch.h
diff --git a/ndk/platforms/android-21/arch-arm64/src/atexit.h b/ndk/crt/x86/atexit.h
similarity index 100%
copy from ndk/platforms/android-21/arch-arm64/src/atexit.h
copy to ndk/crt/x86/atexit.h
diff --git a/ndk/platforms/android-9/arch-x86/src/crtbegin.c b/ndk/crt/x86/crtbegin.c
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/crtbegin.c
rename to ndk/crt/x86/crtbegin.c
diff --git a/ndk/platforms/android-9/arch-x86/src/crtbegin_so.c b/ndk/crt/x86/crtbegin_so.c
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/crtbegin_so.c
rename to ndk/crt/x86/crtbegin_so.c
diff --git a/ndk/platforms/android-9/arch-x86/src/crtend.S b/ndk/crt/x86/crtend_android.S
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/crtend.S
rename to ndk/crt/x86/crtend_android.S
diff --git a/ndk/platforms/android-9/arch-x86/src/crtend_so.S b/ndk/crt/x86/crtend_so.S
similarity index 100%
rename from ndk/platforms/android-9/arch-x86/src/crtend_so.S
rename to ndk/crt/x86/crtend_so.S
diff --git a/ndk/crt/x86_64 b/ndk/crt/x86_64
new file mode 120000
index 0000000..f4bad79
--- /dev/null
+++ b/ndk/crt/x86_64
@@ -0,0 +1 @@
+x86
\ No newline at end of file
diff --git a/ndk/platforms/android-21/arch-arm/src/__dso_handle.h b/ndk/platforms/android-21/arch-arm/src/__dso_handle.h
deleted file mode 100644
index 72f12da..0000000
--- a/ndk/platforms/android-21/arch-arm/src/__dso_handle.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-/* The __dso_handle global variable is used by static
-   C++ constructors and destructors in the binary.
-   See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
-
-   CRT_LEGACY_WORKAROUND is only defined when building this file
-   for the C library. This forces __dso_handle to be exported by
-   it. This is only required to ensure binary compatibility with
-   old NDK application machine code that contains reference to
-   the symbol, but do not have a proper definition for it.
-
-   These binaries cannot call their destructorson dlclose(), but
-   at least they will not fail to load.
-
-   When this file is built for the NDK, CRT_LEGACY_WORKAROUND
-   should never be defined.
- */
-
-#ifndef CRT_LEGACY_WORKAROUND
-__attribute__ ((visibility ("hidden")))
-#endif
-__attribute__ ((section (".bss")))
-void *__dso_handle = (void *) 0;
diff --git a/ndk/platforms/android-21/arch-arm/src/atexit.h b/ndk/platforms/android-21/arch-arm/src/atexit.h
deleted file mode 100644
index 0a3eee4..0000000
--- a/ndk/platforms/android-21/arch-arm/src/atexit.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2016 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 <stddef.h>
-
-extern void* __dso_handle;
-
-extern int __cxa_atexit(void (*)(void*), void*, void*);
-
-__attribute__ ((visibility ("hidden")))
-void __atexit_handler_wrapper(void* func) {
-  if (func != NULL) {
-    (*(void (*)(void))func)();
-  }
-}
-
-__attribute__ ((visibility ("hidden")))
-int atexit(void (*func)(void)) {
-  return (__cxa_atexit(&__atexit_handler_wrapper, func, &__dso_handle));
-}
diff --git a/ndk/platforms/android-21/arch-mips64/src/asm_multiarch.h b/ndk/platforms/android-21/arch-mips64/src/asm_multiarch.h
deleted file mode 100644
index 91cb8af..0000000
--- a/ndk/platforms/android-21/arch-mips64/src/asm_multiarch.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#ifdef __LP64__
-# define ASM_PTR_SIZE(x) .quad x
-# define ASM_ALIGN_TO_PTR_SIZE .balign 8
-#else
-# define ASM_PTR_SIZE(x) .long x
-# define ASM_ALIGN_TO_PTR_SIZE .balign 4
-#endif
-
diff --git a/ndk/platforms/android-21/arch-mips64/src/atexit.h b/ndk/platforms/android-21/arch-mips64/src/atexit.h
deleted file mode 100644
index 3ded9bf..0000000
--- a/ndk/platforms/android-21/arch-mips64/src/atexit.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2013 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 <stddef.h>
-
-extern void* __dso_handle;
-
-extern int __cxa_atexit(void (*)(void*), void*, void*);
-
-__attribute__ ((visibility ("hidden")))
-void __atexit_handler_wrapper(void* func) {
-  if (func != NULL) {
-    (*(void (*)(void))func)();
-  }
-}
-
-__attribute__ ((visibility ("hidden")))
-int atexit(void (*func)(void)) {
-  return (__cxa_atexit(&__atexit_handler_wrapper, func, &__dso_handle));
-}
diff --git a/ndk/platforms/android-21/arch-mips64/src/crtbegin_so.c b/ndk/platforms/android-21/arch-mips64/src/crtbegin_so.c
deleted file mode 100644
index 925dc8c..0000000
--- a/ndk/platforms/android-21/arch-mips64/src/crtbegin_so.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-extern void __cxa_finalize(void *);
-extern void *__dso_handle;
-
-__attribute__((visibility("hidden"),destructor))
-void __on_dlclose() {
-  __cxa_finalize(&__dso_handle);
-}
-
-#include "__dso_handle_so.h"
-#include "atexit.h"
diff --git a/ndk/platforms/android-21/arch-x86_64/src b/ndk/platforms/android-21/arch-x86_64/src
deleted file mode 120000
index 18d4e35..0000000
--- a/ndk/platforms/android-21/arch-x86_64/src
+++ /dev/null
@@ -1 +0,0 @@
-../../android-9/arch-x86/src
\ No newline at end of file
diff --git a/ndk/platforms/android-9/arch-arm/src/atexit.h b/ndk/platforms/android-9/arch-arm/src/atexit.h
deleted file mode 100644
index 90aa030..0000000
--- a/ndk/platforms/android-9/arch-arm/src/atexit.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2012 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 <stddef.h>
-
-extern void* __dso_handle;
-
-extern int __cxa_atexit(void (*)(void*), void*, void*);
-
-__attribute__ ((visibility ("hidden")))
-void __atexit_handler_wrapper(void* func) {
-  if (func != NULL) {
-    (*(void (*)(void))func)();
-  }
-}
-
-__attribute__ ((visibility ("hidden")))
-int atexit(void (*func)(void)) {
-  return (__cxa_atexit(&__atexit_handler_wrapper, func, &__dso_handle));
-}
diff --git a/ndk/platforms/android-9/arch-arm/src/crtbegin_dynamic.c b/ndk/platforms/android-9/arch-arm/src/crtbegin_dynamic.c
deleted file mode 100644
index edb417d..0000000
--- a/ndk/platforms/android-9/arch-arm/src/crtbegin_dynamic.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-typedef struct
-{
-    void (**preinit_array)(void);
-    void (**init_array)(void);
-    void (**fini_array)(void);
-    void (**ctor_list)(void);
-} structors_array_t;
-
-extern int main(int argc, char **argv, char **env);
-
-extern void __libc_init(
-  unsigned int *elfdata,
-  void (*onexit)(void),
-  int (*slingshot)(int, char**, char**),
-  structors_array_t const * const structors
-);
-
-__attribute__ ((section (".preinit_array")))
-void (*__PREINIT_ARRAY__)(void) = (void (*)(void)) -1;
-
-__attribute__ ((section (".init_array")))
-void (*__INIT_ARRAY__)(void) = (void (*)(void)) -1;
-
-__attribute__ ((section (".fini_array")))
-void (*__FINI_ARRAY__)(void) = (void (*)(void)) -1;
-
-__attribute__ ((section (".ctors")))
-void (*__CTOR_LIST__)(void) = (void (*)(void)) -1;
-
-/* this is the small startup code that is first run when
-   any executable that is dynamically-linked with Bionic
-   runs.
-
-   it's purpose is to call __libc_init with appropriate
-   arguments, which are:
-
-    - the address of the raw data block setup by the Linux
-      kernel ELF loader
-
-    - address of an "onexit" function, not used on any
-      platform supported by Bionic
-
-    - address of the "main" function of the program.
-
-    - address of the constructor list
-*/
-
-__attribute__((visibility("hidden")))
-void _start() {
-  structors_array_t array;
-  void *elfdata;
-
-  array.preinit_array = &__PREINIT_ARRAY__;
-  array.init_array =    &__INIT_ARRAY__;
-  array.fini_array =    &__FINI_ARRAY__;
-  array.ctor_list =    &__CTOR_LIST__;
-
-  elfdata = __builtin_frame_address(0) + sizeof(void *);
-  __libc_init(elfdata, (void *) 0, &main, &array);
-}
-
-#include "__dso_handle.h"
-#include "atexit.h"
diff --git a/ndk/platforms/android-9/arch-arm/src/crtbegin_so.c b/ndk/platforms/android-9/arch-arm/src/crtbegin_so.c
deleted file mode 100644
index cd0257a..0000000
--- a/ndk/platforms/android-9/arch-arm/src/crtbegin_so.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-extern void __cxa_finalize(void *);
-extern void *__dso_handle;
-
-__attribute__((visibility("hidden"),destructor))
-void __on_dlclose() {
-  __cxa_finalize(&__dso_handle);
-}
-
-/* CRT_LEGACY_WORKAROUND should only be defined when building
- * this file as part of the platform's C library.
- *
- * The C library already defines a function named 'atexit()'
- * for backwards compatibility with older NDK-generated binaries.
- *
- * For newer ones, 'atexit' is actually embedded in the C
- * runtime objects that are linked into the final ELF
- * binary (shared library or executable), and will call
- * __cxa_atexit() in order to un-register any atexit()
- * handler when a library is unloaded.
- *
- * This function must be global *and* hidden. Only the
- * code inside the same ELF binary should be able to access it.
- */
-
-#ifdef CRT_LEGACY_WORKAROUND
-#include "__dso_handle.h"
-#else
-#include "__dso_handle_so.h"
-#include "atexit.h"
-#endif
diff --git a/ndk/platforms/android-9/arch-arm/src/crtbegin_static.c b/ndk/platforms/android-9/arch-arm/src/crtbegin_static.c
deleted file mode 100644
index 0a72335..0000000
--- a/ndk/platforms/android-9/arch-arm/src/crtbegin_static.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-typedef struct
-{
-    void (**preinit_array)(void);
-    void (**init_array)(void);
-    void (**fini_array)(void);
-    void (**ctor_list)(void);
-} structors_array_t;
-
-extern int main(int argc, char **argv, char **env);
-
-extern void __libc_init(
-  unsigned int *elfdata,
-  void (*onexit)(void),
-  int (*slingshot)(int, char**, char**),
-  structors_array_t const * const structors
-);
-
-__attribute__ ((section (".preinit_array")))
-void (*__PREINIT_ARRAY__)(void) = (void (*)(void)) -1;
-
-__attribute__ ((section (".init_array")))
-void (*__INIT_ARRAY__)(void) = (void (*)(void)) -1;
-
-__attribute__ ((section (".fini_array")))
-void (*__FINI_ARRAY__)(void) = (void (*)(void)) -1;
-
-__attribute__ ((section (".ctors")))
-void (*__CTOR_LIST__)(void) = (void (*)(void)) -1;
-
-/* this is the small startup code that is first run when
-   any executable that is statically-linked with Bionic
-   runs.
-
-   it's purpose is to call __libc_init with appropriate
-   arguments, which are:
-
-    - the address of the raw data block setup by the Linux
-      kernel ELF loader
-
-    - address of an "onexit" function, not used on any
-      platform supported by Bionic
-
-    - address of the "main" function of the program.
-
-    - address of the constructor list
-*/
-
-__attribute__((visibility("hidden")))
-void _start() {
-  structors_array_t array;
-  void *elfdata;
-
-  array.preinit_array = &__PREINIT_ARRAY__;
-  array.init_array =    &__INIT_ARRAY__;
-  array.fini_array =    &__FINI_ARRAY__;
-  array.ctor_list =    &__CTOR_LIST__;
-
-  elfdata = __builtin_frame_address(0) + sizeof(void *);
-  __libc_init(elfdata, (void *) 0, &main, &array);
-}
-
-#include "__dso_handle.h"
-/* NOTE: atexit() is  not be provided by crtbegin_static.c, but by libc.a */
diff --git a/ndk/platforms/android-9/arch-x86/src/atexit.h b/ndk/platforms/android-9/arch-x86/src/atexit.h
deleted file mode 100644
index 90aa030..0000000
--- a/ndk/platforms/android-9/arch-x86/src/atexit.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2012 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 <stddef.h>
-
-extern void* __dso_handle;
-
-extern int __cxa_atexit(void (*)(void*), void*, void*);
-
-__attribute__ ((visibility ("hidden")))
-void __atexit_handler_wrapper(void* func) {
-  if (func != NULL) {
-    (*(void (*)(void))func)();
-  }
-}
-
-__attribute__ ((visibility ("hidden")))
-int atexit(void (*func)(void)) {
-  return (__cxa_atexit(&__atexit_handler_wrapper, func, &__dso_handle));
-}