[lld] c81fe34 - [lld][ELF] Don't apply --fix-cortex-a53-843419 to relocatable links.

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 15:38:21 PST 2020


Author: Eli Friedman
Date: 2020-01-20T15:27:41-08:00
New Revision: c81fe34718d7bc4088c849b507cc7038e043f1bc

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

LOG: [lld][ELF] Don't apply --fix-cortex-a53-843419 to relocatable links.

The code doesn't apply the fix correctly to relocatable links. I could
try to fix the code that applies the fix, but it's pointless: we don't
actually know what the offset will be in the final executable. So just
ignore the flag for relocatable links.

Issue discovered building Android.

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

Added: 
    

Modified: 
    lld/ELF/Driver.cpp
    lld/test/ELF/aarch64-cortex-a53-843419-recognize.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 23da749d3078..28128146a599 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -874,7 +874,8 @@ static void readConfigs(opt::InputArgList &args) {
       args.hasFlag(OPT_export_dynamic, OPT_no_export_dynamic, false);
   config->filterList = args::getStrings(args, OPT_filter);
   config->fini = args.getLastArgValue(OPT_fini, "_fini");
-  config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419);
+  config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419) &&
+                                     !args.hasArg(OPT_relocatable);
   config->fixCortexA8 = args.hasArg(OPT_fix_cortex_a8);
   config->forceBTI = hasZOption(args, "force-bti");
   config->gcSections = args.hasFlag(OPT_gc_sections, OPT_no_gc_sections, false);

diff  --git a/lld/test/ELF/aarch64-cortex-a53-843419-recognize.s b/lld/test/ELF/aarch64-cortex-a53-843419-recognize.s
index 0a0e1138e797..25e864f8e607 100644
--- a/lld/test/ELF/aarch64-cortex-a53-843419-recognize.s
+++ b/lld/test/ELF/aarch64-cortex-a53-843419-recognize.s
@@ -4,6 +4,8 @@
 // RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 | FileCheck %s -check-prefixes=CHECK,CHECK-FIX
 // RUN: ld.lld %t.o -z separate-code -o %t3
 // RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t3 | FileCheck %s -check-prefixes=CHECK,CHECK-NOFIX
+// RUN: ld.lld -fix-cortex-a53-843419 -r -z separate-code %t.o -o %t4
+// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t4 | FileCheck %s -check-prefixes=CHECK-RELOCATABLE
 // Test cases for Cortex-A53 Erratum 843419
 // See ARM-EPM-048406 Cortex_A53_MPCore_Software_Developers_Errata_Notice.pdf
 // for full erratum details.
@@ -33,6 +35,12 @@
 // CHECK-FIX:     212000:        03 c8 00 14     b       #204812
 // CHECK-NOFIX:   212000:        00 00 40 f9     ldr             x0, [x0]
 // CHECK-NEXT:    212004:        c0 03 5f d6     ret
+// CHECK-RELOCATABLE: t3_ff8_ldr:
+// CHECK-RELOCATABLE-NEXT:    ff8:        00 00 00 90     adrp    x0, #0
+// CHECK-RELOCATABLE-NEXT:    ffc:        21 00 40 f9     ldr             x1, [x1]
+// CHECK-RELOCATABLE-NEXT:   1000:        00 00 40 f9     ldr             x0, [x0]
+// CHECK-RELOCATABLE-NEXT:   1004:        c0 03 5f d6     ret
+
         .section .text.01, "ax", %progbits
         .balign 4096
         .globl t3_ff8_ldr


        


More information about the llvm-commits mailing list