Handle the version_script property.

Doesn't work when depends on arch/target/etc., but good enough for
libdl_android.

Bug: 186650430
Test: Presubmits.
Change-Id: Ib0facb41a89454717c74663e5e078aedd33d1b9c
diff --git a/cc/bp2build.go b/cc/bp2build.go
index a4db79f..d52b817 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -246,15 +246,17 @@
 
 // Convenience struct to hold all attributes parsed from linker properties.
 type linkerAttributes struct {
-	deps     bazel.LabelListAttribute
-	linkopts bazel.StringListAttribute
+	deps          bazel.LabelListAttribute
+	linkopts      bazel.StringListAttribute
+	versionScript bazel.LabelAttribute
 }
 
-// bp2BuildParseLinkerProps creates a label list attribute containing the header library deps of a module, including
+// bp2BuildParseLinkerProps parses the linker properties of a module, including
 // configurable attribute values.
 func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module) linkerAttributes {
 	var deps bazel.LabelListAttribute
 	var linkopts bazel.StringListAttribute
+	var versionScript bazel.LabelAttribute
 
 	for _, linkerProps := range module.linker.linkerProps() {
 		if baseLinkerProps, ok := linkerProps.(*BaseLinkerProperties); ok {
@@ -265,6 +267,12 @@
 			libs = android.SortedUniqueStrings(libs)
 			deps = bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, libs))
 			linkopts.Value = baseLinkerProps.Ldflags
+
+			if baseLinkerProps.Version_script != nil {
+				versionScript = bazel.LabelAttribute{
+					Value: android.BazelLabelForModuleSrcSingle(ctx, *baseLinkerProps.Version_script),
+				}
+			}
 			break
 		}
 	}
@@ -294,8 +302,9 @@
 	}
 
 	return linkerAttributes{
-		deps:     deps,
-		linkopts: linkopts,
+		deps:          deps,
+		linkopts:      linkopts,
+		versionScript: versionScript,
 	}
 }
 
diff --git a/cc/library.go b/cc/library.go
index 3b65d8d..50d3f67 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -228,6 +228,7 @@
 	User_link_flags        bazel.StringListAttribute
 	Includes               bazel.StringListAttribute
 	Static_deps_for_shared bazel.LabelListAttribute
+	Version_script         bazel.LabelAttribute
 }
 
 type bazelCcLibrary struct {
@@ -273,6 +274,7 @@
 		Copts:                  compilerAttrs.copts,
 		Linkopts:               linkerAttrs.linkopts,
 		Deps:                   linkerAttrs.deps,
+		Version_script:         linkerAttrs.versionScript,
 		Static_deps_for_shared: sharedAttrs.staticDeps,
 		Includes:               exportedIncludes,
 	}