[lld] r254840 - [ELF/AArch64] Allow only valid dynamic relocations in the output.

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 4 22:20:25 PST 2015


Author: ikudrin
Date: Sat Dec  5 00:20:24 2015
New Revision: 254840

URL: http://llvm.org/viewvc/llvm-project?rev=254840&view=rev
Log:
[ELF/AArch64] Allow only valid dynamic relocations in the output.

All relocations, which cannot be handled by the dynamic linker,
cause a linking error "rebuild with -fPIC".

Differential revision: http://reviews.llvm.org/D15193

Added:
    lld/trunk/test/ELF/aarch64-fpic-abs16.s
    lld/trunk/test/ELF/aarch64-fpic-add_abs_lo12_nc.s
    lld/trunk/test/ELF/aarch64-fpic-adr_prel_lo21.s
    lld/trunk/test/ELF/aarch64-fpic-adr_prel_pg_hi21.s
    lld/trunk/test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s
    lld/trunk/test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s
    lld/trunk/test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s
    lld/trunk/test/ELF/aarch64-fpic-prel16.s
    lld/trunk/test/ELF/aarch64-fpic-prel32.s
    lld/trunk/test/ELF/aarch64-fpic-prel64.s
Modified:
    lld/trunk/ELF/Target.cpp
    lld/trunk/test/ELF/aarch64-abs16.s
    lld/trunk/test/ELF/aarch64-abs32.s
    lld/trunk/test/ELF/aarch64-data-relocs.s
    lld/trunk/test/ELF/aarch64-hi21-error.s
    lld/trunk/test/ELF/aarch64-lo21-error.s
    lld/trunk/test/ELF/aarch64-prel16.s
    lld/trunk/test/ELF/aarch64-prel32.s

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=254840&r1=254839&r2=254840&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Sat Dec  5 00:20:24 2015
@@ -143,6 +143,7 @@ public:
 class AArch64TargetInfo final : public TargetInfo {
 public:
   AArch64TargetInfo();
+  unsigned getDynReloc(unsigned Type) const override;
   unsigned getPltRefReloc(unsigned Type) const override;
   void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const override;
   void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,
@@ -907,6 +908,14 @@ AArch64TargetInfo::AArch64TargetInfo() {
   PltZeroEntrySize = 32;
 }
 
+unsigned AArch64TargetInfo::getDynReloc(unsigned Type) const {
+  if (Type == R_AARCH64_ABS32 || Type == R_AARCH64_ABS64)
+    return Type;
+  StringRef S = getELFRelocationTypeName(EM_AARCH64, Type);
+  error("Relocation " + S + " cannot be used when making a shared object; "
+                            "recompile with -fPIC.");
+}
+
 unsigned AArch64TargetInfo::getPltRefReloc(unsigned Type) const { return Type; }
 
 void AArch64TargetInfo::writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const {

Modified: lld/trunk/test/ELF/aarch64-abs16.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-abs16.s?rev=254840&r1=254839&r2=254840&view=diff
==============================================================================
--- lld/trunk/test/ELF/aarch64-abs16.s (original)
+++ lld/trunk/test/ELF/aarch64-abs16.s Sat Dec  5 00:20:24 2015
@@ -4,22 +4,24 @@
 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs256.s -o %t256.o
 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs257.s -o %t257.o
 
+.globl _start
+_start:
 .data
   .hword foo + 0xfeff
   .hword foo - 0x8100
 
-// RUN: ld.lld -shared %t.o %t256.o -o %t.so
-// RUN: llvm-objdump -s -section=.data %t.so | FileCheck %s
+// RUN: ld.lld %t.o %t256.o -o %t2
+// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
 
 // CHECK: Contents of section .data:
-// 1090: S = 0x100, A = 0xfeff
-//       S + A = 0xffff
-// 1092: S = 0x100, A = -0x8100
-//       S + A = 0x8000
-// CHECK-NEXT: 1090 ffff0080
+// 11000: S = 0x100, A = 0xfeff
+//        S + A = 0xffff
+// 11002: S = 0x100, A = -0x8100
+//        S + A = 0x8000
+// CHECK-NEXT: 11000 ffff0080
 
-// RUN: not ld.lld -shared %t.o %t255.o -o %t.so
+// RUN: not ld.lld %t.o %t255.o -o %t2
 //   | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld -shared %t.o %t257.o -o %t.so
+// RUN: not ld.lld %t.o %t257.o -o %t2
 //   | FileCheck %s --check-prefix=OVERFLOW
 // OVERFLOW: Relocation R_AARCH64_ABS16 out of range

Modified: lld/trunk/test/ELF/aarch64-abs32.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-abs32.s?rev=254840&r1=254839&r2=254840&view=diff
==============================================================================
--- lld/trunk/test/ELF/aarch64-abs32.s (original)
+++ lld/trunk/test/ELF/aarch64-abs32.s Sat Dec  5 00:20:24 2015
@@ -4,22 +4,24 @@
 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs256.s -o %t256.o
 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs257.s -o %t257.o
 
+.globl _start
+_start:
 .data
   .word foo + 0xfffffeff
   .word foo - 0x80000100
 
-// RUN: ld.lld -shared %t.o %t256.o -o %t.so
-// RUN: llvm-objdump -s -section=.data %t.so | FileCheck %s
+// RUN: ld.lld %t.o %t256.o -o %t2
+// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
 
 // CHECK: Contents of section .data:
-// 1090: S = 0x100, A = 0xfffffeff
-//       S + A = 0xffffffff
-// 1094: S = 0x100, A = -0x80000100
-//       S + A = 0x80000000
-// CHECK-NEXT: 1090 ffffffff 00000080
+// 11000: S = 0x100, A = 0xfffffeff
+//        S + A = 0xffffffff
+// 11004: S = 0x100, A = -0x80000100
+//        S + A = 0x80000000
+// CHECK-NEXT: 11000 ffffffff 00000080
 
-// RUN: not ld.lld -shared %t.o %t255.o -o %t.so
+// RUN: not ld.lld %t.o %t255.o -o %t2
 //   | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld -shared %t.o %t257.o -o %t.so
+// RUN: not ld.lld %t.o %t257.o -o %t2
 //   | FileCheck %s --check-prefix=OVERFLOW
 // OVERFLOW: Relocation R_AARCH64_ABS32 out of range

Modified: lld/trunk/test/ELF/aarch64-data-relocs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-data-relocs.s?rev=254840&r1=254839&r2=254840&view=diff
==============================================================================
--- lld/trunk/test/ELF/aarch64-data-relocs.s (original)
+++ lld/trunk/test/ELF/aarch64-data-relocs.s Sat Dec  5 00:20:24 2015
@@ -1,20 +1,23 @@
 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t
-// RUN: ld.lld -shared %t -o %t2
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs256.s -o %t256.o
+// RUN: ld.lld %t %t256.o -o %t2
 // RUN: llvm-objdump -s %t2 | FileCheck %s
 // REQUIRES: aarch64
 
+.globl _start
+_start:
 .section .R_AARCH64_ABS64, "ax", at progbits
-  .xword sym + 36
+  .xword foo + 0x24
 
+// S = 0x100, A = 0x24
+// S + A = 0x124
 // CHECK: Contents of section .R_AARCH64_ABS64:
-// CHECK-NEXT: 1000 24000000 00000000
-//                  ^-- A = 0x24
+// CHECK-NEXT: 11000 24010000 00000000
 
 .section .R_AARCH64_PREL64, "ax", at progbits
-  .xword sym - . + 36
+  .xword foo - . + 0x24
 
-// S + A = 0x24
-// P = 0x1008
-// SA - P = 0xfffffffffffff01c
+// S = 0x100, A = 0x24, P = 0x11008
+// S + A - P = 0xfffffffffffef11c
 // CHECK: Contents of section .R_AARCH64_PREL64:
-// CHECK-NEXT: 1008 1cf0ffff ffffffff
+// CHECK-NEXT: 11008 1cf1feff ffffffff

Added: lld/trunk/test/ELF/aarch64-fpic-abs16.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-fpic-abs16.s?rev=254840&view=auto
==============================================================================
--- lld/trunk/test/ELF/aarch64-fpic-abs16.s (added)
+++ lld/trunk/test/ELF/aarch64-fpic-abs16.s Sat Dec  5 00:20:24 2015
@@ -0,0 +1,7 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_ABS16 cannot be used when making a shared object; recompile with -fPIC.
+
+.data
+  .hword foo

Added: lld/trunk/test/ELF/aarch64-fpic-add_abs_lo12_nc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-fpic-add_abs_lo12_nc.s?rev=254840&view=auto
==============================================================================
--- lld/trunk/test/ELF/aarch64-fpic-add_abs_lo12_nc.s (added)
+++ lld/trunk/test/ELF/aarch64-fpic-add_abs_lo12_nc.s Sat Dec  5 00:20:24 2015
@@ -0,0 +1,10 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_ADD_ABS_LO12_NC cannot be used when making a shared object; recompile with -fPIC.
+
+  add x0, x0, :lo12:dat
+.data
+.globl dat
+dat:
+  .word 0

Added: lld/trunk/test/ELF/aarch64-fpic-adr_prel_lo21.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-fpic-adr_prel_lo21.s?rev=254840&view=auto
==============================================================================
--- lld/trunk/test/ELF/aarch64-fpic-adr_prel_lo21.s (added)
+++ lld/trunk/test/ELF/aarch64-fpic-adr_prel_lo21.s Sat Dec  5 00:20:24 2015
@@ -0,0 +1,10 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_ADR_PREL_LO21 cannot be used when making a shared object; recompile with -fPIC.
+
+  adr x0, dat
+.data
+.globl dat
+dat:
+  .word 0

Added: lld/trunk/test/ELF/aarch64-fpic-adr_prel_pg_hi21.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-fpic-adr_prel_pg_hi21.s?rev=254840&view=auto
==============================================================================
--- lld/trunk/test/ELF/aarch64-fpic-adr_prel_pg_hi21.s (added)
+++ lld/trunk/test/ELF/aarch64-fpic-adr_prel_pg_hi21.s Sat Dec  5 00:20:24 2015
@@ -0,0 +1,10 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_ADR_PREL_PG_HI21 cannot be used when making a shared object; recompile with -fPIC.
+
+  adrp x0, dat
+.data
+.globl dat
+dat:
+  .word 0

Added: lld/trunk/test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s?rev=254840&view=auto
==============================================================================
--- lld/trunk/test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s (added)
+++ lld/trunk/test/ELF/aarch64-fpic-ldst32_abs_lo12_nc.s Sat Dec  5 00:20:24 2015
@@ -0,0 +1,10 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_LDST32_ABS_LO12_NC cannot be used when making a shared object; recompile with -fPIC.
+
+  ldr s4, [x0, :lo12:dat]
+.data
+.globl dat
+dat:
+  .word 0

Added: lld/trunk/test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s?rev=254840&view=auto
==============================================================================
--- lld/trunk/test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s (added)
+++ lld/trunk/test/ELF/aarch64-fpic-ldst64_abs_lo12_nc.s Sat Dec  5 00:20:24 2015
@@ -0,0 +1,10 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_LDST64_ABS_LO12_NC cannot be used when making a shared object; recompile with -fPIC.
+
+  ldr x0, [x0, :lo12:dat]
+.data
+.globl dat
+dat:
+  .word 0

Added: lld/trunk/test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s?rev=254840&view=auto
==============================================================================
--- lld/trunk/test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s (added)
+++ lld/trunk/test/ELF/aarch64-fpic-ldst8_abs_lo12_nc.s Sat Dec  5 00:20:24 2015
@@ -0,0 +1,10 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_LDST8_ABS_LO12_NC cannot be used when making a shared object; recompile with -fPIC.
+
+  ldrsb x0, [x1, :lo12:dat]
+.data
+.globl dat
+dat:
+  .word 0

Added: lld/trunk/test/ELF/aarch64-fpic-prel16.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-fpic-prel16.s?rev=254840&view=auto
==============================================================================
--- lld/trunk/test/ELF/aarch64-fpic-prel16.s (added)
+++ lld/trunk/test/ELF/aarch64-fpic-prel16.s Sat Dec  5 00:20:24 2015
@@ -0,0 +1,7 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_PREL16 cannot be used when making a shared object; recompile with -fPIC.
+
+.data
+  .hword foo - .

Added: lld/trunk/test/ELF/aarch64-fpic-prel32.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-fpic-prel32.s?rev=254840&view=auto
==============================================================================
--- lld/trunk/test/ELF/aarch64-fpic-prel32.s (added)
+++ lld/trunk/test/ELF/aarch64-fpic-prel32.s Sat Dec  5 00:20:24 2015
@@ -0,0 +1,7 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_PREL32 cannot be used when making a shared object; recompile with -fPIC.
+
+.data
+  .word foo - .

Added: lld/trunk/test/ELF/aarch64-fpic-prel64.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-fpic-prel64.s?rev=254840&view=auto
==============================================================================
--- lld/trunk/test/ELF/aarch64-fpic-prel64.s (added)
+++ lld/trunk/test/ELF/aarch64-fpic-prel64.s Sat Dec  5 00:20:24 2015
@@ -0,0 +1,7 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %s -o %t.o
+// RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
+// CHECK: Relocation R_AARCH64_PREL64 cannot be used when making a shared object; recompile with -fPIC.
+
+.data
+  .xword foo - .

Modified: lld/trunk/test/ELF/aarch64-hi21-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-hi21-error.s?rev=254840&r1=254839&r2=254840&view=diff
==============================================================================
--- lld/trunk/test/ELF/aarch64-hi21-error.s (original)
+++ lld/trunk/test/ELF/aarch64-hi21-error.s Sat Dec  5 00:20:24 2015
@@ -1,8 +1,10 @@
 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %S/Inputs/abs.s -o %tabs
 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %s -o %t
-// RUN: not ld.lld %tabs -shared %t -o %t2 2>&1 | FileCheck %s
+// RUN: not ld.lld %tabs %t -o %t2 2>&1 | FileCheck %s
 // REQUIRES: aarch64
 
+.globl _start
+_start:
 adrp x0, big
 
 #CHECK: R_AARCH64_ADR_PREL_PG_HI21 out of range

Modified: lld/trunk/test/ELF/aarch64-lo21-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-lo21-error.s?rev=254840&r1=254839&r2=254840&view=diff
==============================================================================
--- lld/trunk/test/ELF/aarch64-lo21-error.s (original)
+++ lld/trunk/test/ELF/aarch64-lo21-error.s Sat Dec  5 00:20:24 2015
@@ -1,8 +1,10 @@
 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %S/Inputs/abs.s -o %tabs
 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %s -o %t
-// RUN: not ld.lld %tabs -shared %t -o %t2 2>&1 | FileCheck %s
+// RUN: not ld.lld %tabs %t -o %t2 2>&1 | FileCheck %s
 // REQUIRES: aarch64
 
+.globl _start
+_start:
 adr x0, big
 
 #CHECK: R_AARCH64_ADR_PREL_LO21 out of range

Modified: lld/trunk/test/ELF/aarch64-prel16.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-prel16.s?rev=254840&r1=254839&r2=254840&view=diff
==============================================================================
--- lld/trunk/test/ELF/aarch64-prel16.s (original)
+++ lld/trunk/test/ELF/aarch64-prel16.s Sat Dec  5 00:20:24 2015
@@ -4,26 +4,28 @@
 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs256.s -o %t256.o
 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs257.s -o %t257.o
 
+.globl _start
+_start:
 .data
-  .hword foo - . + 0x10f8f
-  .hword foo - . - 0x706e
+  .hword foo - . + 0x20eff
+  .hword foo - . + 0x8f02
 
-// Note: If this test fails, it is probably results from
+// Note: If this test fails, it probably happens because of
 //       the change of the address of the .data section.
 //       You may found the correct address in the aarch64_abs16.s test,
-//       if it's already fixed. Then, update addends accordingly.
-// RUN: ld.lld -shared %t.o %t256.o -o %t.so
-// RUN: llvm-objdump -s -section=.data %t.so | FileCheck %s
+//       if it is already fixed. Then, update addends accordingly.
+// RUN: ld.lld %t.o %t256.o -o %t2
+// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
 
 // CHECK: Contents of section .data:
-// 1090: S = 0x100, A = 0x10f8f, P = 0x1090
-//       S + A - P = 0xffff
-// 1092: S = 0x100, A = -0x706e, P = 0x1092
-//       S + A - P = 0x8000
-// CHECK-NEXT: 1090 ffff0080
+// 11000: S = 0x100, A = 0x20eff, P = 0x11000
+//        S + A - P = 0xffff
+// 11002: S = 0x100, A = 0x8f02, P = 0x11002
+//        S + A - P = 0x8000
+// CHECK-NEXT: 11000 ffff0080
 
-// RUN: not ld.lld -shared %t.o %t255.o -o %t.so
+// RUN: not ld.lld %t.o %t255.o -o %t2
 //   | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld -shared %t.o %t257.o -o %t.so
+// RUN: not ld.lld %t.o %t257.o -o %t2
 //   | FileCheck %s --check-prefix=OVERFLOW
 // OVERFLOW: Relocation R_AARCH64_PREL16 out of range

Modified: lld/trunk/test/ELF/aarch64-prel32.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/aarch64-prel32.s?rev=254840&r1=254839&r2=254840&view=diff
==============================================================================
--- lld/trunk/test/ELF/aarch64-prel32.s (original)
+++ lld/trunk/test/ELF/aarch64-prel32.s Sat Dec  5 00:20:24 2015
@@ -4,26 +4,28 @@
 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs256.s -o %t256.o
 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-freebsd %S/Inputs/abs257.s -o %t257.o
 
+.globl _start
+_start:
 .data
-  .word foo - . + 0x100000f8f
-  .word foo - . - 0x7ffff06c
+  .word foo - . + 0x100010eff
+  .word foo - . - 0x7ffef0fc
 
-// Note: If this test fails, it is probably results from
+// Note: If this test fails, it probably happens because of
 //       the change of the address of the .data section.
 //       You may found the correct address in the aarch64_abs32.s test,
-//       if it's already fixed. Then, update addends accordingly.
-// RUN: ld.lld -shared %t.o %t256.o -o %t.so
-// RUN: llvm-objdump -s -section=.data %t.so | FileCheck %s
+//       if it is already fixed. Then, update addends accordingly.
+// RUN: ld.lld %t.o %t256.o -o %t2
+// RUN: llvm-objdump -s -section=.data %t2 | FileCheck %s
 
 // CHECK: Contents of section .data:
-// 1090: S = 0x100, A = 0x100000f8f, P = 0x1090
-//       S + A - P = 0xffffffff
-// 1094: S = 0x100, A = -0x7ffff06c, P = 0x1094
-//       S + A - P = 0x80000000
-// CHECK-NEXT: 1090 ffffffff 00000080
+// 11000: S = 0x100, A = 0x100010eff, P = 0x11000
+//        S + A - P = 0xffffffff
+// 11004: S = 0x100, A = -0x7ffef0fc, P = 0x11004
+//        S + A - P = 0x80000000
+// CHECK-NEXT: 11000 ffffffff 00000080
 
-// RUN: not ld.lld -shared %t.o %t255.o -o %t.so
+// RUN: not ld.lld %t.o %t255.o -o %t2
 //   | FileCheck %s --check-prefix=OVERFLOW
-// RUN: not ld.lld -shared %t.o %t257.o -o %t.so
+// RUN: not ld.lld %t.o %t257.o -o %t2
 //   | FileCheck %s --check-prefix=OVERFLOW
 // OVERFLOW: Relocation R_AARCH64_PREL32 out of range




More information about the llvm-commits mailing list