OSDN Git Service

Move common arch-* code to arch-common directory
authorPavel Chupin <pavel.v.chupin@intel.com>
Wed, 2 Oct 2013 12:38:05 +0000 (16:38 +0400)
committerPavel Chupin <pavel.v.chupin@intel.com>
Thu, 3 Oct 2013 07:14:33 +0000 (11:14 +0400)
Will be helpful on adding x86_64

Change-Id: I96cf6fc7912c02f289c75f07ae0079c32d69173f
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
12 files changed:
libc/Android.mk
libc/arch-arm/bionic/crtbegin.c [deleted file]
libc/arch-arm/bionic/crtbegin_so.c [deleted file]
libc/arch-common/bionic/asm_multiarch.h [moved from libc/arch-arm/bionic/crtend_so.S with 87% similarity]
libc/arch-common/bionic/atexit.h [moved from libc/arch-arm/bionic/atexit.h with 100% similarity]
libc/arch-common/bionic/crtbegin.c [moved from libc/arch-x86/bionic/crtbegin.c with 95% similarity]
libc/arch-common/bionic/crtbegin_so.c [moved from libc/arch-x86/bionic/crtbegin_so.c with 93% similarity]
libc/arch-common/bionic/crtend.S [moved from libc/arch-arm/bionic/crtend.S with 85% similarity]
libc/arch-common/bionic/crtend_so.S [moved from libc/arch-mips/bionic/crtend.S with 77% similarity]
libc/arch-mips/bionic/crtend_so.S [deleted file]
libc/arch-x86/bionic/crtend.S [deleted file]
libc/arch-x86/bionic/crtend_so.S [deleted file]

index c7478c5..3d06514 100644 (file)
@@ -646,18 +646,20 @@ libc_crt_target_cflags += \
 # 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.
@@ -687,7 +689,7 @@ $(GEN): $(libc_crt_target_crtbegin_so_file)
 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 $<
@@ -740,7 +742,7 @@ ALL_GENERATED_SOURCES += $(GEN)
 # 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 $<
@@ -979,10 +981,10 @@ ifeq ($(TARGET_ARCH),arm)
        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
diff --git a/libc/arch-arm/bionic/crtbegin.c b/libc/arch-arm/bionic/crtbegin.c
deleted file mode 100644 (file)
index 1bcb335..0000000
+++ /dev/null
@@ -1,53 +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 "../../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"
diff --git a/libc/arch-arm/bionic/crtbegin_so.c b/libc/arch-arm/bionic/crtbegin_so.c
deleted file mode 100644 (file)
index cd0257a..0000000
+++ /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
similarity index 87%
rename from libc/arch-arm/bionic/crtend_so.S
rename to libc/arch-common/bionic/asm_multiarch.h
index bb6570e..32c7e5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
+
similarity index 95%
rename from libc/arch-x86/bionic/crtbegin.c
rename to libc/arch-common/bionic/crtbegin.c
index 43e9306..bc67bfb 100644 (file)
@@ -40,7 +40,9 @@ __attribute__ ((section (".fini_array")))
 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__;
@@ -53,4 +55,6 @@ void _start() {
 
 #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
similarity index 93%
rename from libc/arch-x86/bionic/crtbegin_so.c
rename to libc/arch-common/bionic/crtbegin_so.c
index 30de6af..bd70edf 100644 (file)
@@ -51,9 +51,12 @@ void __on_dlclose() {
  */
 
 #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
+
similarity index 85%
rename from libc/arch-arm/bionic/crtend.S
rename to libc/arch-common/bionic/crtend.S
index fffb0ab..a4cf8de 100644 (file)
  * 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
similarity index 77%
rename from libc/arch-mips/bionic/crtend.S
rename to libc/arch-common/bionic/crtend_so.S
index 6984d0e..f745109 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
diff --git a/libc/arch-mips/bionic/crtend_so.S b/libc/arch-mips/bionic/crtend_so.S
deleted file mode 100644 (file)
index f09c427..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-       .section .init_array, "aw"
-       .long 0
-
-       .section .fini_array, "aw"
-       .long 0
diff --git a/libc/arch-x86/bionic/crtend.S b/libc/arch-x86/bionic/crtend.S
deleted file mode 100644 (file)
index 68447e7..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-       .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
diff --git a/libc/arch-x86/bionic/crtend_so.S b/libc/arch-x86/bionic/crtend_so.S
deleted file mode 100644 (file)
index 63e58b9..0000000
+++ /dev/null
@@ -1,12 +0,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