[lld] e727f39 - [LLD][ELF][ARM] Don't apply --fix-cortex-a8 to relocatable links.

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 03:04:55 PST 2020


Author: Peter Smith
Date: 2020-01-22T11:03:40Z
New Revision: e727f39ec0b15ee8aec52e83467299d79b2ea8f5

URL: https://github.com/llvm/llvm-project/commit/e727f39ec0b15ee8aec52e83467299d79b2ea8f5
DIFF: https://github.com/llvm/llvm-project/commit/e727f39ec0b15ee8aec52e83467299d79b2ea8f5.diff

LOG: [LLD][ELF][ARM] Don't apply --fix-cortex-a8 to relocatable links.

The --fix-cortex-a8 is sensitive to alignment and the precise destination
of branch instructions. These are not knowable at relocatable link time. We
follow GNU ld and the --fix-cortex-a53-843419 (D72968) by not patching the
code when there is a relocatable link.

Differential Revision: https://reviews.llvm.org/D73100

Added: 
    

Modified: 
    lld/ELF/Driver.cpp
    lld/test/ELF/arm-fix-cortex-a8-recognize.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 28128146a599..61d4247fbf53 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -876,7 +876,8 @@ static void readConfigs(opt::InputArgList &args) {
   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
index 9971f15d884a..d56ed1934efe 100644
--- 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 @@ target:
 // 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


        


More information about the llvm-commits mailing list