Do not generate SHT_RELR relocations before API 28
This patch fixes an issue that SHR_RELR relocation is not supported by SDK version earlier than API 28. We only turn it on when SDK is not used, or SDK version is newer than or equal to API 28. Test: m -j48 for aosp_taimen-userdebug Bug: http://b/119086751 Change-Id: I33124ae4f35fb8c00ae9103e8c04e2d4ccd5fec3
This commit is contained in:
parent
3633e8641e
commit
9100b1d83d
|
@ -87,8 +87,6 @@ var (
|
|||
|
||||
deviceGlobalLldflags = append(ClangFilterUnknownLldflags(deviceGlobalLdflags),
|
||||
[]string{
|
||||
"-Wl,--pack-dyn-relocs=android+relr",
|
||||
"-Wl,--use-android-relr-tags",
|
||||
"-fuse-ld=lld",
|
||||
}...)
|
||||
|
||||
|
|
25
cc/linker.go
25
cc/linker.go
|
@ -18,6 +18,7 @@ import (
|
|||
"android/soong/android"
|
||||
"android/soong/cc/config"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
@ -298,6 +299,23 @@ func (linker *baseLinker) useClangLld(ctx ModuleContext) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// Check whether the SDK version is not older than the specific one
|
||||
func CheckSdkVersionAtLeast(ctx ModuleContext, SdkVersion int) bool {
|
||||
if ctx.sdkVersion() == "current" {
|
||||
return true
|
||||
}
|
||||
parsedSdkVersion, err := strconv.Atoi(ctx.sdkVersion())
|
||||
if err != nil {
|
||||
ctx.PropertyErrorf("sdk_version",
|
||||
"Invalid sdk_version value (must be int or current): %q",
|
||||
ctx.sdkVersion())
|
||||
}
|
||||
if parsedSdkVersion < SdkVersion {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// ModuleContext extends BaseModuleContext
|
||||
// BaseModuleContext should know if LLD is used?
|
||||
func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
||||
|
@ -312,6 +330,13 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
|||
flags.LdFlags = append(flags.LdFlags, fmt.Sprintf("${config.%sGlobalLldflags}", hod))
|
||||
if !BoolDefault(linker.Properties.Pack_relocations, true) {
|
||||
flags.LdFlags = append(flags.LdFlags, "-Wl,--pack-dyn-relocs=none")
|
||||
} else if ctx.Device() {
|
||||
// The SHT_RELR relocations is only supported by API level >= 28.
|
||||
// Do not turn this on if older version NDK is used.
|
||||
if !ctx.useSdk() || CheckSdkVersionAtLeast(ctx, 28) {
|
||||
flags.LdFlags = append(flags.LdFlags, "-Wl,--pack-dyn-relocs=android+relr")
|
||||
flags.LdFlags = append(flags.LdFlags, "-Wl,--use-android-relr-tags")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
flags.LdFlags = append(flags.LdFlags, fmt.Sprintf("${config.%sGlobalLdflags}", hod))
|
||||
|
|
Loading…
Reference in New Issue