From b70617a1604e8bfc39ceb701ed70f69fd4f34a8b Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Mon, 14 Jan 2019 11:00:10 -0800 Subject: [PATCH] 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 --- cc/linker.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cc/linker.go b/cc/linker.go index 854dfc578..eb7126874 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -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 }