# that will call __cxa_finalize(&__dso_handle) in order to ensure that
# static C++ destructors are properly called on dlclose().
#
+libc_crt_target_crtbegin_file := $(LOCAL_PATH)/arch-common/bionic/crtbegin.c
+libc_crt_target_crtbegin_so_file := $(LOCAL_PATH)/arch-common/bionic/crtbegin_so.c
+
ifeq ($(TARGET_ARCH),arm)
libc_crt_target_so_cflags :=
endif
ifeq ($(TARGET_ARCH),mips)
libc_crt_target_so_cflags := -fPIC
+libc_crt_target_crtbegin_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.c
endif
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
libc_crt_target_so_cflags := -fPIC
endif
libc_crt_target_so_cflags += $(libc_crt_target_cflags)
-libc_crt_target_crtbegin_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.c
-libc_crt_target_crtbegin_so_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.c
# See the comment in crtbrand.c for the reason why we need to generate
# crtbrand.s before generating crtbrand.o.
ALL_GENERATED_SOURCES += $(GEN)
GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
-$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
+$(GEN): $(LOCAL_PATH)/arch-common/bionic/crtend_so.S
@mkdir -p $(dir $@)
$(hide) $(TARGET_CC) $(libc_crt_target_so_cflags) \
-MD -MF $(@:%.o=%.d) -o $@ -c $<
# We rename crtend.o to crtend_android.o to avoid a
# name clash between gcc and bionic.
GEN := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
-$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
+$(GEN): $(LOCAL_PATH)/arch-common/bionic/crtend.S
@mkdir -p $(dir $@)
$(hide) $(TARGET_CC) $(libc_crt_target_cflags) \
-MD -MF $(@:%.o=%.d) -o $@ -c $<
LOCAL_CFLAGS += -DCRT_LEGACY_WORKAROUND
LOCAL_SRC_FILES := \
- arch-arm/bionic/crtbegin_so.c \
+ arch-common/bionic/crtbegin_so.c \
arch-arm/bionic/atexit_legacy.c \
$(LOCAL_SRC_FILES) \
- arch-arm/bionic/crtend_so.S
+ arch-common/bionic/crtend_so.S
endif
LOCAL_MODULE:= libc
+++ /dev/null
-/*
- * 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 "../../bionic/libc_init_common.h"
-#include <stddef.h>
-#include <stdint.h>
-
-__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;
-
-__LIBC_HIDDEN__ void _start() {
- structors_array_t array;
- array.preinit_array = &__PREINIT_ARRAY__;
- array.init_array = &__INIT_ARRAY__;
- array.fini_array = &__FINI_ARRAY__;
-
- void* raw_args = (void*) ((uintptr_t) __builtin_frame_address(0) + sizeof(void*));
- __libc_init(raw_args, NULL, &main, &array);
-}
-
-#include "__dso_handle.h"
-#include "atexit.h"
+++ /dev/null
-/*
- * 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
/*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* SUCH DAMAGE.
*/
-#if defined(__linux__) && defined(__ELF__)
- .section .note.GNU-stack,"",%progbits
+#ifdef __LP64__
+# define ASM_PTR_SIZE(x) .quad x
+# define ASM_ALIGN(x) .align 4
+#else
+# define ASM_PTR_SIZE(x) .long x
+# define ASM_ALIGN(x)
#endif
+
void (*__FINI_ARRAY__)(void) = (void (*)(void)) -1;
__LIBC_HIDDEN__
+#ifdef __i386__
__attribute__((force_align_arg_pointer))
+#endif
void _start() {
structors_array_t array;
array.preinit_array = &__PREINIT_ARRAY__;
#include "__dso_handle.h"
#include "atexit.h"
-#include "__stack_chk_fail_local.h"
+#ifdef __i386__
+# include "../../arch-x86/bionic/__stack_chk_fail_local.h"
+#endif
*/
#ifdef CRT_LEGACY_WORKAROUND
-#include "__dso_handle.h"
+# include "__dso_handle.h"
#else
-#include "__dso_handle_so.h"
-#include "atexit.h"
-#include "__stack_chk_fail_local.h"
+# include "__dso_handle_so.h"
+# include "atexit.h"
#endif
+#ifdef __i386__
+# include "../../arch-x86/bionic/__stack_chk_fail_local.h"
+#endif
+
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
+
+#include "asm_multiarch.h"
+
.section .preinit_array, "aw"
- .long 0
+ ASM_PTR_SIZE(0)
.section .init_array, "aw"
- .long 0
+ ASM_PTR_SIZE(0)
.section .fini_array, "aw"
- .long 0
+ ASM_PTR_SIZE(0)
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif
+#if defined(__i386__) || defined(__x86_64__)
+ .section .eh_frame,"a",@progbits
+ ASM_ALIGN(4)
+ .type __FRAME_END__, @object
+ .size __FRAME_END__, 4
+__FRAME_END__:
+ .zero 4
+#endif
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
- .section .preinit_array, "aw"
- .long 0
+#include "asm_multiarch.h"
+
+#ifndef __arm__
.section .init_array, "aw"
- .long 0
+ ASM_PTR_SIZE(0)
.section .fini_array, "aw"
- .long 0
+ ASM_PTR_SIZE(0)
+#endif
+#if defined(__linux__) && defined(__ELF__)
+ .section .note.GNU-stack,"",%progbits
+#endif
+#if defined(__i386__) || defined(__x86_64__)
+ .section .eh_frame,"a",@progbits
+ ASM_ALIGN(4)
+ .type __FRAME_END__, @object
+ .size __FRAME_END__, 4
+__FRAME_END__:
+ .zero 4
+#endif
+++ /dev/null
- .section .init_array, "aw"
- .long 0
-
- .section .fini_array, "aw"
- .long 0
+++ /dev/null
- .section .preinit_array, "aw"
- .long 0
-
- .section .init_array, "aw"
- .long 0
-
- .section .fini_array, "aw"
- .long 0
-
- .section .eh_frame,"a",@progbits
- .align 4
- .type __FRAME_END__, @object
- .size __FRAME_END__, 4
-__FRAME_END__:
- .zero 4
+++ /dev/null
-.section .init_array, "aw"
- .long 0
-
-.section .fini_array, "aw"
- .long 0
-
- .section .eh_frame,"a",@progbits
- .align 4
- .type __FRAME_END__, @object
- .size __FRAME_END__, 4
-__FRAME_END__:
- .zero 4