* commit '4102c6f241153cb04e2fad7900ffbc07841c1381': Rewrite ARM crtbegin* as C files
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2010 The Android Open Source Project
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -26,30 +26,25 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# The __dso_handle global variable is used by static
|
/* The __dso_handle global variable is used by static
|
||||||
# C++ constructors and destructors in the binary.
|
C++ constructors and destructors in the binary.
|
||||||
# See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
|
See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
|
||||||
#
|
|
||||||
.data
|
|
||||||
.align 4
|
|
||||||
|
|
||||||
/* CRT_LEGACY_WORKAROUND is only defined when building this file
|
CRT_LEGACY_WORKAROUND is only defined when building this file
|
||||||
* for the C library. This forces __dso_handle to be exported by
|
for the C library. This forces __dso_handle to be exported by
|
||||||
* it. This is only required to ensure binary compatibility with
|
it. This is only required to ensure binary compatibility with
|
||||||
* old NDK application machine code that contains reference to
|
old NDK application machine code that contains reference to
|
||||||
* the symbol, but do not have a proper definition for it.
|
the symbol, but do not have a proper definition for it.
|
||||||
*
|
|
||||||
* These binaries cannot call their destructorson dlclose(), but
|
These binaries cannot call their destructorson dlclose(), but
|
||||||
* at least they will not fail to load.
|
at least they will not fail to load.
|
||||||
*
|
|
||||||
* When this file is built for the NDK, CRT_LEGACY_WORKAROUND
|
When this file is built for the NDK, CRT_LEGACY_WORKAROUND
|
||||||
* should never be defined.
|
should never be defined.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CRT_LEGACY_WORKAROUND
|
#ifndef CRT_LEGACY_WORKAROUND
|
||||||
.hidden __dso_handle
|
__attribute__ ((visibility ("hidden")))
|
||||||
#endif
|
#endif
|
||||||
|
__attribute__ ((section (".bss")))
|
||||||
.globl __dso_handle
|
void *__dso_handle = (void *) 0;
|
||||||
__dso_handle:
|
|
||||||
.long __dso_handle
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2010 The Android Open Source Project
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -26,13 +26,11 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# The __dso_handle global variable is used by static
|
/* The __dso_handle global variable is used by static
|
||||||
# C++ constructors and destructors in the binary.
|
C++ constructors and destructors in the binary.
|
||||||
# See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
|
See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
|
||||||
#
|
*/
|
||||||
.data
|
|
||||||
.align 4
|
__attribute__ ((visibility ("hidden")))
|
||||||
.hidden __dso_handle
|
__attribute__ ((section (".data")))
|
||||||
.globl __dso_handle
|
void *__dso_handle;
|
||||||
__dso_handle:
|
|
||||||
.long __dso_handle
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2008 The Android Open Source Project
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -26,36 +26,10 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# Implement static C++ destructors when the shared
|
extern void *__dso_handle;
|
||||||
# library is unloaded through dlclose().
|
|
||||||
#
|
|
||||||
# A call to this function must be the first entry
|
|
||||||
# in the .fini_array. See 3.3.5.3.C of C++ ABI
|
|
||||||
# standard.
|
|
||||||
#
|
|
||||||
__on_dlclose:
|
|
||||||
adr r0, 0f
|
|
||||||
ldr r0, [r0]
|
|
||||||
b __cxa_finalize
|
|
||||||
|
|
||||||
0:
|
__attribute__ ((visibility ("hidden")))
|
||||||
.long __dso_handle
|
int atexit(void (*func)(void))
|
||||||
|
{
|
||||||
.section .init_array, "aw"
|
return (__cxa_atexit((void (*)(void *))func, (void *)0, &__dso_handle));
|
||||||
.globl __INIT_ARRAY__
|
}
|
||||||
__INIT_ARRAY__:
|
|
||||||
.long -1
|
|
||||||
|
|
||||||
.section .fini_array, "aw"
|
|
||||||
.globl __FINI_ARRAY__
|
|
||||||
__FINI_ARRAY__:
|
|
||||||
.long -1
|
|
||||||
.long __on_dlclose
|
|
||||||
|
|
||||||
#ifdef CRT_LEGACY_WORKAROUND
|
|
||||||
#include "__dso_handle.S"
|
|
||||||
#else
|
|
||||||
#include "__dso_handle_so.S"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "atexit.S"
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 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.
|
|
||||||
*/
|
|
||||||
.text
|
|
||||||
.align 4
|
|
||||||
.type _start,#function
|
|
||||||
.globl _start
|
|
||||||
|
|
||||||
# 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
|
|
||||||
#
|
|
||||||
_start:
|
|
||||||
mov r0, sp
|
|
||||||
mov r1, #0
|
|
||||||
ldr r2, =main
|
|
||||||
adr r3, 1f
|
|
||||||
ldr r4, =__libc_init
|
|
||||||
# Use blx intead of bx so stack unwinding past __libc_init can terminate at _start
|
|
||||||
blx r4
|
|
||||||
mov r0, #0
|
|
||||||
bx r0
|
|
||||||
|
|
||||||
1: .long __PREINIT_ARRAY__
|
|
||||||
.long __INIT_ARRAY__
|
|
||||||
.long __FINI_ARRAY__
|
|
||||||
.long __CTOR_LIST__
|
|
||||||
|
|
||||||
.section .preinit_array, "aw"
|
|
||||||
.globl __PREINIT_ARRAY__
|
|
||||||
__PREINIT_ARRAY__:
|
|
||||||
.long -1
|
|
||||||
|
|
||||||
.section .init_array, "aw"
|
|
||||||
.globl __INIT_ARRAY__
|
|
||||||
__INIT_ARRAY__:
|
|
||||||
.long -1
|
|
||||||
|
|
||||||
.section .fini_array, "aw"
|
|
||||||
.globl __FINI_ARRAY__
|
|
||||||
__FINI_ARRAY__:
|
|
||||||
.long -1
|
|
||||||
|
|
||||||
.section .ctors, "aw"
|
|
||||||
.globl __CTOR_LIST__
|
|
||||||
__CTOR_LIST__:
|
|
||||||
.long -1
|
|
||||||
|
|
||||||
#include "__dso_handle.S"
|
|
||||||
#include "atexit.S"
|
|
||||||
91
ndk/platforms/android-3/arch-arm/src/crtbegin_dynamic.c
Normal file
91
ndk/platforms/android-3/arch-arm/src/crtbegin_dynamic.c
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011 The Android Open Source Project
|
* Copyright (C) 2012 The Android Open Source Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -26,6 +26,14 @@
|
|||||||
* SUCH DAMAGE.
|
* 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
|
/* CRT_LEGACY_WORKAROUND should only be defined when building
|
||||||
* this file as part of the platform's C library.
|
* this file as part of the platform's C library.
|
||||||
*
|
*
|
||||||
@@ -41,43 +49,10 @@
|
|||||||
* This function must be global *and* hidden. Only the
|
* This function must be global *and* hidden. Only the
|
||||||
* code inside the same ELF binary should be able to access it.
|
* code inside the same ELF binary should be able to access it.
|
||||||
*/
|
*/
|
||||||
#ifndef CRT_LEGACY_WORKAROUND
|
|
||||||
.arch armv5te
|
#ifdef CRT_LEGACY_WORKAROUND
|
||||||
.fpu softvfp
|
#include "__dso_handle.h"
|
||||||
.eabi_attribute 20, 1
|
#else
|
||||||
.eabi_attribute 21, 1
|
#include "__dso_handle_so.h"
|
||||||
.eabi_attribute 23, 3
|
#include "atexit.h"
|
||||||
.eabi_attribute 24, 1
|
|
||||||
.eabi_attribute 25, 1
|
|
||||||
.eabi_attribute 26, 2
|
|
||||||
.eabi_attribute 30, 4
|
|
||||||
.eabi_attribute 18, 4
|
|
||||||
.hidden atexit
|
|
||||||
.code 16
|
|
||||||
.thumb_func
|
|
||||||
.text
|
|
||||||
.align 0
|
|
||||||
.global atexit
|
|
||||||
.type atexit, #function
|
|
||||||
atexit: .fnstart
|
|
||||||
.LFB0:
|
|
||||||
.save {r4, lr}
|
|
||||||
push {r4, lr}
|
|
||||||
.LCFI0:
|
|
||||||
ldr r3, .L3
|
|
||||||
mov r1, #0
|
|
||||||
@ sp needed for prologue
|
|
||||||
.LPIC0:
|
|
||||||
add r3, pc
|
|
||||||
ldr r2, [r3]
|
|
||||||
ldr r3, =__cxa_atexit
|
|
||||||
blx r3
|
|
||||||
pop {r4, pc}
|
|
||||||
.L4:
|
|
||||||
.align 2
|
|
||||||
.L3:
|
|
||||||
.word __dso_handle-(.LPIC0+4)
|
|
||||||
.LFE0:
|
|
||||||
.fnend
|
|
||||||
.size atexit, . - atexit
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2008 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.
|
|
||||||
*/
|
|
||||||
.text
|
|
||||||
.align 4
|
|
||||||
.type _start,#function
|
|
||||||
.globl _start
|
|
||||||
|
|
||||||
# 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
|
|
||||||
#
|
|
||||||
_start:
|
|
||||||
mov r0, sp
|
|
||||||
mov r1, #0
|
|
||||||
ldr r2, =main
|
|
||||||
adr r3, 1f
|
|
||||||
ldr r4, =__libc_init
|
|
||||||
# Use blx intead of bx so stack unwinding past __libc_init can terminate at _start
|
|
||||||
blx r4
|
|
||||||
mov r0, #0
|
|
||||||
bx r0
|
|
||||||
|
|
||||||
1: .long __PREINIT_ARRAY__
|
|
||||||
.long __INIT_ARRAY__
|
|
||||||
.long __FINI_ARRAY__
|
|
||||||
.long __CTOR_LIST__
|
|
||||||
|
|
||||||
.section .preinit_array, "aw"
|
|
||||||
.globl __PREINIT_ARRAY__
|
|
||||||
__PREINIT_ARRAY__:
|
|
||||||
.long -1
|
|
||||||
|
|
||||||
.section .init_array, "aw"
|
|
||||||
.globl __INIT_ARRAY__
|
|
||||||
__INIT_ARRAY__:
|
|
||||||
.long -1
|
|
||||||
|
|
||||||
.section .fini_array, "aw"
|
|
||||||
.globl __FINI_ARRAY__
|
|
||||||
__FINI_ARRAY__:
|
|
||||||
.long -1
|
|
||||||
|
|
||||||
.section .ctors, "aw"
|
|
||||||
.globl __CTOR_LIST__
|
|
||||||
__CTOR_LIST__:
|
|
||||||
.long -1
|
|
||||||
|
|
||||||
|
|
||||||
#include "__dso_handle.S"
|
|
||||||
/* NOTE: atexit() is not be provided by crtbegin_static.S, but by libc.a */
|
|
||||||
|
|
||||||
91
ndk/platforms/android-3/arch-arm/src/crtbegin_static.c
Normal file
91
ndk/platforms/android-3/arch-arm/src/crtbegin_static.c
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* 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 */
|
||||||
Reference in New Issue
Block a user