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
diff --git a/cc/linker.go b/cc/linker.go
index 854dfc5..eb71268 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -150,6 +150,9 @@
// 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 @@
linker.Properties.Target.Vendor.Version_script)
}
+ android.ExtractSourceDeps(ctx, linker.Properties.Symbol_ordering_file)
+
return deps
}
@@ -435,6 +440,16 @@
}
}
+ 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
}