Support prefix_symbols for linker
The linker needs to add __dl_ to the beginning of all of its symbols
to avoid conflicts. Add support for a prefix_symbols property, and
insert an objcopy --prefix_symbols build step to produce the final
binary.
Change-Id: I70de7c830cd64305e5900c6de53efecea2e17c75
diff --git a/cc/builder.go b/cc/builder.go
index 4c86110..c843c2d 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -67,6 +67,13 @@
},
"arCmd", "arFlags")
+ prefixSymbols = pctx.StaticRule("prefixSymbols",
+ blueprint.RuleParams{
+ Command: "$objcopyCmd --prefix-symbols=${prefix} ${in} ${out}",
+ Description: "prefixSymbols $out",
+ },
+ "objcopyCmd", "prefix")
+
copyGccLibPath = pctx.StaticVariable("copyGccLibPath", "${SrcDir}/build/soong/copygcclib.sh")
copyGccLib = pctx.StaticRule("copyGccLib",
@@ -272,6 +279,24 @@
})
}
+// Generate a rule for runing objcopy --prefix-symbols on a binary
+func TransformBinaryPrefixSymbols(ctx common.AndroidModuleContext, prefix string, inputFile string,
+ flags builderFlags, outputFile string) {
+
+ objcopyCmd := gccCmd(flags.toolchain, "objcopy")
+
+ ctx.Build(pctx, blueprint.BuildParams{
+ Rule: prefixSymbols,
+ Outputs: []string{outputFile},
+ Inputs: []string{inputFile},
+ Implicits: []string{objcopyCmd},
+ Args: map[string]string{
+ "objcopyCmd": objcopyCmd,
+ "prefix": prefix,
+ },
+ })
+}
+
func CopyGccLib(ctx common.AndroidModuleContext, libName string,
flags builderFlags, outputFile string) {