• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2020 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17// We introduce this namespace so that native bridge guest libraries are built
18// only for targets that explicitly use this namespace via PRODUCT_SOONG_NAMESPACES
19// and checkbuild.
20soong_namespace {
21}
22
23package {
24    default_applicable_licenses: ["Android-Apache-2.0"],
25}
26
27cc_library {
28    defaults: [
29        "native_bridge_stub_library_defaults",
30        // Definitions come from bionic/libc/Android.bp that force
31        // the usage of the correct native allocator.
32        "libc_native_allocator_defaults",
33    ],
34    name: "libnative_bridge_guest_libc",
35    overrides: ["libc"],
36    stem: "libc",
37
38    srcs: [
39        ":libc_sources_shared",
40        "__cxa_thread_atexit_impl.cpp",
41        "__libc_add_main_thread.cpp",
42        "__libc_init_scudo.cpp",
43        "__libc_set_target_sdk_version.cpp",
44        "exit.c",
45        "malloc_init.cpp",
46    ],
47
48    include_dirs: [
49        "bionic/libc",
50        "bionic/libc/arch-common/bionic",
51        "bionic/libc/async_safe/include",
52        "bionic/libc/bionic",
53        "bionic/libc/stdio",
54        "bionic/libstdc++/include",
55    ],
56
57    cflags: [
58        "-D_LIBC=1",
59    ],
60
61    product_variables: {
62        platform_sdk_version: {
63            asflags: ["-DPLATFORM_SDK_VERSION=%d"],
64            cflags: ["-DPLATFORM_SDK_VERSION=%d"],
65        },
66    },
67
68    arch: {
69        arm: {
70            srcs: [
71                ":libc_sources_shared_arm",
72                "stubs_arm.cpp",
73            ],
74
75            cflags: [
76                "-DCRT_LEGACY_WORKAROUND",
77            ],
78
79            version_script: ":libc.arm.map",
80            no_libcrt: true,
81
82            shared: {
83                // For backwards-compatibility, some arm32 builtins are exported from libc.so.
84                static_libs: ["libclang_rt.builtins-exported"],
85            },
86
87            // Arm 32 bit does not produce complete exidx unwind information
88            // so keep the .debug_frame which is relatively small and does
89            // include needed unwind information.
90            // See b/132992102 for details.
91            strip: {
92                keep_symbols_and_debug_frame: true,
93            },
94        },
95        arm64: {
96            srcs: ["stubs_arm64.cpp"],
97
98            version_script: ":libc.arm64.map",
99
100            // Leave the symbols in the shared library so that stack unwinders can produce
101            // meaningful name resolution.
102            strip: {
103                keep_symbols: true,
104            },
105        },
106        riscv64: {
107            srcs: ["stubs_riscv64.cpp"],
108
109            version_script: ":libc.riscv64.map",
110
111            // Leave the symbols in the shared library so that stack unwinders can produce
112            // meaningful name resolution.
113            strip: {
114                keep_symbols: true,
115            },
116        },
117    },
118
119    nocrt: true,
120
121    required: ["tzdata_prebuilt"],
122
123    whole_static_libs: [
124        "gwp_asan",
125        "libc_init_dynamic",
126        "libc_common_shared",
127        "libunwind-exported",
128    ],
129
130    shared_libs: [
131        "ld-android",
132        "libdl",
133    ],
134
135    static_libs: [
136        "libdl_android",
137    ],
138
139    system_shared_libs: [],
140    stl: "none",
141
142    strip: {
143        keep_symbols: true,
144    },
145
146    sanitize: {
147        never: true,
148    },
149
150    // lld complains about duplicate symbols in libcrt and libgcc. Suppress the
151    // warning since this is intended right now.
152    // Bug: 117558759
153    ldflags: ["-Wl,-z,muldefs"],
154}
155
156filegroup {
157    name: "native_bridge_proxy_libc_files",
158    srcs: [
159        "proxy/cxa_trampolines.cc",
160        "proxy/libc_translation.cc",
161        "proxy/malloc_translation.cc",
162        "proxy/pthread_translation.cc",
163        "proxy/setjmp_thunks.cc",
164        "proxy/system_properties_trampolines.cc",
165        "proxy/unistd_thunks.cc",
166    ],
167}
168
169cc_defaults {
170    name: "native_bridge_proxy_libc_defaults",
171    srcs: ["//frameworks/libs/native_bridge_support/android_api/libc:native_bridge_proxy_libc_files"],
172    header_libs: [
173        "libberberis_guest_abi_headers",
174        "libberberis_guest_os_primitives_headers",
175        "libberberis_guest_state_headers",
176        "libberberis_proxy_loader_headers",
177        "libberberis_runtime_primitives_headers",
178    ],
179
180    // We need to access Bionic private headers in the libc proxy.
181    include_dirs: ["bionic/libc"],
182}
183