Strip libgcc to only keep fallback symbols

We use libgcc as fallback for symbols not present in libclang_rt
builtins, however we didn't know what exact symbols were being used,
some may not be intended to fallback.

Create libgcc_stripped, which only contains unwind symbols from libgcc.

Bug: 29275768
Test: bionic-unit-tests
Change-Id: I5b349fa6138e51663bf3b67109b880b4356da8e8
diff --git a/cc/toolchain_library.go b/cc/toolchain_library.go
index 6494a26..b4c51ab 100644
--- a/cc/toolchain_library.go
+++ b/cc/toolchain_library.go
@@ -34,6 +34,8 @@
 type toolchainLibraryDecorator struct {
 	*libraryDecorator
 
+	stripper
+
 	Properties toolchainLibraryProperties
 }
 
@@ -45,7 +47,7 @@
 func (library *toolchainLibraryDecorator) linkerProps() []interface{} {
 	var props []interface{}
 	props = append(props, library.libraryDecorator.linkerProps()...)
-	return append(props, &library.Properties)
+	return append(props, &library.Properties, &library.stripper.StripProperties)
 }
 
 // toolchain_library is used internally by the build tool to link the specified
@@ -78,7 +80,17 @@
 		return android.PathForSource(ctx, "")
 	}
 
-	return android.PathForSource(ctx, *library.Properties.Src)
+	srcPath := android.PathForSource(ctx, *library.Properties.Src)
+
+	if library.stripper.StripProperties.Strip.Keep_symbols_list != nil {
+		fileName := ctx.ModuleName() + staticLibraryExtension
+		outputFile := android.PathForModuleOut(ctx, fileName)
+		buildFlags := flagsToBuilderFlags(flags)
+		library.stripper.strip(ctx, srcPath, outputFile, buildFlags)
+		return outputFile
+	}
+
+	return srcPath
 }
 
 func (library *toolchainLibraryDecorator) nativeCoverage() bool {