• 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
17cc_library {
18    defaults: [
19        "native_bridge_stub_library_defaults",
20        // Definitions come from bionic/libc/Android.bp that force
21        // the usage of the correct native allocator.
22        "libc_native_allocator_defaults",
23    ],
24    name: "libnative_bridge_guest_libc",
25    overrides: ["libc"],
26    stem: "libc",
27
28    srcs: [
29        ":libc_sources_shared",
30        "__cxa_thread_atexit_impl.cpp",
31        "__libc_add_main_thread.cpp",
32        "exit.c",
33        "malloc_init.cpp",
34    ],
35
36    include_dirs: [
37        "bionic/libc",
38        "bionic/libc/arch-common/bionic",
39        "bionic/libc/async_safe/include",
40        "bionic/libc/bionic",
41        "bionic/libc/stdio",
42        "bionic/libstdc++/include",
43    ],
44
45    cflags: [
46        "-D_LIBC=1",
47        "-fno-emulated-tls", // Required for GWP-Asan.
48    ],
49
50    product_variables: {
51        platform_sdk_version: {
52            asflags: ["-DPLATFORM_SDK_VERSION=%d"],
53            cflags: ["-DPLATFORM_SDK_VERSION=%d"],
54        },
55    },
56
57    arch: {
58        arm: {
59            srcs: [
60                ":libc_sources_shared_arm",
61                "stubs_arm.cpp",
62            ],
63
64            cflags: [
65                "-DCRT_LEGACY_WORKAROUND",
66            ],
67
68            version_script: ":libc.arm.map",
69
70            // Arm 32 bit does not produce complete exidx unwind information
71            // so keep the .debug_frame which is relatively small and does
72            // include needed unwind information.
73            // See b/132992102 for details.
74            strip: {
75                keep_symbols_and_debug_frame: true,
76            },
77
78            whole_static_libs: [ "libunwind_llvm" ],
79        },
80        arm64: {
81            srcs: ["stubs_arm64.cpp"],
82
83            version_script: ":libc.arm64.map",
84
85            // Leave the symbols in the shared library so that stack unwinders can produce
86            // meaningful name resolution.
87            strip: {
88                keep_symbols: true,
89            },
90
91            whole_static_libs: [ "libgcc_stripped" ],
92        }
93    },
94
95    nocrt: true,
96
97    required: ["tzdata"],
98
99    whole_static_libs: [
100        "gwp_asan",
101        "libc_init_dynamic",
102        "libc_common_shared",
103    ],
104
105    shared_libs: [
106        "ld-android",
107        "libdl",
108    ],
109
110    static_libs: [
111        "libdl_android",
112    ],
113
114    system_shared_libs: [],
115    stl: "none",
116
117    strip: {
118        keep_symbols: true,
119    },
120
121    sanitize: {
122        never: true,
123    },
124
125    // lld complains about duplicate symbols in libcrt and libgcc. Suppress the
126    // warning since this is intended right now.
127    // Bug: 117558759
128    ldflags: ["-Wl,-z,muldefs"],
129}
130