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
This commit is contained in:
Colin Cross
2015-03-26 14:44:11 -07:00
parent ed4cf0b655
commit bfae8859f2
2 changed files with 31 additions and 0 deletions

View File

@@ -67,6 +67,13 @@ var (
},
"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 @@ func TransformObjsToObj(ctx common.AndroidModuleContext, objFiles []string,
})
}
// 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) {

View File

@@ -1271,6 +1271,12 @@ func (c *CCBinary) compileModule(ctx common.AndroidModuleContext,
outputFile := filepath.Join(common.ModuleOutDir(ctx), c.getStem(ctx))
c.out = outputFile
if c.BinaryProperties.Prefix_symbols != "" {
afterPrefixSymbols := outputFile
outputFile = outputFile + ".intermediate"
TransformBinaryPrefixSymbols(ctx, c.BinaryProperties.Prefix_symbols, outputFile,
ccFlagsToBuilderFlags(flags), afterPrefixSymbols)
}
TransformObjToDynamicBinary(ctx, objFiles, deps.SharedLibs, deps.StaticLibs,
deps.LateStaticLibs, deps.WholeStaticLibs, deps.CrtBegin, deps.CrtEnd, true,