Make sure that ASAN runtime lib is the first DT_NEEDED one

am: 64a44f231d

Change-Id: I9de37b751142ba8e26636f318be3f8cfa3d4946e
This commit is contained in:
Jiyong Park
2019-01-24 21:10:14 -08:00
committed by android-build-merger
4 changed files with 16 additions and 6 deletions

View File

@@ -363,8 +363,10 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
var sharedLibs android.Paths var sharedLibs android.Paths
// Ignore shared libs for static executables. // Ignore shared libs for static executables.
if !binary.static() { if !binary.static() {
sharedLibs = deps.SharedLibs sharedLibs = deps.EarlySharedLibs
sharedLibs = append(sharedLibs, deps.SharedLibs...)
sharedLibs = append(sharedLibs, deps.LateSharedLibs...) sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
linkerDeps = append(linkerDeps, deps.EarlySharedLibsDeps...)
linkerDeps = append(linkerDeps, deps.SharedLibsDeps...) linkerDeps = append(linkerDeps, deps.SharedLibsDeps...)
linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...) linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...)
} }

View File

@@ -96,9 +96,9 @@ type Deps struct {
type PathDeps struct { type PathDeps struct {
// Paths to .so files // Paths to .so files
SharedLibs, LateSharedLibs android.Paths SharedLibs, EarlySharedLibs, LateSharedLibs android.Paths
// Paths to the dependencies to use for .so files (.so.toc files) // Paths to the dependencies to use for .so files (.so.toc files)
SharedLibsDeps, LateSharedLibsDeps android.Paths SharedLibsDeps, EarlySharedLibsDeps, LateSharedLibsDeps android.Paths
// Paths to .a files // Paths to .a files
StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
@@ -328,6 +328,7 @@ type dependencyTag struct {
var ( var (
sharedDepTag = dependencyTag{name: "shared", library: true} sharedDepTag = dependencyTag{name: "shared", library: true}
sharedExportDepTag = dependencyTag{name: "shared", library: true, reexportFlags: true} sharedExportDepTag = dependencyTag{name: "shared", library: true, reexportFlags: true}
earlySharedDepTag = dependencyTag{name: "early_shared", library: true}
lateSharedDepTag = dependencyTag{name: "late shared", library: true} lateSharedDepTag = dependencyTag{name: "late shared", library: true}
staticDepTag = dependencyTag{name: "static", library: true} staticDepTag = dependencyTag{name: "static", library: true}
staticExportDepTag = dependencyTag{name: "static", library: true, reexportFlags: true} staticExportDepTag = dependencyTag{name: "static", library: true, reexportFlags: true}
@@ -1570,6 +1571,11 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPtr = &depPaths.SharedLibsDeps depPtr = &depPaths.SharedLibsDeps
depFile = ccDep.linker.(libraryInterface).toc() depFile = ccDep.linker.(libraryInterface).toc()
directSharedDeps = append(directSharedDeps, ccDep) directSharedDeps = append(directSharedDeps, ccDep)
case earlySharedDepTag:
ptr = &depPaths.EarlySharedLibs
depPtr = &depPaths.EarlySharedLibsDeps
depFile = ccDep.linker.(libraryInterface).toc()
directSharedDeps = append(directSharedDeps, ccDep)
case lateSharedDepTag, ndkLateStubDepTag: case lateSharedDepTag, ndkLateStubDepTag:
ptr = &depPaths.LateSharedLibs ptr = &depPaths.LateSharedLibs
depPtr = &depPaths.LateSharedLibsDeps depPtr = &depPaths.LateSharedLibsDeps
@@ -1663,7 +1669,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
// Export the shared libs to Make. // Export the shared libs to Make.
switch depTag { switch depTag {
case sharedDepTag, sharedExportDepTag, lateSharedDepTag: case sharedDepTag, sharedExportDepTag, lateSharedDepTag, earlySharedDepTag:
if dependentLibrary, ok := ccDep.linker.(*libraryDecorator); ok { if dependentLibrary, ok := ccDep.linker.(*libraryDecorator); ok {
if dependentLibrary.buildStubs() && android.InAnyApex(depName) { if dependentLibrary.buildStubs() && android.InAnyApex(depName) {
// Add the dependency to the APEX(es) providing the library so that // Add the dependency to the APEX(es) providing the library so that

View File

@@ -696,9 +696,11 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
} }
} }
sharedLibs := deps.SharedLibs sharedLibs := deps.EarlySharedLibs
sharedLibs = append(sharedLibs, deps.SharedLibs...)
sharedLibs = append(sharedLibs, deps.LateSharedLibs...) sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
linkerDeps = append(linkerDeps, deps.EarlySharedLibsDeps...)
linkerDeps = append(linkerDeps, deps.SharedLibsDeps...) linkerDeps = append(linkerDeps, deps.SharedLibsDeps...)
linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...) linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...)
linkerDeps = append(linkerDeps, objs.tidyFiles...) linkerDeps = append(linkerDeps, objs.tidyFiles...)

View File

@@ -809,7 +809,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
mctx.AddFarVariationDependencies([]blueprint.Variation{ mctx.AddFarVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "shared"}, {Mutator: "link", Variation: "shared"},
{Mutator: "arch", Variation: mctx.Target().String()}, {Mutator: "arch", Variation: mctx.Target().String()},
}, sharedDepTag, runtimeLibrary) }, earlySharedDepTag, runtimeLibrary)
} }
// static lib does not have dependency to the runtime library. The // static lib does not have dependency to the runtime library. The
// dependency will be added to the executables or shared libs using // dependency will be added to the executables or shared libs using