Dedup version-script handling code.

This is common to binaries and libraries, so move it from library.link
and binary.link to baseLinker.linkerFlags and baseLinker.linkerDeps.

Test: make checkbuild
Bug: None
Change-Id: I5fb24118e601673ae0713a6adc773a1565749be8
diff --git a/cc/binary.go b/cc/binary.go
index 82e1941..be79032 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -31,9 +31,6 @@
 	// if set, add an extra objcopy --prefix-symbols= step
 	Prefix_symbols *string
 
-	// local file name to pass to the linker as --version_script
-	Version_script *string `android:"arch_variant"`
-
 	// if set, install a symlink to the preferred architecture
 	Symlink_preferred_arch *bool
 
@@ -163,8 +160,6 @@
 			"from static libs or set static_executable: true")
 	}
 
-	android.ExtractSourceDeps(ctx, binary.Properties.Version_script)
-
 	return deps
 }
 
@@ -175,7 +170,7 @@
 func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
 	module := newModule(hod, android.MultilibFirst)
 	binary := &binaryDecorator{
-		baseLinker:    NewBaseLinker(),
+		baseLinker:    NewBaseLinker(module.sanitize),
 		baseInstaller: NewBaseInstaller("bin", "", InstallInSystem),
 	}
 	module.compiler = NewBaseCompiler()
@@ -281,7 +276,6 @@
 func (binary *binaryDecorator) link(ctx ModuleContext,
 	flags Flags, deps PathDeps, objs Objects) android.Path {
 
-	versionScript := ctx.ExpandOptionalSource(binary.Properties.Version_script, "version_script")
 	fileName := binary.getStem(ctx) + flags.Toolchain.ExecutableSuffix()
 	outputFile := android.PathForModuleOut(ctx, fileName)
 	ret := outputFile
@@ -291,15 +285,6 @@
 	sharedLibs := deps.SharedLibs
 	sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
 
-	if versionScript.Valid() {
-		if ctx.Darwin() {
-			ctx.PropertyErrorf("version_script", "Not supported on Darwin")
-		} else {
-			flags.LdFlags = append(flags.LdFlags, "-Wl,--version-script,"+versionScript.String())
-			linkerDeps = append(linkerDeps, versionScript.Path())
-		}
-	}
-
 	if deps.LinkerScript.Valid() {
 		flags.LdFlags = append(flags.LdFlags, "-Wl,-T,"+deps.LinkerScript.String())
 		linkerDeps = append(linkerDeps, deps.LinkerScript.Path())