Allow linker scripts when building objects.

Test: m nothing
Test: TreeHugger
Bug: 134581881
Bug: 137267623

Change-Id: If1422372585ec032a9e36eab73a04e98fe1c1b6c
This commit is contained in:
Pete Bentley
2019-08-16 20:25:06 +01:00
committed by Colin Cross
parent fcf55bf656
commit 74c9bbacb6
5 changed files with 52 additions and 12 deletions

View File

@@ -33,6 +33,20 @@ type objectLinker struct {
Properties ObjectLinkerProperties
}
type ObjectLinkerProperties struct {
// list of modules that should only provide headers for this module.
Header_libs []string `android:"arch_variant,variant_prepend"`
// names of other cc_object modules to link into this module using partial linking
Objs []string `android:"arch_variant"`
// if set, add an extra objcopy --prefix-symbols= step
Prefix_symbols *string
// if set, the path to a linker script to pass to ld -r when combining multiple object files.
Linker_script *string `android:"path,arch_variant"`
}
// cc_object runs the compiler without running the linker. It is rarely
// necessary, but sometimes used to generate .s files from .c files to use as
// input to a cc_genrule module.
@@ -71,9 +85,13 @@ func (object *objectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
return deps
}
func (*objectLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
func (object *objectLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
flags.LdFlags = append(flags.LdFlags, ctx.toolchain().ToolchainClangLdflags())
if lds := android.OptionalPathForModuleSrc(ctx, object.Properties.Linker_script); lds.Valid() {
flags.LdFlags = append(flags.LdFlags, "-Wl,-T,"+lds.String())
flags.LdFlagsDeps = append(flags.LdFlagsDeps, lds.Path())
}
return flags
}