Reuse more of apex stubs implementation for llndk stubs

Use the linker script and exported flags support from apex stubs
for llndk stubs.

Test: no change to build.ninja or Android-${TARGET_PRODUCT}.mk
Change-Id: I9886498dcac7419958d290de99cf5f39f5fdedee
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index 3b8b47d..e50da9a 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -68,9 +68,6 @@
 
 	Properties llndkLibraryProperties
 
-	exportHeadersTimestamp android.OptionalPath
-	versionScriptPath      android.ModuleGenPath
-
 	movedToApex bool
 }
 
@@ -89,7 +86,9 @@
 		vndkVer = stub.stubsVersion()
 	}
 	objs, versionScript := compileStubLibrary(ctx, flags, String(stub.Properties.Symbol_file), vndkVer, "--llndk")
-	stub.versionScriptPath = versionScript
+	if !Bool(stub.Properties.Unversioned) {
+		stub.versionScriptPath = android.OptionalPathForPath(versionScript)
+	}
 	return objs
 }
 
@@ -138,12 +137,6 @@
 		stub.movedToApex = implApexModule.DirectlyInAnyApex()
 	}
 
-	if !Bool(stub.Properties.Unversioned) {
-		linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String()
-		flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag)
-		flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath)
-	}
-
 	if len(stub.Properties.Export_preprocessed_headers) > 0 {
 		genHeaderOutDir := android.PathForModuleGen(ctx, "include")
 
@@ -166,10 +159,6 @@
 		stub.libraryDecorator.flagExporter.Properties.Export_include_dirs = []string{}
 	}
 
-	if stub.stubsVersion() != "" {
-		stub.reexportFlags("-D" + versioningMacroName(ctx.baseModuleName()) + "=" + stub.stubsVersion())
-	}
-
 	return stub.libraryDecorator.link(ctx, flags, deps, objs)
 }
 
@@ -181,8 +170,6 @@
 	return true
 }
 
-func (stub *llndkStubDecorator) setBuildStubs() {}
-
 func NewLLndkStubLibrary() *Module {
 	module, library := NewLibrary(android.DeviceSupported)
 	library.BuildOnlyShared()