2
* Copyright (C) 2008 The Android Open Source Project
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
8
* * Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* * Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in
12
* the documentation and/or other materials provided with the
15
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29
/* This file contains dummy references to libgcc.a functions to force the
30
* dynamic linker to copy their definition into the final libc.so binary.
32
* They are required to ensure backwards binary compatibility with
33
* Android 1.5, 1.6 and even 3.0 system images. Some applications built
34
* using the NDK require them to be here.
36
* Now, for a more elaborate description of the issue:
38
* libgcc.a is a compiler-specific library containing various helper
39
* functions used to implement certain operations that are not necessarily
40
* supported by the target CPU. For example, integer division doesn't have a
41
* corresponding CPU instruction on ARMv5, and is instead implemented in the
42
* compiler-generated machine code as a call to an __idiv helper function.
44
* Normally, one has to place libgcc.a in the link command used to generate
45
* target binaries (shared libraries and executables) after all objects and
46
* static libraries, but before dependent shared libraries, i.e. something
48
* gcc <options> -o libfoo.so foo.a libgcc.a -lc -lm
50
* This ensures that any helper function needed by the code in foo.a is copied
51
* into the final libfoo.so. Unfortunately, the Android build system has been
54
* gcc <options> -o libfoo.so foo.a -lc -lm libgcc.a
56
* The problem with this is that if one helper function needed by foo.a has
57
* already been copied into libc.so or libm.so, then nothing will be copied
58
* into libfoo.so. Instead, a symbol import definition will be added to it
59
* so libfoo.so can directly call the one in libc.so at runtime.
61
* When changing toolchains for 2.0, the set of helper functions copied to
62
* libc.so changed, which resulted in some native shared libraries generated
63
* with the NDK to fail to load properly.
65
* The NDK has been fixed after 1.6_r1 to use the correct link command, so
66
* any native shared library generated with it should now be safe from that
67
* problem. On the other hand, existing shared libraries distributed with
68
* applications that were generated with a previous version of the NDK
69
* still need all 1.5/1.6 helper functions in libc.so and libm.so
71
* After 3.2, the toolchain was updated again, adding __aeabi_f2uiz to the
72
* list of requirements. Technically, this is due to mis-linked NDK libraries
73
* but it is easier to add a single function here than asking several app
74
* developers to fix their build.
76
* Final note: some of the functions below should really be in libm.so to
77
* completely reflect the state of 1.5/1.6 system images. However,
78
* since libm.so depends on libc.so, it's easier to put all of
79
* these in libc.so instead, since the dynamic linker will always
80
* search in libc.so before libm.so for dependencies.
83
#define COMPAT_FUNCTIONS_LIST \
88
XX(__aeabi_cdrcmple) \
151
#define XX(f) extern void f(void);
152
COMPAT_FUNCTIONS_LIST
155
void __bionic_libgcc_compat_hooks(void)
158
COMPAT_FUNCTIONS_LIST