~xnox/ubuntu/trusty/gcc-arm-linux-androideabi/dima

« back to all changes in this revision

Viewing changes to android/bionic/libc/arch-arm/bionic/libgcc_compat.c

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-07-05 10:12:24 UTC
  • Revision ID: package-import@ubuntu.com-20130705101224-6qo3e8jbz8p31aa1
Tags: upstream-0.20130705.1
ImportĀ upstreamĀ versionĀ 0.20130705.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2008 The Android Open Source Project
 
3
 * All rights reserved.
 
4
 *
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions
 
7
 * are met:
 
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
 
13
 *    distribution.
 
14
 *
 
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
 
26
 * SUCH DAMAGE.
 
27
 */
 
28
 
 
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.
 
31
 *
 
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.
 
35
 *
 
36
 * Now, for a more elaborate description of the issue:
 
37
 *
 
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.
 
43
 *
 
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
 
47
 * like:
 
48
 *         gcc <options> -o libfoo.so  foo.a libgcc.a -lc -lm
 
49
 *
 
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
 
52
 * using this instead:
 
53
 *
 
54
 *         gcc <options> -o libfoo.so foo.a -lc -lm libgcc.a
 
55
 *
 
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.
 
60
 *
 
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.
 
64
 *
 
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
 
70
 *
 
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.
 
75
 *
 
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.
 
81
 */
 
82
 
 
83
#define   COMPAT_FUNCTIONS_LIST \
 
84
    XX(__adddf3)             \
 
85
    XX(__addsf3)             \
 
86
    XX(__aeabi_cdcmpeq)      \
 
87
    XX(__aeabi_cdcmple)      \
 
88
    XX(__aeabi_cdrcmple)     \
 
89
    XX(__aeabi_d2f)          \
 
90
    XX(__aeabi_d2iz)         \
 
91
    XX(__aeabi_dadd)         \
 
92
    XX(__aeabi_dcmpeq)       \
 
93
    XX(__aeabi_dcmpge)       \
 
94
    XX(__aeabi_dcmpgt)       \
 
95
    XX(__aeabi_dcmple)       \
 
96
    XX(__aeabi_dcmplt)       \
 
97
    XX(__aeabi_dcmpun)       \
 
98
    XX(__aeabi_ddiv)         \
 
99
    XX(__aeabi_dmul)         \
 
100
    XX(__aeabi_drsub)        \
 
101
    XX(__aeabi_dsub)         \
 
102
    XX(__aeabi_f2d)          \
 
103
    XX(__aeabi_f2iz)         \
 
104
    XX(__aeabi_f2uiz)        \
 
105
    XX(__aeabi_fadd)         \
 
106
    XX(__aeabi_fcmpun)       \
 
107
    XX(__aeabi_fdiv)         \
 
108
    XX(__aeabi_fmul)         \
 
109
    XX(__aeabi_frsub)        \
 
110
    XX(__aeabi_fsub)         \
 
111
    XX(__aeabi_i2d)          \
 
112
    XX(__aeabi_i2f)          \
 
113
    XX(__aeabi_l2d)          \
 
114
    XX(__aeabi_l2f)          \
 
115
    XX(__aeabi_lmul)         \
 
116
    XX(__aeabi_llsl)         \
 
117
    XX(__aeabi_llsr)         \
 
118
    XX(__aeabi_ui2d)         \
 
119
    XX(__aeabi_ui2f)         \
 
120
    XX(__aeabi_ul2d)         \
 
121
    XX(__aeabi_ul2f)         \
 
122
    XX(__cmpdf2)             \
 
123
    XX(__divdf3)             \
 
124
    XX(__divsf3)             \
 
125
    XX(__eqdf2)             \
 
126
    XX(__extendsfdf2)        \
 
127
    XX(__fixdfsi)            \
 
128
    XX(__fixsfsi)            \
 
129
    XX(__floatdidf)          \
 
130
    XX(__floatdisf)          \
 
131
    XX(__floatsidf)          \
 
132
    XX(__floatsisf)          \
 
133
    XX(__floatundidf)        \
 
134
    XX(__floatundisf)        \
 
135
    XX(__floatunsidf)        \
 
136
    XX(__floatunsisf)        \
 
137
    XX(__gedf2)              \
 
138
    XX(__gtdf2)              \
 
139
    XX(__ledf2)              \
 
140
    XX(__ltdf2)              \
 
141
    XX(__muldf3)             \
 
142
    XX(__muldi3)             \
 
143
    XX(__mulsf3)             \
 
144
    XX(__nedf2)              \
 
145
    XX(__subdf3)             \
 
146
    XX(__subsf3)             \
 
147
    XX(__truncdfsf2)         \
 
148
    XX(__unorddf2)           \
 
149
    XX(__unordsf2)           \
 
150
 
 
151
#define  XX(f)    extern void f(void);
 
152
COMPAT_FUNCTIONS_LIST
 
153
#undef XX
 
154
 
 
155
void  __bionic_libgcc_compat_hooks(void)
 
156
{
 
157
#define XX(f)    f();
 
158
COMPAT_FUNCTIONS_LIST
 
159
#undef XX
 
160
}