Loading cc/builder.go +23 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,14 @@ var ( }, "objcopyCmd", "prefix") // Rule to run objcopy --remove-section=.llvm_addrsig on a partially linked object noAddrSig = pctx.AndroidStaticRule("noAddrSig", blueprint.RuleParams{ Command: "rm -f ${out} && $objcopyCmd --remove-section=.llvm_addrsig ${in} ${out}", CommandDeps: []string{"$objcopyCmd"}, }, "objcopyCmd") _ = pctx.SourcePathVariable("stripPath", "build/soong/scripts/strip.sh") _ = pctx.SourcePathVariable("xzCmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/xz") _ = pctx.SourcePathVariable("createMiniDebugInfo", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/create_minidebuginfo") Loading Loading @@ -1008,6 +1016,21 @@ func transformBinaryPrefixSymbols(ctx android.ModuleContext, prefix string, inpu }) } // Generate a rule for running objcopy --remove-section=.llvm_addrsig on a partially linked object func transformObjectNoAddrSig(ctx android.ModuleContext, inputFile android.Path, outputFile android.WritablePath) { objcopyCmd := "${config.ClangBin}/llvm-objcopy" ctx.Build(pctx, android.BuildParams{ Rule: noAddrSig, Description: "remove addrsig " + outputFile.Base(), Output: outputFile, Input: inputFile, Args: map[string]string{ "objcopyCmd": objcopyCmd, }, }) } // Registers a build statement to invoke `strip` (to discard symbols and data from object files). func transformStrip(ctx android.ModuleContext, inputFile android.Path, outputFile android.WritablePath, flags StripFlags) { Loading cc/object.go +8 −1 Original line number Diff line number Diff line Loading @@ -309,6 +309,8 @@ func (object *objectLinker) link(ctx ModuleContext, }) } } else { outputAddrSig := android.PathForModuleOut(ctx, "addrsig", outputName) if String(object.Properties.Prefix_symbols) != "" { input := android.PathForModuleOut(ctx, "unprefixed", outputName) transformBinaryPrefixSymbols(ctx, String(object.Properties.Prefix_symbols), input, Loading @@ -316,7 +318,12 @@ func (object *objectLinker) link(ctx ModuleContext, output = input } transformObjsToObj(ctx, objs.objFiles, builderFlags, output, flags.LdFlagsDeps) transformObjsToObj(ctx, objs.objFiles, builderFlags, outputAddrSig, flags.LdFlagsDeps) // ld -r reorders symbols and invalidates the .llvm_addrsig section, which then causes warnings // if the resulting object is used with ld --icf=safe. Strip the .llvm_addrsig section to // prevent the warnings. transformObjectNoAddrSig(ctx, outputAddrSig, output) } ctx.CheckbuildFile(outputFile) Loading java/app_test.go +2 −2 Original line number Diff line number Diff line Loading @@ -443,9 +443,9 @@ func TestUpdatableApps_JniLibShouldBeBuiltAgainstMinSdkVersion(t *testing.T) { inputs := ctx.ModuleForTests("libjni", "android_arm64_armv8-a_sdk_shared").Description("link").Implicits var crtbeginFound, crtendFound bool expectedCrtBegin := ctx.ModuleForTests("crtbegin_so", "android_arm64_armv8-a_sdk_29").Rule("partialLd").Output "android_arm64_armv8-a_sdk_29").Rule("noAddrSig").Output expectedCrtEnd := ctx.ModuleForTests("crtend_so", "android_arm64_armv8-a_sdk_29").Rule("partialLd").Output "android_arm64_armv8-a_sdk_29").Rule("noAddrSig").Output implicits := []string{} for _, input := range inputs { implicits = append(implicits, input.String()) Loading Loading
cc/builder.go +23 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,14 @@ var ( }, "objcopyCmd", "prefix") // Rule to run objcopy --remove-section=.llvm_addrsig on a partially linked object noAddrSig = pctx.AndroidStaticRule("noAddrSig", blueprint.RuleParams{ Command: "rm -f ${out} && $objcopyCmd --remove-section=.llvm_addrsig ${in} ${out}", CommandDeps: []string{"$objcopyCmd"}, }, "objcopyCmd") _ = pctx.SourcePathVariable("stripPath", "build/soong/scripts/strip.sh") _ = pctx.SourcePathVariable("xzCmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/xz") _ = pctx.SourcePathVariable("createMiniDebugInfo", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/create_minidebuginfo") Loading Loading @@ -1008,6 +1016,21 @@ func transformBinaryPrefixSymbols(ctx android.ModuleContext, prefix string, inpu }) } // Generate a rule for running objcopy --remove-section=.llvm_addrsig on a partially linked object func transformObjectNoAddrSig(ctx android.ModuleContext, inputFile android.Path, outputFile android.WritablePath) { objcopyCmd := "${config.ClangBin}/llvm-objcopy" ctx.Build(pctx, android.BuildParams{ Rule: noAddrSig, Description: "remove addrsig " + outputFile.Base(), Output: outputFile, Input: inputFile, Args: map[string]string{ "objcopyCmd": objcopyCmd, }, }) } // Registers a build statement to invoke `strip` (to discard symbols and data from object files). func transformStrip(ctx android.ModuleContext, inputFile android.Path, outputFile android.WritablePath, flags StripFlags) { Loading
cc/object.go +8 −1 Original line number Diff line number Diff line Loading @@ -309,6 +309,8 @@ func (object *objectLinker) link(ctx ModuleContext, }) } } else { outputAddrSig := android.PathForModuleOut(ctx, "addrsig", outputName) if String(object.Properties.Prefix_symbols) != "" { input := android.PathForModuleOut(ctx, "unprefixed", outputName) transformBinaryPrefixSymbols(ctx, String(object.Properties.Prefix_symbols), input, Loading @@ -316,7 +318,12 @@ func (object *objectLinker) link(ctx ModuleContext, output = input } transformObjsToObj(ctx, objs.objFiles, builderFlags, output, flags.LdFlagsDeps) transformObjsToObj(ctx, objs.objFiles, builderFlags, outputAddrSig, flags.LdFlagsDeps) // ld -r reorders symbols and invalidates the .llvm_addrsig section, which then causes warnings // if the resulting object is used with ld --icf=safe. Strip the .llvm_addrsig section to // prevent the warnings. transformObjectNoAddrSig(ctx, outputAddrSig, output) } ctx.CheckbuildFile(outputFile) Loading
java/app_test.go +2 −2 Original line number Diff line number Diff line Loading @@ -443,9 +443,9 @@ func TestUpdatableApps_JniLibShouldBeBuiltAgainstMinSdkVersion(t *testing.T) { inputs := ctx.ModuleForTests("libjni", "android_arm64_armv8-a_sdk_shared").Description("link").Implicits var crtbeginFound, crtendFound bool expectedCrtBegin := ctx.ModuleForTests("crtbegin_so", "android_arm64_armv8-a_sdk_29").Rule("partialLd").Output "android_arm64_armv8-a_sdk_29").Rule("noAddrSig").Output expectedCrtEnd := ctx.ModuleForTests("crtend_so", "android_arm64_armv8-a_sdk_29").Rule("partialLd").Output "android_arm64_armv8-a_sdk_29").Rule("noAddrSig").Output implicits := []string{} for _, input := range inputs { implicits = append(implicits, input.String()) Loading