Add Symbol_ordering_file property

We add an optional Symbol_ordering_file property to linker properties
to allow modules to specify the order of symbols in the binary.

Bug: 112073665
Test: Build libc with a symbol ordering file and check the resulting
      binary.

Change-Id: Ibb24697cfdee4a5750442cb74f1ee6390d8a6430
This commit is contained in:
Vic Yang 2019-01-14 11:00:10 -08:00
parent 6712c0eb87
commit b70617a160
1 changed files with 15 additions and 0 deletions

View File

@ -150,6 +150,9 @@ type BaseLinkerProperties struct {
// local file name to pass to the linker as --version_script
Version_script *string `android:"arch_variant"`
// Local file name to pass to the linker as --symbol-ordering-file
Symbol_ordering_file *string `android:"arch_variant"`
}
func NewBaseLinker(sanitize *sanitize) *baseLinker {
@ -279,6 +282,8 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
linker.Properties.Target.Vendor.Version_script)
}
android.ExtractSourceDeps(ctx, linker.Properties.Symbol_ordering_file)
return deps
}
@ -435,6 +440,16 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
}
}
if !linker.dynamicProperties.BuildStubs {
symbolOrderingFile := ctx.ExpandOptionalSource(
linker.Properties.Symbol_ordering_file, "Symbol_ordering_file")
if symbolOrderingFile.Valid() {
flags.LdFlags = append(flags.LdFlags,
"-Wl,--symbol-ordering-file,"+symbolOrderingFile.String())
flags.LdFlagsDeps = append(flags.LdFlagsDeps, symbolOrderingFile.Path())
}
}
return flags
}