Stop linking libdl.a into static bins
libdl.a has a no-op dlopen, which breaks static libraries that need a real dlopen. Instead of automatically linking libdl.a into static executables, make it optional. Until recently, the libunwind_llvm.a unwinder, used on arm32, needed the no-op dladdr, but it's now built using -D_LIBUNWIND_USE_DLADDR=0. The HWASan run-time uses dlsym and dladdr, so add a libdl dependency for HWASan-built static binaries. We could also remove the dependency from libclang_rt.hwasan_static-*.a, but this is also easy to do. Bug: http://b/141485154 Test: bionic unit tests, device boots, verify that static and dynamic executables can throw/catch an exception Test: verify that a static executable using dlopen doesn't link (unless it adds an explicit dependency on libdl) Change-Id: Ic52c3f336b671b4ed335e99c94a64dfe8614b618
This commit is contained in:
@@ -848,12 +848,14 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
|
||||
|
||||
// Determine the runtime library required
|
||||
runtimeLibrary := ""
|
||||
var extraStaticDeps []string
|
||||
toolchain := c.toolchain(mctx)
|
||||
if Bool(c.sanitize.Properties.Sanitize.Address) {
|
||||
runtimeLibrary = config.AddressSanitizerRuntimeLibrary(toolchain)
|
||||
} else if Bool(c.sanitize.Properties.Sanitize.Hwaddress) {
|
||||
if c.staticBinary() {
|
||||
runtimeLibrary = config.HWAddressSanitizerStaticLibrary(toolchain)
|
||||
extraStaticDeps = []string{"libdl"}
|
||||
} else {
|
||||
runtimeLibrary = config.HWAddressSanitizerRuntimeLibrary(toolchain)
|
||||
}
|
||||
@@ -887,7 +889,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
|
||||
mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{
|
||||
{Mutator: "link", Variation: "static"},
|
||||
{Mutator: "image", Variation: c.imageVariation()},
|
||||
}...), staticDepTag, runtimeLibrary)
|
||||
}...), staticDepTag, append([]string{runtimeLibrary}, extraStaticDeps...)...)
|
||||
} else if !c.static() && !c.header() {
|
||||
// dynamic executable and shared libs get shared runtime libs
|
||||
mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{
|
||||
|
Reference in New Issue
Block a user