From 5e7c4e6a57aa156b40b29a568ea57841b5b7af30 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Wed, 23 May 2012 14:52:12 +0200 Subject: [PATCH] ndk: Remove prebuilt C runtime objects. Add sources instead. This patch removes all prebuilt C runtime object files from the ndk/platforms/ directory. We replace them with equivalent assembly sources lifted from the following directories: bionic/libc/private/ (for __dso_handle.S and __dso_handle_so.S) bionic/libc/arch-$ARCH/ (for all others) Note: This requires that your NDK's gen-platforms.sh script be capable of rebuilding the object files from sources. See https://android-review.googlesource.com/36822 The goal here is to make it much easier to update these files, and track their changes relative to the content of bionic/lib. For example to fix the following issues in the future: Change-Id: If4c84e2584b0e58ca3585b034bb8a13a8add8ab9 http://code.google.com/p/android/issues/detail?id=26911 http://code.google.com/p/android/issues/detail?id=23203 --- ndk/platforms/README.CRT.TXT | 274 ++++++++++++++++++ .../android-3/arch-arm/lib/crtbegin_dynamic.o | Bin 1324 -> 0 bytes .../android-3/arch-arm/lib/crtbegin_so.o | Bin 1068 -> 0 bytes .../android-3/arch-arm/lib/crtbegin_static.o | Bin 1324 -> 0 bytes .../android-3/arch-arm/lib/crtend_android.o | Bin 892 -> 0 bytes .../android-3/arch-arm/lib/crtend_so.o | Bin 716 -> 0 bytes .../android-3/arch-arm/src/__dso_handle.S | 55 ++++ .../android-3/arch-arm/src/__dso_handle_so.S | 38 +++ ndk/platforms/android-3/arch-arm/src/atexit.S | 83 ++++++ .../android-3/arch-arm/src/crtbegin_dynamic.S | 84 ++++++ .../android-3/arch-arm/src/crtbegin_so.S | 61 ++++ .../android-3/arch-arm/src/crtbegin_static.S | 86 ++++++ ndk/platforms/android-3/arch-arm/src/crtend.S | 40 +++ .../android-3/arch-arm/src/crtend_so.S | 38 +++ .../arch-mips/lib/crtbegin_dynamic.o | Bin 2304 -> 0 bytes .../android-9/arch-mips/lib/crtbegin_so.o | Bin 1888 -> 0 bytes .../android-9/arch-mips/lib/crtbegin_static.o | Bin 2760 -> 0 bytes .../android-9/arch-mips/lib/crtend_android.o | Bin 1133 -> 0 bytes .../android-9/arch-mips/lib/crtend_so.o | Bin 1061 -> 0 bytes .../android-9/arch-mips/src/crtbegin_static.S | 2 +- .../android-9/arch-x86/lib/crtbegin_dynamic.o | Bin 2100 -> 0 bytes .../android-9/arch-x86/lib/crtbegin_so.o | Bin 2032 -> 0 bytes .../android-9/arch-x86/lib/crtbegin_static.o | Bin 2100 -> 0 bytes .../android-9/arch-x86/lib/crtend_android.o | Bin 763 -> 0 bytes .../android-9/arch-x86/lib/crtend_so.o | Bin 687 -> 0 bytes .../android-9/arch-x86/src/__dso_handle.S | 42 +++ .../android-9/arch-x86/src/__dso_handle_so.S | 38 +++ .../arch-x86/src/__stack_chk_fail_local.S | 48 +++ ndk/platforms/android-9/arch-x86/src/atexit.S | 66 +++++ .../android-9/arch-x86/src/crtbegin_dynamic.S | 139 +++++++++ .../android-9/arch-x86/src/crtbegin_so.S | 111 +++++++ .../android-9/arch-x86/src/crtbegin_static.S | 139 +++++++++ ndk/platforms/android-9/arch-x86/src/crtend.S | 15 + .../android-9/arch-x86/src/crtend_so.S | 12 + 34 files changed, 1370 insertions(+), 1 deletion(-) create mode 100644 ndk/platforms/README.CRT.TXT delete mode 100644 ndk/platforms/android-3/arch-arm/lib/crtbegin_dynamic.o delete mode 100644 ndk/platforms/android-3/arch-arm/lib/crtbegin_so.o delete mode 100644 ndk/platforms/android-3/arch-arm/lib/crtbegin_static.o delete mode 100644 ndk/platforms/android-3/arch-arm/lib/crtend_android.o delete mode 100644 ndk/platforms/android-3/arch-arm/lib/crtend_so.o create mode 100644 ndk/platforms/android-3/arch-arm/src/__dso_handle.S create mode 100644 ndk/platforms/android-3/arch-arm/src/__dso_handle_so.S create mode 100644 ndk/platforms/android-3/arch-arm/src/atexit.S create mode 100644 ndk/platforms/android-3/arch-arm/src/crtbegin_dynamic.S create mode 100644 ndk/platforms/android-3/arch-arm/src/crtbegin_so.S create mode 100644 ndk/platforms/android-3/arch-arm/src/crtbegin_static.S create mode 100644 ndk/platforms/android-3/arch-arm/src/crtend.S create mode 100644 ndk/platforms/android-3/arch-arm/src/crtend_so.S delete mode 100644 ndk/platforms/android-9/arch-mips/lib/crtbegin_dynamic.o delete mode 100644 ndk/platforms/android-9/arch-mips/lib/crtbegin_so.o delete mode 100644 ndk/platforms/android-9/arch-mips/lib/crtbegin_static.o delete mode 100644 ndk/platforms/android-9/arch-mips/lib/crtend_android.o delete mode 100644 ndk/platforms/android-9/arch-mips/lib/crtend_so.o delete mode 100644 ndk/platforms/android-9/arch-x86/lib/crtbegin_dynamic.o delete mode 100644 ndk/platforms/android-9/arch-x86/lib/crtbegin_so.o delete mode 100644 ndk/platforms/android-9/arch-x86/lib/crtbegin_static.o delete mode 100644 ndk/platforms/android-9/arch-x86/lib/crtend_android.o delete mode 100644 ndk/platforms/android-9/arch-x86/lib/crtend_so.o create mode 100644 ndk/platforms/android-9/arch-x86/src/__dso_handle.S create mode 100644 ndk/platforms/android-9/arch-x86/src/__dso_handle_so.S create mode 100644 ndk/platforms/android-9/arch-x86/src/__stack_chk_fail_local.S create mode 100644 ndk/platforms/android-9/arch-x86/src/atexit.S create mode 100644 ndk/platforms/android-9/arch-x86/src/crtbegin_dynamic.S create mode 100644 ndk/platforms/android-9/arch-x86/src/crtbegin_so.S create mode 100644 ndk/platforms/android-9/arch-x86/src/crtbegin_static.S create mode 100644 ndk/platforms/android-9/arch-x86/src/crtend.S create mode 100644 ndk/platforms/android-9/arch-x86/src/crtend_so.S diff --git a/ndk/platforms/README.CRT.TXT b/ndk/platforms/README.CRT.TXT new file mode 100644 index 000000000..82d0a1a6f --- /dev/null +++ b/ndk/platforms/README.CRT.TXT @@ -0,0 +1,274 @@ +This directory contains the sources of the C runtime object files +required by the Android NDK toolchains. This document explains +what they are, as well as a few important details about them. + +The files are located under the following directories: + + android-3/arch-arm/src/ + android-9/arch-x86/src/ + android-9/arch-mips/src/ + +They are all *assembly* files with an .S extension, which means that +they'll be sent to the C-preprocessor before being assembled into +object files. They have the following names and usage: + + crtbegin_static.S + This file contains a tiny ELF startup entry point (named '_start') + that is linked into every Android _static_ executable. These binaries can + run on any Linux ARM system, but cannot perform dynamic linking at all. + + Note that the kernel calls the '_start' entry point directly when it + launches such an executable. The _start stub is used to call the + C library's runtime initialization, passing it the address of the + 'main' function. + + crtbegin_dynamic.S + This is equivalent to crtbegin_static.S, for for _dynamic_ executables. + These executables always link to the system C library dynamically. + + When the kernel launches such an executable, it actually starts the + dynamic linker (/system/bin/linker), which loads and relocates the + executable (possibly loading any dependent system libraries as well), + then call the _start stub. + + crtbegin_so.S + This is equivalent to crtbegin_dynamic.S, but shall be used for + shared libraries. One major difference is that there is no _start + entry point. + + crtend_android.S + This source file shall be used when generating an executable, i.e. used + in association with either crtbegin_static.S or crtbegin_dynamic.S + + crtend.S + This source file is _strictly_ equivalent to crtend_android.S. + Actually, it *must* be compiled into an object named 'crtend_android.o' + because that's the hard-coded name that the toolchain binaries expect. + + (the naming difference for this source file is purely historical, it + could probably be removed in the future). + + crtend_so.S + This source's object file shall be used when generating a shared library, + i.e. used in association with crtbegin_so.S only. + +Content of these files: + +ELF section (lists); + + crtbegin_static.S + crtbegin_dynamic.S contain a '_start' entry point for + the corresponding executable. crtbegin_so.S doesn't need any. + + all crtbegin_XXX.s files contain the head of various ELF sections, which are + used to list of ELF constructors and destructors. The sections are: + + .init_array: + Contains a list of function addresses that are run at load time. + This means they are run *before* 'main', in the case of executables, + or during 'dlopen()' for shared libraries (either implicit or explicit). + + The functions are called in list order (from first to last). + + .fini_array: + Contains a list of destructor addresses that are run at unload time. + This means they are run *after* 'exit', in the case of executables, + or during 'dlclose()' for shared libraries (either implicit or explicit). + + The functions are called in _reverse_ list order (from last to first). + + .preinit_array: + This section can *only* appear in executables. It contains a list of + constructors that are run _before_ the ones in .init_array, or those + of any dependent shared library (if any). + + .ctors + This section shall *not* be used on Android. Used on some GLibc-based + Linux systems to hold list of constructors. The toolchains should + place all constructors in .init_array instead. + + .dtors + This section shall *not* be used on Android. Used on some GLibc-based + Linux systems to hold a list of destructors. The toolchains should + place all destructors in .fini_array instead. + + +__dso_handle symbol: + + To properly support the C++ ABI, a unique *local* *hidden* symbol named + '__dso_handle' must be defined in each shared library. + + This is used to implement static C++ object initialization in a shared + library, as in: + + static Foo foo(10); + + The statement above creates a hidden function, which address will be added + to the .init_array section described above. Its compiler-generated code + will perform the object construction, and also register static destructor + using a call that looks like: + + __cxa_atexit( Foo::~Foo, &foo, &__dso_handle ); + + Where '__cxa_atexit' is a special C++ support function provided by the + C library. Doing this ensures that the destructor for 'foo' will be + automatically called when the shared library containing this code is + unloaded (i.e. either through 'dlclose' or at program exit). + + The value of __dso_handle is normally never taken directly. + + See http://sourcery.mentor.com/public/cxx-abi/abi.html#dso-dtor + + WARNING: There is a big caveat regarding this symbol. Read the section + named 'IMPORTANT BACKWARDS COMPATIBILITY ISSUES' below. + + +atexit() implementation: + + The Posix standard doesn't mandate the program behaviour's when a shared + library which registered a function with 'atexit' is unloaded explicitely + (e.g. with 'dlclose()'). + + On most BSD systems (including OS X), unloading the library succeeds, but + the program will crash when it calls exit() or returns from main(). + + On Linux, GLibc provides an implementation that automatically unregisters + such atexit() handlers when the corresponding shared library is unloaded. + + However, this requires that the atexit() implementation be part of the + shared library itself, rather than the C library. + + The crtbegin_shared.S and crtbegin_static.S files contain an tiny + implementation of atexit() in assembler that essentially does: + + void atexit(void(*myfunc)(void)) + { + __cxa_atexit(myfunc, NULL, &__dso_handle); + } + + Because it references the shared library's hidden __dso_handle symbol, + this code cannot be in the C library itself. + + Note that crtbegin_static.S should *not* provide an atexit() function + (the latter should be provided by libc.a instead). + + See 'BACKWARDS COMPATIBILITY ISSUES' section below. + + + +BACKWARDS COMPATIBILITY ISSUES: +------------------------------- + +To maintain binary compatibility to all existing NDK-generated machine code, +the system's C library (i.e. /system/lib/libc.so) needs to exports symbols +that shall *not* be exported by the NDK-provided link-time libraries (i.e. +$NDK/platforms/android-$LEVEL/arch-$ARCH/usr/lib/libc.so). + +Starting from NDK r7, the NDK libc.so is itself generated by a script +(gen-platforms.sh) from a list of symbol files (see libc.so.functions.txt +and libc.so.variables.txt) and does not contain any implementation code. + +The NDK libc.a, on the other hand, is a copy of a given version of the system +C static library, and shall only be used to generate static executables (it +is also required to build gdbserver). + +1. libgcc compatibility symbols: + + None of the link-time NDK shared libraries should export any libgcc symbol. + + However, on ARM, the system C library needs to export some of them to + maintain binary compatibility with 'legacy' NDK machine code. Details are + under bionic/libc/arch-arm/bionic/libgcc_compat.c. + + Note that gen-platforms.sh takes care of this by explicitely removing any + libgcc symbol from the link-time shared libraries it generates. This is done + by using the lists under: + + $NDK/build/tools/toolchain-symbols/$ARCH/libgcc.a.functions.txt + + You will need to update these files when the toolchain changes. + + Note that all libgcc releases should be backwards-compatible, i.e. newer + releases always contain all the symbols from previous ones). + + +2. __dso_handle compatibility symbol: + + Earlier versions of the C library exported a __dso_handle symbol + *incorrectly*. As such: + + - the system's libc.so shall always export its __dso_handle, as *global* + and *public* (in ELF visibility terms). A weak symbol definition is ok + but not necessary. This is only to ensure binary compatibility with + 'legacy' NDK machine code. + + - the NDK link-time libc.so shall *never* export or contain any + __dso_handle symbol. + + - The NDK's crtbegin_dynamic.S and crtbegin_so.S shall provide a *local* + and *hidden* __dso_handle symbol. + + - The NDK's libc.a will containg a *global* and *public* __dso_handle, since + it is a copy of a release-specific system libc.so. + + - crtbegin_static.S shall not provide any __dso_handle symbol, since static + executables will use the one in libc.a instead. + +Note that existing NDK machine code that links against the system libc's +__dso_handle will not have their C++ destructors run correctly when the +library is unloaded. However, this bug can be solved by simply recompiling +/relinking against a newer NDK release, without touching the original +sources. + + + +3. atexit compatibility symbol: + + Earlier versions of the C library implemented and exported an atexit() + function. While this is compliant with Posix, this doesn't allow a useful + GLibc extension which automatically un-registers atexit() handlers when + a shared library is unloaded with dlclose(). + + To support this, while providing binary compatibility, the following + must apply: + + - The platform's /system/lib/libc.so should *always* export a working + atexit() implementation (used by 'legacy' NDK machine code). + + - The NDK link-time libc.so should *never* export atexit() + + - crtbegin_shared.S, crtbegin_so.S shall define a *local* *hidden* + symbol for atexit(), with a tiny implementation that amounts to the + following code: + + void atexit( void(*handler)(void) ) + { + __cxa_atexit( handler, NULL, &__dso_handle ); + } + + - The NDK libc.a shall provide an atexit() implementation, and + crtbegin_static.S shall *not* provide one to avoid conflicts. + +Note that existing NDK machine code that links against the system libc's +atexit symbol will not have their atexit-handler automatically unregistered +when the library is unloaded. However, this bug can be solved by simply +recompiling/relinking against a newer NDK release, without touching the +original sources. + +4. __atomic_xxx sompatibility symbols: + +This issues is detailed in ndk/docs/ANDROID-ATOMICS.html and +bionic/libc/arch-arm/bionic/atomics_arm.c. In a nutshell: + + - The system C library *shall* always export on *ARM* the __atomic_cmpxchg, + __atomic_inc and __atomic_dec functions to support legacy NDK machine code. + Their implementation should have full (i.e. acquire+release) memory ordering + semantics. + + - The system C library for other CPU architectures (e.g. x86 or mips) *shall* + *not* export any of these symbols. + + - The NDK libc.so *shall* *not* export these symbols at all. + + - The NDK header shall provide inlined-static versions of + these functions that use the built-in GCC atomic functions instead. + diff --git a/ndk/platforms/android-3/arch-arm/lib/crtbegin_dynamic.o b/ndk/platforms/android-3/arch-arm/lib/crtbegin_dynamic.o deleted file mode 100644 index f34cba84e5dc05f91c0da89d32c4d42ddcf997e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1324 zcmZ`&+e+L}6x}fyXL_-X_JX}p9~1;3jG)hTkP!xLE$KkTKrZ`2{ zH{@Rba^@~>o#w^u-{J5#kCG`B@WDH*L~9mB9qJ$=>j`LWwcDmi2h)1V*`d(^(8L)Y z2#dqMXTnoMUQZiMUXUc@9miobh>X&4tk1|R@_h)&@0p_*?w0@2)5gS6aALyb|J9Dm zyhnkLWHL9b0h>8zaC80!_#o#Df1J$s2%O)Cqz1-9u5BR4aRztK?D&b6kYRt(Cv&k` zcr)ikAI~Kr{XQVU=Pf=1exGj>`KJZn=@{Qv`!UA%E%V%M^BnpWhJ>td8VTve zwJVGPlRU)7I3Y=(iQ!CtZsU}S9cHi_z9SNRj;}=k zS@ZuO;bQ&EB7iQ|zgE(9+Aiq^?UppwGp}jBM=CKoHl$QP3icHL%XFxt0TQ46cIQ*4 zt6IL_+EEIbirj!MRM)%PzS`=1>89RZa-S5S}z?ss9yvP((afp&$egdK0vuf}kR$7eQFICelD`C0W6G@e%Z4d;}lC zClI{&5Y}&!Oqv!C4s5>pX1~nr%qGvrXD60rk(fnI8Z)AgbfdhRV3X!)h8%kNBzpb& z8I8W>J;70C%v&pXXkT{&vKHZ%_d3T^ajF)%@$k;*F3?0N_QZ?)&^7*}A=lGJliQ7B za)W+gl#U`jB$oxZ2ncVr&s}Xy6m%bqA9LOR+6IK&YbASud#q(XgUn$K{!AfWcT(MK zrU9iY)>g)CAlp$2`BU<3Bf@&oUBWNc6@LeDo?B7JwZtUfAp%QSqU*rt{9>ZpN1)h8 z1Ibv&eeevVk2Cnlbq`4F8qd|tXOMi$@TDflAFx;}COXEF1c7fLH3aA2FJN(9?wQY4 z%=Zp*ftZ-&6aE+4`RUSKdmTKrZ`2{ zH{@Rba^@~>o#w^u-{J5#kCG`B@WDH*L~9mB9qJ$=>j`LWwcDmi2h)1V*`d(^(8L)Y z2#dqMXTnoMUQZiMUXUc@9miobh>X&4tk1|R@_h)&@0p_*?w0@2)5gS6aALyb|J9Dm zyhnkLWHL9b0h>8zaC80!_#o#Df1J$s2%O)Cqz1-9u5BR4aRztK?D&b6kYRt(Cv&k` zcr)ikAI~Kr{XQVU=Pf=1exGj>`KJZn=@{Qv`!UA%E%V%M^BnpWhJ>td8VTve zwJVGPlRU)7I3Y=(iQ!CtZsU}S9cHi_z9SNRj;}=k zS@ZuO;bQ&EB7iQ|zgE(9+Aiq^?UppwGp}jBM=CKoHl$QP3icHL%XFxt0TQ46cIQ*4 zt6IL_+EEIbirj!MRM)%PzS`=1>89RZa-MY`y43J?TL`;r=L|R~P2h=1cPD!;uqm#Qn zHA2$a(9A!0F^dxpd&T>71YFVbBi zzg5zm*XVAM=ibtOE0P3$Blrcb!#Ci( z6aNo>P33-L1dH~Ctk#0!c3u+9P3HdP2^@!&6Xl6qk1F+OZgzmzBYXOSye667tkj#8 K^LQ}_L;3^J{4&)5 diff --git a/ndk/platforms/android-3/arch-arm/lib/crtend_so.o b/ndk/platforms/android-3/arch-arm/lib/crtend_so.o deleted file mode 100644 index c54db97fd39d76f814f80041a4f2ac9153902153..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 716 zcmaix&rZTX5XNV13rdK8E_m={Vj>5!CrvnTArVh{QSN3NYU}|*+A)!nui#_&C_I+m zuscv1OefiX-|YN4GflrIPmjhJ(lFGgT}Jfl3(4I^`_!SfqBQQoy3D0HnJ#Q{Kb=r3 zCR?uN>{2KfUO&`v_Qhmpjvd*wEXn4JoZnngxE0xVB~J1@wci@tq5XjV8_{+Z7^)rnG1 OYV~Aqb|ioMW=4OeTqv*r diff --git a/ndk/platforms/android-3/arch-arm/src/__dso_handle.S b/ndk/platforms/android-3/arch-arm/src/__dso_handle.S new file mode 100644 index 000000000..2d783894d --- /dev/null +++ b/ndk/platforms/android-3/arch-arm/src/__dso_handle.S @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2010 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 +# + .data + .align 4 + +/* 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 + .hidden __dso_handle +#endif + + .globl __dso_handle +__dso_handle: + .long __dso_handle diff --git a/ndk/platforms/android-3/arch-arm/src/__dso_handle_so.S b/ndk/platforms/android-3/arch-arm/src/__dso_handle_so.S new file mode 100644 index 000000000..77a5d7fba --- /dev/null +++ b/ndk/platforms/android-3/arch-arm/src/__dso_handle_so.S @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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 +# + .data + .align 4 + .hidden __dso_handle + .globl __dso_handle +__dso_handle: + .long __dso_handle diff --git a/ndk/platforms/android-3/arch-arm/src/atexit.S b/ndk/platforms/android-3/arch-arm/src/atexit.S new file mode 100644 index 000000000..b6401edab --- /dev/null +++ b/ndk/platforms/android-3/arch-arm/src/atexit.S @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2011 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. + */ + +/* 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. + */ +#ifndef CRT_LEGACY_WORKAROUND + .arch armv5te + .fpu softvfp + .eabi_attribute 20, 1 + .eabi_attribute 21, 1 + .eabi_attribute 23, 3 + .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 diff --git a/ndk/platforms/android-3/arch-arm/src/crtbegin_dynamic.S b/ndk/platforms/android-3/arch-arm/src/crtbegin_dynamic.S new file mode 100644 index 000000000..6ca08458e --- /dev/null +++ b/ndk/platforms/android-3/arch-arm/src/crtbegin_dynamic.S @@ -0,0 +1,84 @@ +/* + * 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 + bx r4 + +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" diff --git a/ndk/platforms/android-3/arch-arm/src/crtbegin_so.S b/ndk/platforms/android-3/arch-arm/src/crtbegin_so.S new file mode 100644 index 000000000..9275b1e01 --- /dev/null +++ b/ndk/platforms/android-3/arch-arm/src/crtbegin_so.S @@ -0,0 +1,61 @@ +/* + * 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. + */ + +# Implement static C++ destructors when the shared +# 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: + .long __dso_handle + + .section .init_array, "aw" + .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" diff --git a/ndk/platforms/android-3/arch-arm/src/crtbegin_static.S b/ndk/platforms/android-3/arch-arm/src/crtbegin_static.S new file mode 100644 index 000000000..ec13351eb --- /dev/null +++ b/ndk/platforms/android-3/arch-arm/src/crtbegin_static.S @@ -0,0 +1,86 @@ +/* + * 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 + bx r4 + +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 */ + diff --git a/ndk/platforms/android-3/arch-arm/src/crtend.S b/ndk/platforms/android-3/arch-arm/src/crtend.S new file mode 100644 index 000000000..2f3b1ede3 --- /dev/null +++ b/ndk/platforms/android-3/arch-arm/src/crtend.S @@ -0,0 +1,40 @@ +/* + * 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. + */ + + .section .preinit_array, "aw" + .long 0 + + .section .init_array, "aw" + .long 0 + + .section .fini_array, "aw" + .long 0 + + .section .ctors, "aw" + .long 0 + diff --git a/ndk/platforms/android-3/arch-arm/src/crtend_so.S b/ndk/platforms/android-3/arch-arm/src/crtend_so.S new file mode 100644 index 000000000..a1281c402 --- /dev/null +++ b/ndk/platforms/android-3/arch-arm/src/crtend_so.S @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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. + */ + +/* This is the same than crtend.S except that a shared library + * cannot have a .preinit_array + */ + + .section .init_array, "aw" + .long 0 + + .section .fini_array, "aw" + .long 0 + diff --git a/ndk/platforms/android-9/arch-mips/lib/crtbegin_dynamic.o b/ndk/platforms/android-9/arch-mips/lib/crtbegin_dynamic.o deleted file mode 100644 index 3202d1a1c416dfed4a9bdad26bc74db96829abfe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2304 zcmai0&ubKC7=Cw0ldRilHnvsUlujTLE3&qwEeaMknoSdkHf+;_2l<@cnItQl-R$yW^vs`_`zvW{n=9 z_gY)zdi#X@GuGL7J}z>nJs`Ff=5P0_8h0$_kI1hNhveBqkyYrNzBMR?cf+dHcE1#& zMi`sCN$t$5P#ZPyt+rEQjftFDgHGF)=i>v?+2-1t*QAE_y;GmBMILY0`TzN5!-T7^ zH#Rmj*M{*C=Ev%I3!*F@)KVh(*5&2EDFXvP#3i+Sua*zIl|b^eTqkfOUv9NX7pwJ! zM(A(4zT}&}SFKkA1$mc6&M{zi!R%QMy&MGC-9 zWE1p+eF!^~^bd&q4xYngJr5pS@=3&Xb8Q4w1EJVH3_Gd!62+{i9&1(aIBfb=?^Ed6 z;5t;B&jjwFiASV6n0GL;3DhH>z(gn>(;ydP7Uq$DjhXDPgCdwn02>nVb)W2T-IXnQ z&vwYW66NVSuTwlRv_IWP4KeR$B|t4BsushOyK(;D9EQzxr5=&@s%r;R#;^(h(ujuY zDc=sQ_^M&l>QSUVE}j@x&k8fXClMvjb`|*!Si(%dp+C4KpC@2*SlHfs zKPmKc638{+*&|O5D}HK2uZ5FYj1o=&hf#4hQIG?l@8KdB5}fN?-oon%p2K=v?csX_ zFZX!lupakf#=y~1OIz|6_&TPIIh;<(-#{JgPmFOJX0g^NJ2lgN z?-}RE6?lu&W~wxCwrEZlznM8_j8q!S&6*c@ZvL~+zd9+6@+Gel(EbwHt-$dEQCMsm zx7upTvQw=iSgV#RhOb@NbEV?UxtV!0Q7TQGhpI7K=oEM&dS?FHl9`?PZoZp4*~2O; zj=|g8sa1dSAmp|hX343$HBTIT8oHNbN<_lvc{d(}cW~Q%z!6|(f4DXo9FQ^kfyaPZ ze2uy1>GwqN@t5@bA_XE2*d!4LXqtEk|096ZodZ(W1!nMY@eKC?1M&}~yVn`K_-}w` w!EZ--Ye43$1F7>HIq(l)79Y_+fvmd;Jd8SyG(R9jY@$s>-vuIWYFEVn1D%=haR2}S diff --git a/ndk/platforms/android-9/arch-mips/lib/crtbegin_so.o b/ndk/platforms/android-9/arch-mips/lib/crtbegin_so.o deleted file mode 100644 index ddfd100726af7db20f02c4302b93ccaaabde016d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1888 zcmaJ?OKTHR6h6t=NBVAk6|9(orPW15QL#`VeWW%}tHdC>x=b?DHj*|m8KEsgOA&D) zq&qFRaN*8H!IcY(TbKO_`59dZ@%u7!)0<#>;N*PYdEGPj-pp(#7Ux5ukZ1`>r<^d6 zKOh|g^7L*!VM2zaU#A9kWJ=`A_-J+Cs@4w2N96axfc!cT*{z7o?Db0gf}gls>5%w< z#v*ecMfNL^O>jVR1vp~(k5Ety;;cUh?S$TdlIue{0@ghM8+Z)Z>=*Cw>zT`1-R~AK`|5sG z;3!m!?#=tik-|Zs3OgKN8ulZfhH^eF#{h9nV3|jG2sP(hzWG5i?~cHm?^_ksPmmwZ;U-!KmGCwy9TKh6JVt)>%YKeHow zTT_|Uw8M;dH9D*!Gu&W)nI%0f^}Q{;Pc9pt5N^cHfOGy3)}MssGxH9Tn_@NoeZJSi z4NDjagP1qn#JeQh#Czm*6YrJnCNA>9;8EaD1|JMt@(rAKAPOA{hvYk~7M_zRk;2Wc5*41 zR@14}^h;zaH4kpk+4Pf?T1-Am*MoB=TPZ3hS1zI^yJ0K50_}Wm%LR4H1+{9gJ9$@Z zyijvqkP;A%-ge&K`*v9Fe+1WK1hyS^f*fBYzCR)tMey;GZtz8N#JTUxB2GQDBBzQ2e?Si$a;Ve;`~f*s3g5T8b z=I!jvtiLKO%tay*(JdlzIbtF)L*#Ty7B6}UQ!*xLo$6sk(lOsLep%$F$;|%GM#j8n zWTxo-rX%ugXIh?R_YWUUitKdaVnT6H(;7Pl^T*|n`zd*NUu3&8Ecui_Y8#qYv-HKJ z;9=&^yd(~MUF3H#u4Brh$++wXa}CxNnZ0{K@?%;%(KFBNos5}BXuH!t2YvCLT)(E1 z@*-lO&MWt#BEd6=9Iw%@0FhuFcToFIN3Y|cb$c%IyB_&}aKTUBdVY9#sK=QwUPFHa zeHR^VVB8N6{)Md9I1df#`5w%dYj4(Es|0jgKCWr21w6E z((wIFyCu11%c;~WuCiJ!Yt#4l^A$LByzDkw(6N1R*3?SNsyTz7;CO`V!m}|Hgz~^< z=& z23_AW3Sdk(ZQp?747$#{i99}+ZaVLCIKuNj2(1gu?z|P)XVJBuJwT6}A*{C-(i;is zt;6QJXuaxy=lHTOj|;AAN2qIm9poYGHCGz}*JF6|>Ny!=-uFQcLBA_vSR#v;or2>< z_^ClXz6U;QSnnbhIjcnw3z=XiH={4h=uxEpsh)vG&k8d>>?!b`SVoT?(;JZ&;NK1U z@i=$NQ8T#rv`3>6Imd+w8tWDB=2Z52t+pvj*$uT?ZIrC4^6pk;t#80vxTfZcGanb! zY~iE%>q<$Z^o3J)bML-)>3u0TYR#(SIyUJC$Zoq<%M}f)O=VZwO{rOxI)c?osjPUl z!(J>F=C98$shMJN<_1)i>Z5buq3D&RPl{?`{<9@7_i7L0C#CH=E&oe^8Sr^gs=Q$- zd^fCW<+cNAw;O8Bs@qkMI46y<@WJwmYdz70&i zgzp0|`m)Gn;yIB#@jU+N5ML3wMtoI-=Y+b8KY5S?>1#waFsf|ZpDa+Nk#5tD%67a@X$aBjSdNs$lsu1G5V$^HNf-&}Ss z6A6gmz}$N?^LBP_ci)>gtsn?UETA$iBBC!8N;P^o%LT_&r5%y}4~FS%nAt9cY3AnG z7nUW{jKbJvmcnkDQs|Pm!KgQ;a1uLwTrwC9vdB7TXB2AQLm>IrZ0xW$oF`r4vFRFVKsCjY-WS#MG-J^i$j*uwBf76{pgFPo}zCj(h?>WP|kI#Yn&Yrla zjCE`maGpW-Wu4SO3w{m03m4t9s(}`|NAN0KbT6s~TIejeK9^Y4w66a{$MLH9#$G4q zGC?e73tI3!aG8zsAMhCyZ*pdg(u+$SEcyiU8Sww{4BUSUuKP7mI6+QK`boSB&C*SA zKfN=@dIyf>)y=yZ+FWXD@|Uzo8BD3?2=b|Qy^{ZzWCE%P&C$>{@q1_E{|*pqGfOwZ b^KB4C(N*WZ9X0P7QG}qOgI4?Uw&_dXtT99< diff --git a/ndk/platforms/android-9/arch-mips/lib/crtend_so.o b/ndk/platforms/android-9/arch-mips/lib/crtend_so.o deleted file mode 100644 index 5c686298cf795dd534e54f121071dc8527aea619..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1061 zcmb_bO-sW-5S_SMt75G;K`)+EkUiQ->;It6r$d)?N$1WM z*caxqXGc0sTtd2==cH}+I2iTDq$jB*Js1s~Nvut#q<_2i zhL`W4;-6`F6sUW$3uK@2y5Uhke0x}^B7gH8!h=003%)@ExaB#+qSwd3@EzT9F$nf? zoFHpR*_VA%11)(BzJV0qeNY1}eQoe?-cC>hEq!<3p)U<;p|9h8GVcUh?u>oHH^Jp> zy#9)OV&X&Yf>C;LX$KFz0oRdy4?H{fTtSBYJ|GUTCL#Sq|AcDp4RF73XV&2ktmSJe zx+z+oYpcHfcl;lQp>S%RK_Z$>A&UF25`VWGJZA(QhAQ7qv8rf^$e6R6tF~!fHjRO3 Mh9YjCUbKAa6Mg+Xvj6}9 diff --git a/ndk/platforms/android-9/arch-mips/src/crtbegin_static.S b/ndk/platforms/android-9/arch-mips/src/crtbegin_static.S index 9f00811ea..16534e88b 100644 --- a/ndk/platforms/android-9/arch-mips/src/crtbegin_static.S +++ b/ndk/platforms/android-9/arch-mips/src/crtbegin_static.S @@ -228,4 +228,4 @@ $L3: .weak __register_frame_info .include "__dso_handle.S" -.include "atexit.S" +/* NOTE: atexit() is not be provided by crtbegin_static.S, but by libc.a */ diff --git a/ndk/platforms/android-9/arch-x86/lib/crtbegin_dynamic.o b/ndk/platforms/android-9/arch-x86/lib/crtbegin_dynamic.o deleted file mode 100644 index 17704f55be54723b7eb6d33d59d4ddf332e3bccc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2100 zcma)7O>Y}j6umQcN<&jHX@CMnM5<{kQH@x*p$iaoVBAK8CUsI&1n70_nZzdJOf)k_ zjzB6XDv}A2x@E@(35g#7s=7cjqN-TJ4+x72D*6*Z;hgb2ckBS-O3&w>`}OYonCENu ze8n&f(PBtW9x#z#Qc_9+PDw!yC;o{vp}TwYIjGf}Pba^$Ru_N&b8m0&9)HNS+}Mdv z$mQ)*!{xAR4+N#>7Z^cr`1J0Hm9BqB*d*mU>Z;>7LOiw7AC z%u~sx-s$~u_(oPR-%?Walb(s#t@~3;qIfvm^PXD!x$9)tCA7?e}l z3kRMY5AX#H#%JTE!L{f(o&|fz#%Uj8b@|tzvlktA8V=UiqT^nLA-fJMbB9TkmwH9_@Nx6m<5$y`sFV8|u@+zBIwH4ei3nwQ;aN?k{`I)+^ycu%?!bs!jVaH#8ILWlxHHY$zu;xOIJV z4ky5QuBK7uzIx+$p+tBmDEs|~Y_HpIu}iwvKJ{_P0=Il~L)nCyaoiE##F(lq5a zpq5E6=*VE#)Zeo0;;<+fX`O;O4X)T$rU9ACL{5Jt*rcVM+I zs7kf`rmbe}^K%!Kl6uhE@V(e`ty1YsNrKw@UOk3BGb1XBoiIj{->lUYpFwFk&2<9>LYl5Yg~H+PXS@&Et; diff --git a/ndk/platforms/android-9/arch-x86/lib/crtbegin_so.o b/ndk/platforms/android-9/arch-x86/lib/crtbegin_so.o deleted file mode 100644 index cf50f1de83a2c170781aa8dd542fd77d1ffbca11..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2032 zcma)7O=uit7=HJsP1nR)V?@P>f?KUf$ICXvgV2rHZ33~a=@we5e$MX9X4lN_gqc~{ z^r9v7P-38WFTDtY7jGWyL5S$Vv(RG^3OVS(TMt5fo|*64eA`6ug?Hcgd4Hbw`j zqP9}c<#J*qCj~h`A`djEqy=Z>lsuj0r*y;BJCCmH{jQSn~WdkLkDR@FAx3OwG(EQx;=Tr^xKOcD#RCTjIM~wr9(`;>4T1#BIVR zQD!^Fi~PVz{9z&vJ1bgs5^Wd8WHe$Hv z5#U}0v#oP0RS^8J~RPseacLJLplr{uPUd5&M(IA4@+Z4Cbh3%>^c_a`vly?fAe z(CK_$9>W?T|1oUrAuR8o`C02?n3wcpqP#(`w<$__p;`;VrW+_P38PrKgCU}|B~@Ro zeo#{jwF}D^m6BH2+X(!`_nb=QTt&j>XMQVzKld)GmoF|iRCRT=dL5NY)qyQ|)aOcF zSh=)NT~U|n^((c8YE&0iYHao5P<7nC7x)0Jp{wvAbc60qLeG!Y}j6umQcN<&jHX@CMnM5<{kQH@x*p$iaoVBAK8CUsI&1n70_nZzdJOf)k_ zjzB6XDv}A2x@E@(35g#7s=7cjqN-TJ4+x72D*6*Z;hgb2ckBS-O3&w>`}OYonCENu ze8n&f(PBtW9x#z#Qc_9+PDw!yC;o{vp}TwYIjGf}Pba^$Ru_N&b8m0&9)HNS+}Mdv z$mQ)*!{xAR4+N#>7Z^cr`1J0Hm9BqB*d*mU>Z;>7LOiw7AC z%u~sx-s$~u_(oPR-%?Walb(s#t@~3;qIfvm^PXD!x$9)tCA7?e}l z3kRMY5AX#H#%JTE!L{f(o&|fz#%Uj8b@|tzvlktA8V=UiqT^nLA-fJMbB9TkmwH9_@Nx6m<5$y`sFV8|u@+zBIwH4ei3nwQ;aN?k{`I)+^ycu%?!bs!jVaH#8ILWlxHHY$zu;xOIJV z4ky5QuBK7uzIx+$p+tBmDEs|~Y_HpIu}iwvKJ{_P0=Il~L)nCyaoiE##F(lq5a zpq5E6=*VE#)Zeo0;;<+fX`O;O4X)T$rU9ACL{5Jt*rcVM+I zs7kf`rmbe}^K%!Kl6uhE@V(e`ty1YsNrKw@UOk3BGb1XBoiIj{->lUYpFwFk&2<9>LYl5Yg~H+PXS@&Et; diff --git a/ndk/platforms/android-9/arch-x86/lib/crtend_android.o b/ndk/platforms/android-9/arch-x86/lib/crtend_android.o deleted file mode 100644 index 87716a04c831d9c4c657e587f56aaa51ad4c3ce2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 763 zcmah{u}%U(5S{f$Xc8*k@s z&p?=DGH+(yzS-HkpY&y1nL4}3sv*bG4Jdr~vp_BGT%BtK*hOSs67oa5 zTl9I`W4s+zn9W4$eSd|xrqlYC#S|7ENvTNLc1Hi7%Hjr31zvPt>X YrQa;yolh!i5*agke|k+#`ZhF%c05ik0{{R3 diff --git a/ndk/platforms/android-9/arch-x86/lib/crtend_so.o b/ndk/platforms/android-9/arch-x86/lib/crtend_so.o deleted file mode 100644 index 4c4460fbe298ffe6c86a32c63bc80a23594850a7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 687 zcma)4I}XAy40R~~fzQkW6AUO50|Ns{lnEHPK$MDBWq_g0023U6BXCq~8bgWzVJUik z@yoN*^z1JeLI~gx;K7RlTy0_WzyZ{u!qN<7dfFQufJ{x2Va%Bcj|Svc8x1l@Q;@sE z&M2KE`UEmU!g(00DAD^c@BEW>uu5~5tty-Eb);z19wO;H%fIRRSg-z}8=|K1rsH0? z{rq-g%$tsm_$S@mo+%(wOmMk6&fB=pcOcyq*P0R={APsgMWrs13t|ly-H-fQmb-p8 x)X}^g?8p2Q=KmC$&+Say?LeGwleu|N%GrAOn%tL^f?ijt#b&nhmA{@V1$Q=LCEWl3 diff --git a/ndk/platforms/android-9/arch-x86/src/__dso_handle.S b/ndk/platforms/android-9/arch-x86/src/__dso_handle.S new file mode 100644 index 000000000..3e801284f --- /dev/null +++ b/ndk/platforms/android-9/arch-x86/src/__dso_handle.S @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2010 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 +# + .section .bss + .align 4 + +#ifndef CRT_LEGACY_WORKAROUND + .hidden __dso_handle +#endif + + .globl __dso_handle +__dso_handle: + .long 0 diff --git a/ndk/platforms/android-9/arch-x86/src/__dso_handle_so.S b/ndk/platforms/android-9/arch-x86/src/__dso_handle_so.S new file mode 100644 index 000000000..77a5d7fba --- /dev/null +++ b/ndk/platforms/android-9/arch-x86/src/__dso_handle_so.S @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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 +# + .data + .align 4 + .hidden __dso_handle + .globl __dso_handle +__dso_handle: + .long __dso_handle diff --git a/ndk/platforms/android-9/arch-x86/src/__stack_chk_fail_local.S b/ndk/platforms/android-9/arch-x86/src/__stack_chk_fail_local.S new file mode 100644 index 000000000..59fe86ec3 --- /dev/null +++ b/ndk/platforms/android-9/arch-x86/src/__stack_chk_fail_local.S @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011 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. + */ +/* + * Contributed by: Intel Corporation + */ + + .text + .p2align 4,,15 + .globl __stack_chk_fail_local + .hidden __stack_chk_fail_local + .type __stack_chk_fail_local, @function + +__stack_chk_fail_local: +#ifdef __PIC__ + pushl %ebx + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + call __stack_chk_fail@PLT +#else /* PIC */ + jmp __stack_chk_fail +#endif /* not PIC */ + + .size __stack_chk_fail_local, .-__stack_chk_fail_local diff --git a/ndk/platforms/android-9/arch-x86/src/atexit.S b/ndk/platforms/android-9/arch-x86/src/atexit.S new file mode 100644 index 000000000..b28f40bb6 --- /dev/null +++ b/ndk/platforms/android-9/arch-x86/src/atexit.S @@ -0,0 +1,66 @@ +/* + * 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 + .p2align 4,,15 + .globl atexit + .hidden atexit + .type atexit, @function +atexit: + pushl %ebp + movl %esp, %ebp + pushl %ebx + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + subl $20, %esp + movl $0, 4(%esp) + movl __dso_handle@GOTOFF(%ebx), %eax + movl %eax, 8(%esp) + movl 8(%ebp), %eax + movl %eax, (%esp) + call __cxa_atexit@PLT + addl $20, %esp + popl %ebx + popl %ebp + ret + .size atexit, .-atexit + + .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat + .globl __x86.get_pc_thunk.bx + .hidden __x86.get_pc_thunk.bx + .type __x86.get_pc_thunk.bx, @function +__x86.get_pc_thunk.bx: + nop + nop + nop + nop + nop + nop + nop + nop + movl (%esp), %ebx + ret diff --git a/ndk/platforms/android-9/arch-x86/src/crtbegin_dynamic.S b/ndk/platforms/android-9/arch-x86/src/crtbegin_dynamic.S new file mode 100644 index 000000000..177244b70 --- /dev/null +++ b/ndk/platforms/android-9/arch-x86/src/crtbegin_dynamic.S @@ -0,0 +1,139 @@ +# bionic/arch-x86/bionic/crtbegin_dynamic.S +# +# Copyright 2006, The Android Open Source Project +# +# 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. +# * Neither the name of Google Inc. nor the names of its contributors may +# be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY Google Inc. ``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 Google Inc. 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. We +# can't hard-code it in the adr pseudo instruction +# so we use a tiny trampoline that will get relocated +# by the dynamic linker before this code runs +# +# - address of the constructor list +# +_start: + mov %esp, %eax + # before push arguments, align the stack to a 16 byte boundary + andl $~15, %esp + mov $1f, %edx + pushl %edx + mov $0f, %edx + pushl %edx + mov $0, %edx + pushl %edx + pushl %eax + call __libc_init + +0: + jmp main + +1: .long __PREINIT_ARRAY__ + .long __INIT_ARRAY__ + .long __FINI_ARRAY__ + + .section .preinit_array, "aw" + .globl __PREINIT_ARRAY__ +__PREINIT_ARRAY__: + .long -1 + + .section .init_array, "aw" + .globl __INIT_ARRAY__ +__INIT_ARRAY__: + .long -1 + .long frame_dummy + + .section .fini_array, "aw" + .globl __FINI_ARRAY__ +__FINI_ARRAY__: + .long -1 + .long __do_global_dtors_aux + + .section .eh_frame,"a",@progbits + .align 4 + .type __EH_FRAME_BEGIN__, @object +__EH_FRAME_BEGIN__: + .text + .p2align 4,,15 + .type __do_global_dtors_aux, @function +__do_global_dtors_aux: + pushl %ebp + movl %esp, %ebp + subl $24, %esp + cmpb $0, completed.4454 + jne .L4 + movl $__deregister_frame_info_bases, %eax + testl %eax, %eax + je .L3 + movl $__EH_FRAME_BEGIN__, (%esp) + call __deregister_frame_info_bases +.L3: + movb $1, completed.4454 +.L4: + leave + ret + .text + .p2align 4,,15 + .type frame_dummy, @function +frame_dummy: + pushl %ebp + movl $__register_frame_info_bases, %eax + movl %esp, %ebp + subl $24, %esp + testl %eax, %eax + je .L7 + movl %ebx, 12(%esp) + movl $0, 8(%esp) + movl $object.4466, 4(%esp) + movl $__EH_FRAME_BEGIN__, (%esp) + call __register_frame_info_bases +.L7: + leave + ret + .local completed.4454 + .comm completed.4454,1,1 + .local object.4466 + .comm object.4466,24,4 + .weak __register_frame_info_bases + .weak __deregister_frame_info_bases + +#include "__dso_handle.S" +#include "atexit.S" +#include "__stack_chk_fail_local.S" diff --git a/ndk/platforms/android-9/arch-x86/src/crtbegin_so.S b/ndk/platforms/android-9/arch-x86/src/crtbegin_so.S new file mode 100644 index 000000000..99662fe16 --- /dev/null +++ b/ndk/platforms/android-9/arch-x86/src/crtbegin_so.S @@ -0,0 +1,111 @@ +/* + * 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. + */ + +.section .init_array, "aw" +.align 4 +.type __INIT_ARRAY__, @object +.globl __INIT_ARRAY__ +__INIT_ARRAY__: + .long -1 + .long frame_dummy + +.section .fini_array, "aw" +.align 4 +.type __FINI_ARRAY__, @object +.globl __FINI_ARRAY__ +__FINI_ARRAY__: + .long -1 + .long __do_global_dtors_aux + + .section .eh_frame,"a",@progbits + .align 4 + .type __EH_FRAME_BEGIN__, @object +__EH_FRAME_BEGIN__: + .text + .p2align 4,,15 + .type __do_global_dtors_aux, @function +__do_global_dtors_aux: + pushl %ebp + movl %esp, %ebp + pushl %ebx + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + subl $20, %esp + cmpb $0, completed.4454@GOTOFF(%ebx) + jne .L5 + movl __dso_handle@GOTOFF(%ebx), %eax + movl %eax, (%esp) + call __cxa_finalize@PLT + movl __deregister_frame_info_bases@GOT(%ebx), %eax + testl %eax, %eax + je .L4 + leal __EH_FRAME_BEGIN__@GOTOFF(%ebx), %eax + movl %eax, (%esp) + call __deregister_frame_info_bases@PLT +.L4: + movb $1, completed.4454@GOTOFF(%ebx) +.L5: + addl $20, %esp + popl %ebx + popl %ebp + ret + .text + .p2align 4,,15 + .type frame_dummy, @function +frame_dummy: + pushl %ebp + movl %esp, %ebp + pushl %ebx + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + subl $20, %esp + movl __register_frame_info_bases@GOT(%ebx), %eax + testl %eax, %eax + je .L8 + leal object.4469@GOTOFF(%ebx), %eax + movl %eax, 4(%esp) + leal __EH_FRAME_BEGIN__@GOTOFF(%ebx), %eax + movl %ebx, 12(%esp) + movl $0, 8(%esp) + movl %eax, (%esp) + call __register_frame_info_bases@PLT +.L8: + addl $20, %esp + popl %ebx + popl %ebp + ret + .local completed.4454 + .comm completed.4454,1,1 + .local object.4469 + .comm object.4469,24,4 + .weak __register_frame_info_bases + .weak __deregister_frame_info_bases + +#include "__dso_handle_so.S" +#include "atexit.S" +#include "__stack_chk_fail_local.S" diff --git a/ndk/platforms/android-9/arch-x86/src/crtbegin_static.S b/ndk/platforms/android-9/arch-x86/src/crtbegin_static.S new file mode 100644 index 000000000..4f95b1e40 --- /dev/null +++ b/ndk/platforms/android-9/arch-x86/src/crtbegin_static.S @@ -0,0 +1,139 @@ +# bionic/arch-x86/bionic/crtbegin_static.S +# +# Copyright 2006, The Android Open Source Project +# +# 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. +# * Neither the name of Google Inc. nor the names of its contributors may +# be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY Google Inc. ``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 Google Inc. 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. We +# can't hard-code it in the adr pseudo instruction +# so we use a tiny trampoline that will get relocated +# by the dynamic linker before this code runs +# +# - address of the constructor list +# +_start: + mov %esp, %eax + # before push arguments, align the stack to a 16 byte boundary + andl $~15, %esp + mov $1f, %edx + pushl %edx + mov $0f, %edx + pushl %edx + mov $0, %edx + pushl %edx + pushl %eax + call __libc_init + +0: jmp main + +1: .long __PREINIT_ARRAY__ + .long __INIT_ARRAY__ + .long __FINI_ARRAY__ + + .section .preinit_array, "aw" + .globl __PREINIT_ARRAY__ +__PREINIT_ARRAY__: + .long -1 + + .section .init_array, "aw" + .globl __INIT_ARRAY__ +__INIT_ARRAY__: + .long -1 + .long frame_dummy + + .section .fini_array, "aw" + .globl __FINI_ARRAY__ +__FINI_ARRAY__: + .long -1 + .long __do_global_dtors_aux + + .section .eh_frame,"a",@progbits + .align 4 + .type __EH_FRAME_BEGIN__, @object +__EH_FRAME_BEGIN__: + .text + .p2align 4,,15 + .type __do_global_dtors_aux, @function +__do_global_dtors_aux: + pushl %ebp + movl %esp, %ebp + subl $24, %esp + cmpb $0, completed.4454 + jne .L4 + movl $__deregister_frame_info_bases, %eax + testl %eax, %eax + je .L3 + movl $__EH_FRAME_BEGIN__, (%esp) + call __deregister_frame_info_bases +.L3: + movb $1, completed.4454 +.L4: + leave + ret + .text + .p2align 4,,15 + .type frame_dummy, @function +frame_dummy: + pushl %ebp + movl $__register_frame_info_bases, %eax + movl %esp, %ebp + subl $24, %esp + testl %eax, %eax + je .L7 + movl %ebx, 12(%esp) + movl $0, 8(%esp) + movl $object.4466, 4(%esp) + movl $__EH_FRAME_BEGIN__, (%esp) + call __register_frame_info_bases +.L7: + leave + ret + .local completed.4454 + .comm completed.4454,1,1 + .local object.4466 + .comm object.4466,24,4 + .weak __register_frame_info_bases + .weak __deregister_frame_info_bases + +#include "__dso_handle.S" +#include "__stack_chk_fail_local.S" +/* NOTE: atexit() is not be provided by crtbegin_static.S, but by libc.a */ + diff --git a/ndk/platforms/android-9/arch-x86/src/crtend.S b/ndk/platforms/android-9/arch-x86/src/crtend.S new file mode 100644 index 000000000..68447e7db --- /dev/null +++ b/ndk/platforms/android-9/arch-x86/src/crtend.S @@ -0,0 +1,15 @@ + .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/ndk/platforms/android-9/arch-x86/src/crtend_so.S b/ndk/platforms/android-9/arch-x86/src/crtend_so.S new file mode 100644 index 000000000..63e58b970 --- /dev/null +++ b/ndk/platforms/android-9/arch-x86/src/crtend_so.S @@ -0,0 +1,12 @@ +.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