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:
@@ -67,6 +67,13 @@ var (
|
|||||||
},
|
},
|
||||||
"arCmd", "arFlags")
|
"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")
|
copyGccLibPath = pctx.StaticVariable("copyGccLibPath", "${SrcDir}/build/soong/copygcclib.sh")
|
||||||
|
|
||||||
copyGccLib = pctx.StaticRule("copyGccLib",
|
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,
|
func CopyGccLib(ctx common.AndroidModuleContext, libName string,
|
||||||
flags builderFlags, outputFile string) {
|
flags builderFlags, outputFile string) {
|
||||||
|
|
||||||
|
6
cc/cc.go
6
cc/cc.go
@@ -1271,6 +1271,12 @@ func (c *CCBinary) compileModule(ctx common.AndroidModuleContext,
|
|||||||
|
|
||||||
outputFile := filepath.Join(common.ModuleOutDir(ctx), c.getStem(ctx))
|
outputFile := filepath.Join(common.ModuleOutDir(ctx), c.getStem(ctx))
|
||||||
c.out = outputFile
|
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,
|
TransformObjToDynamicBinary(ctx, objFiles, deps.SharedLibs, deps.StaticLibs,
|
||||||
deps.LateStaticLibs, deps.WholeStaticLibs, deps.CrtBegin, deps.CrtEnd, true,
|
deps.LateStaticLibs, deps.WholeStaticLibs, deps.CrtBegin, deps.CrtEnd, true,
|
||||||
|
Reference in New Issue
Block a user