[lld] r264322 - Simplify AArch64 isRelRelative

Adhemerval Zanella via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 12:12:14 PDT 2016


Author: azanella
Date: Thu Mar 24 14:12:14 2016
New Revision: 264322

URL: http://llvm.org/viewvc/llvm-project?rev=264322&view=rev
Log:
Simplify AArch64 isRelRelative

This patch simplifies the isRelRelative for AArch64 and add the missing
ones for bootstrap and test-suite.  It also adds more testing for
shared object creation.

Modified:
    lld/trunk/ELF/Target.cpp
    lld/trunk/test/ELF/aarch64-relative.s

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=264322&r1=264321&r2=264322&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Mar 24 14:12:14 2016
@@ -1223,12 +1223,25 @@ AArch64TargetInfo::AArch64TargetInfo() {
 }
 
 bool AArch64TargetInfo::isRelRelative(uint32_t Type) const {
-  return Type == R_AARCH64_PREL32 || Type == R_AARCH64_ADR_PREL_PG_HI21 ||
-         Type == R_AARCH64_LDST8_ABS_LO12_NC ||
-         Type == R_AARCH64_LDST32_ABS_LO12_NC ||
-         Type == R_AARCH64_LDST64_ABS_LO12_NC ||
-         Type == R_AARCH64_ADD_ABS_LO12_NC || Type == R_AARCH64_CALL26 ||
-         Type == R_AARCH64_CONDBR19;
+  switch (Type) {
+  default:
+    return false;
+  case R_AARCH64_PREL32:
+  case R_AARCH64_ADR_PREL_LO21:
+  case R_AARCH64_ADR_PREL_PG_HI21:
+  case R_AARCH64_ADR_GOT_PAGE:
+  case R_AARCH64_LDST8_ABS_LO12_NC:
+  case R_AARCH64_LDST16_ABS_LO12_NC:
+  case R_AARCH64_LDST32_ABS_LO12_NC:
+  case R_AARCH64_LDST64_ABS_LO12_NC:
+  case R_AARCH64_LDST128_ABS_LO12_NC:
+  case R_AARCH64_ADD_ABS_LO12_NC:
+  case R_AARCH64_CALL26:
+  case R_AARCH64_JUMP26:
+  case R_AARCH64_CONDBR19:
+  case R_AARCH64_TSTBR14:
+    return true;
+  }
 }
 
 bool AArch64TargetInfo::isTlsGlobalDynamicRel(uint32_t Type) const {

Modified: lld/trunk/test/ELF/aarch64-relative.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-relative.s?rev=264322&r1=264321&r2=264322&view=diff
==============================================================================
--- lld/trunk/test/ELF/aarch64-relative.s (original)
+++ lld/trunk/test/ELF/aarch64-relative.s Thu Mar 24 14:12:14 2016
@@ -2,19 +2,25 @@
 // RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %t.o
 // RUN: ld.lld %t.o -o %t.so -shared
 // RUN: llvm-readobj -r %t.so | FileCheck %s
-        adrp    x8, .Lfoo
-        strb    w9, [x8, :lo12:.Lfoo]
-        ldr     w0, [x8, :lo12:.Lfoo]
-        ldr     x0, [x8, :lo12:.Lfoo]
-        add     x0, x0, :lo12:.Lfoo
-        bl      .Lfoo
-        b.eq    .Lfoo
 
-        .data
-        .Lfoo:
+  adr     x8, .Lfoo                 // R_AARCH64_ADR_PREL_LO21
+  adrp    x8, .Lfoo                 // R_AARCH64_ADR_PREL_PG_HI21
+  strb    w9, [x8, :lo12:.Lfoo]     // R_AARCH64_LDST8_ABS_LO12_NC
+  ldr     h17, [x19, :lo12:.Lfoo]   // R_AARCH64_LDST16_ABS_LO12_NC
+  ldr     w0, [x8, :lo12:.Lfoo]     // R_AARCH64_LDST32_ABS_LO12_NC
+  ldr     x0, [x8, :lo12:.Lfoo]     // R_AARCH64_LDST64_ABS_LO12_NC
+  ldr     q20, [x19, #:lo12:.Lfoo]  // R_AARCH64_LDST128_ABS_LO12_NC
+  add     x0, x0, :lo12:.Lfoo       // R_AARCH64_ADD_ABS_LO12_NC
+  bl      .Lfoo                     // R_AARCH64_CALL26
+  b       .Lfoo                     // R_AARCH64_JUMP26
+  beq     .Lfoo                     // R_AARCH64_CONDBR19
+.Lbranch:
+  tbz     x1, 7, .Lbranch           // R_AARCH64_TSTBR14
+.data
+.Lfoo:
 
-        .rodata
-        .long .Lfoo - .
+.rodata
+.long .Lfoo - .
 
 // CHECK:      Relocations [
 // CHECK-NEXT: ]




More information about the llvm-commits mailing list