Merge "Use SHT_RELR relocations where possible."

This commit is contained in:
Elliott Hughes
2021-05-11 17:29:39 +00:00
committed by Gerrit Code Review

View File

@@ -421,9 +421,13 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
if !BoolDefault(linker.Properties.Pack_relocations, true) { if !BoolDefault(linker.Properties.Pack_relocations, true) {
flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,--pack-dyn-relocs=none") flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,--pack-dyn-relocs=none")
} else if ctx.Device() { } else if ctx.Device() {
// The SHT_RELR relocations is only supported by API level >= 28. // SHT_RELR relocations are only supported at API level >= 30.
// Do not turn this on if older version NDK is used. // ANDROID_RELR relocations were supported at API level >= 28.
if !ctx.useSdk() || CheckSdkVersionAtLeast(ctx, 28) { // Relocation packer was supported at API level >= 23.
// Do the best we can...
if !ctx.useSdk() || CheckSdkVersionAtLeast(ctx, 30) {
flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,--pack-dyn-relocs=android+relr")
} else if CheckSdkVersionAtLeast(ctx, 28) {
flags.Global.LdFlags = append(flags.Global.LdFlags, flags.Global.LdFlags = append(flags.Global.LdFlags,
"-Wl,--pack-dyn-relocs=android+relr", "-Wl,--pack-dyn-relocs=android+relr",
"-Wl,--use-android-relr-tags") "-Wl,--use-android-relr-tags")