diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -876,7 +876,8 @@ config->fini = args.getLastArgValue(OPT_fini, "_fini"); config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419) && !args.hasArg(OPT_relocatable); - config->fixCortexA8 = args.hasArg(OPT_fix_cortex_a8); + config->fixCortexA8 = + args.hasArg(OPT_fix_cortex_a8) && !args.hasArg(OPT_relocatable); config->forceBTI = hasZOption(args, "force-bti"); config->gcSections = args.hasFlag(OPT_gc_sections, OPT_no_gc_sections, false); config->gnuUnique = args.hasFlag(OPT_gnu_unique, OPT_no_gnu_unique, true); diff --git a/lld/test/ELF/arm-fix-cortex-a8-recognize.s b/lld/test/ELF/arm-fix-cortex-a8-recognize.s --- a/lld/test/ELF/arm-fix-cortex-a8-recognize.s +++ b/lld/test/ELF/arm-fix-cortex-a8-recognize.s @@ -10,6 +10,8 @@ // RUN: llvm-objdump -d %t2 --start-address=0x17ffa --stop-address=0x18002 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE6 %s // RUN: llvm-objdump -d %t2 --start-address=0x18ffa --stop-address=0x19002 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE7 %s // RUN: llvm-objdump -d %t2 --start-address=0x19ff4 --stop-address=0x1a002 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE8 %s +// RUN: ld.lld --fix-cortex-a8 -verbose -r %t.o -o %t3 2>&1 | FileCheck --check-prefix=CHECK-RELOCATABLE-LLD %s +// RUN: llvm-objdump --no-show-raw-insn -d %t3 --start-address=0xffa --stop-address=0x1002 | FileCheck --check-prefix=CHECK-RELOCATABLE %s // CHECK: ld.lld: detected cortex-a8-657419 erratum sequence starting at 12FFE in unpatched output. // CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 13FFE in unpatched output. @@ -19,6 +21,10 @@ // CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 17FFE in unpatched output. // CHECK-NEXT: ld.lld: detected cortex-a8-657419 erratum sequence starting at 18FFE in unpatched output. +/// We do not detect errors when doing a relocatable link as we don't know what +/// the final addresses are. +// CHECK-RELOCATABLE-LLD-NOT: ld.lld: detected cortex-a8-657419 erratum sequence + /// Basic tests for the -fix-cortex-a8 erratum fix. The full details of the /// erratum and the patch are in ARMA8ErrataFix.cpp . The test creates an /// instance of the erratum every 4KiB (32-bit non-branch, followed by 32-bit @@ -50,6 +56,10 @@ // CALLSITE1: 00012ffa target: // CALLSITE1-NEXT: 12ffa: nop.w // CALLSITE1-NEXT: 12ffe: b.w #28674 +/// Expect no patch when doing a relocatable link ld -r. +// CHECK-RELOCATABLE: 00000ffa target: +// CHECK-RELOCATABLE-NEXT: ffa: nop.w +// CHECK-RELOCATABLE-NEXT: ffe: b.w #-4 .space 4088 .type target2, %function