Merge "Move common arch-* code to arch-common directory"
This commit is contained in:
commit
141029327c
12 changed files with 60 additions and 167 deletions
|
@ -656,18 +656,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.
|
||||
|
@ -697,7 +699,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 $<
|
||||
|
@ -750,7 +752,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 $<
|
||||
|
@ -989,10 +991,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
|
||||
|
|
|
@ -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"
|
|
@ -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
|
||||
|
@ -26,6 +26,11 @@
|
|||
* 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
|
||||
|
|
@ -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
|
|
@ -51,8 +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 "__dso_handle_so.h"
|
||||
# include "atexit.h"
|
||||
#endif
|
||||
#ifdef __i386__
|
||||
# include "../../arch-x86/bionic/__stack_chk_fail_local.h"
|
||||
#endif
|
||||
|
|
@ -25,16 +25,26 @@
|
|||
* 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
|
|
@ -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
|
||||
|
@ -25,13 +25,25 @@
|
|||
* 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
|
|
@ -1,5 +0,0 @@
|
|||
.section .init_array, "aw"
|
||||
.long 0
|
||||
|
||||
.section .fini_array, "aw"
|
||||
.long 0
|
|
@ -1,59 +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"
|
||||
#include "__stack_chk_fail_local.h"
|
||||
#endif
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in a new issue