Merge "Use a linker script for host bionic embedded linker sections"

This commit is contained in:
Colin Cross
2021-06-16 16:51:10 +00:00
committed by Gerrit Code Review
5 changed files with 23 additions and 44 deletions

View File

@@ -178,7 +178,7 @@ func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
// the kernel before jumping to the embedded linker.
if ctx.Os() == android.LinuxBionic && !binary.static() {
deps.DynamicLinker = "linker"
deps.LinkerFlagsFile = "host_bionic_linker_flags"
deps.CrtBegin = append(deps.CrtBegin, "host_bionic_linker_script")
}
}
@@ -345,12 +345,6 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
var linkerDeps android.Paths
// Add flags from linker flags file.
if deps.LinkerFlagsFile.Valid() {
flags.Local.LdFlags = append(flags.Local.LdFlags, "$$(cat "+deps.LinkerFlagsFile.String()+")")
linkerDeps = append(linkerDeps, deps.LinkerFlagsFile.Path())
}
if flags.DynamicLinker != "" {
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-dynamic-linker,"+flags.DynamicLinker)
} else if ctx.toolchain().Bionic() && !binary.static() {

View File

@@ -129,8 +129,7 @@ type Deps struct {
CrtBegin, CrtEnd []string
// Used for host bionic
LinkerFlagsFile string
DynamicLinker string
DynamicLinker string
// List of libs that need to be excluded for APEX variant
ExcludeLibsForApex []string
@@ -179,9 +178,6 @@ type PathDeps struct {
// Paths to crt*.o files
CrtBegin, CrtEnd android.Paths
// Path to the file container flags to use with the linker
LinkerFlagsFile android.OptionalPath
// Path to the dynamic linker binary
DynamicLinker android.OptionalPath
}
@@ -726,7 +722,6 @@ var (
genHeaderDepTag = dependencyTag{name: "gen header"}
genHeaderExportDepTag = dependencyTag{name: "gen header export"}
objDepTag = dependencyTag{name: "obj"}
linkerFlagsDepTag = dependencyTag{name: "linker flags file"}
dynamicLinkerDepTag = installDependencyTag{name: "dynamic linker"}
reuseObjTag = dependencyTag{name: "reuse objects"}
staticVariantTag = dependencyTag{name: "static variant"}
@@ -2272,9 +2267,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
actx.AddVariationDependencies(crtVariations, CrtEndDepTag,
RewriteSnapshotLib(crt, GetSnapshot(c, &snapshotInfo, actx).Objects))
}
if deps.LinkerFlagsFile != "" {
actx.AddDependency(c, linkerFlagsDepTag, deps.LinkerFlagsFile)
}
if deps.DynamicLinker != "" {
actx.AddDependency(c, dynamicLinkerDepTag, deps.DynamicLinker)
}
@@ -2573,17 +2565,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
} else {
ctx.ModuleErrorf("module %q is not a genrule", depName)
}
case linkerFlagsDepTag:
if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
files := genRule.GeneratedSourceFiles()
if len(files) == 1 {
depPaths.LinkerFlagsFile = android.OptionalPathForPath(files[0])
} else if len(files) > 1 {
ctx.ModuleErrorf("module %q can only generate a single file if used for a linker flag file", depName)
}
} else {
ctx.ModuleErrorf("module %q is not a genrule", depName)
}
case CrtBeginDepTag:
depPaths.CrtBegin = append(depPaths.CrtBegin, android.OutputFileForModule(ctx, dep, ""))
case CrtEndDepTag:

View File

@@ -490,7 +490,7 @@ func withLinuxBionic() string {
}
cc_genrule {
name: "host_bionic_linker_flags",
name: "host_bionic_linker_script",
host_supported: true,
device_supported: false,
target: {
@@ -501,7 +501,7 @@ func withLinuxBionic() string {
enabled: true,
},
},
out: ["linker.flags"],
out: ["linker.script"],
}
cc_defaults {