platform_bionic/libdl/Android.bp
Jiyong Park c45fe9f7bd Add stubs variants for bionic libs
Bionic libs are part of the runtime APEX (com.android.runtime). In order
to be able to update the runtime APEX independetly from the platform, we
have to prevent things outside of the APEX from using bionic symbols
that are not guaranteed to be stable. Otherwise, platform could break
when a symbol is removed from the libs via the APEX update.

To achive this goal, this change adds stubs variant to the bionic libs.
With this, things outside of the runtime APEX (i.e. other APEXes and the
platform) are built with the stubs variants that provide only the
symbols that are guaranteed to be stable.

The set of symbols are basically the same as the symbols available to
NDK clients. However, there are a few additional symbols that are not
available for NDK but should be made available for platform components.
They are marked with "# apex" tag. Symbols with that tag are not exposed
to apps (via NDK stubs) or vendors (via LLNDK stubs).

Note that the stubs is a build-time only artifact. It is used just to
break the build when private symbols are used outside of the runtime
APEX. At runtime, the real library in the APEX is used.

Bug: 120266448
Test: m
Test: m bionic-unit-tests
Change-Id: I7b8d75830c81d7d7d54e2fca21a85b3417531b47
2019-01-04 22:29:36 +09:00

151 lines
3.7 KiB
Text

//
// libdl
//
cc_library_static {
name: "libdl_static",
defaults: ["linux_bionic_supported"],
recovery_available: true,
srcs: [
"libdl.cpp",
"libdl_cfi.cpp",
],
cflags: [
"-Wall",
"-Wextra",
"-Wunused",
"-Werror",
],
// For private/CFIShadow.h.
include_dirs: ["bionic/libc"],
stl: "none",
system_shared_libs: [],
sanitize: {
never: true,
},
}
cc_library {
name: "libdl",
recovery_available: true,
static_ndk_lib: true,
defaults: ["linux_bionic_supported"],
// NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from
// libgcc.a are made static to libdl.so. This in turn ensures that libraries that
// a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so
// to provide those symbols, but will instead pull them from libgcc.a. Specifically,
// we use this property to make sure libc.so has its own copy of the code from
// libgcc.a it uses.
//
// DO NOT REMOVE --exclude-libs!
ldflags: [
"-Wl,--exclude-libs=libgcc.a",
"-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a",
"-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a",
"-Wl,--exclude-libs=libclang_rt.builtins-x86-android.a",
"-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a",
],
// for x86, exclude libgcc_eh.a for the same reasons as above
arch: {
arm: {
version_script: ":libdl.arm.map",
pack_relocations: false,
ldflags: ["-Wl,--hash-style=both"],
},
arm64: {
version_script: ":libdl.arm64.map",
},
x86: {
pack_relocations: false,
ldflags: [
"-Wl,--exclude-libs=libgcc_eh.a",
"-Wl,--hash-style=both",
],
version_script: ":libdl.x86.map",
},
x86_64: {
ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
version_script: ":libdl.x86_64.map",
},
},
shared: {
whole_static_libs: ["libdl_static"],
},
static: {
srcs: ["libdl_static.cpp"],
},
cflags: [
"-Wall",
"-Wextra",
"-Wunused",
"-Werror",
],
stl: "none",
nocrt: true,
system_shared_libs: [],
// This is placeholder library the actual implementation is (currently)
// provided by the linker.
shared_libs: ["ld-android"],
sanitize: {
never: true,
},
stubs: {
symbol_file: "libdl.map.txt",
versions: ["10000"],
},
}
ndk_library {
name: "libdl",
symbol_file: "libdl.map.txt",
first_version: "9",
}
llndk_library {
name: "libdl",
symbol_file: "libdl.map.txt",
}
genrule {
name: "libdl.arm.map",
out: ["libdl.arm.map"],
srcs: ["libdl.map.txt"],
tool_files: [":bionic-generate-version-script"],
cmd: "$(location :bionic-generate-version-script) arm $(in) $(out)",
}
genrule {
name: "libdl.arm64.map",
out: ["libdl.arm64.map"],
srcs: ["libdl.map.txt"],
tool_files: [":bionic-generate-version-script"],
cmd: "$(location :bionic-generate-version-script) arm64 $(in) $(out)",
}
genrule {
name: "libdl.x86.map",
out: ["libdl.x86.map"],
srcs: ["libdl.map.txt"],
tool_files: [":bionic-generate-version-script"],
cmd: "$(location :bionic-generate-version-script) x86 $(in) $(out)",
}
genrule {
name: "libdl.x86_64.map",
out: ["libdl.x86_64.map"],
srcs: ["libdl.map.txt"],
tool_files: [":bionic-generate-version-script"],
cmd: "$(location :bionic-generate-version-script) x86_64 $(in) $(out)",
}