Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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 llvm-svn: 254840
- Loading branch information
Igor Kudrin
committed
Dec 5, 2015
1 parent
a569e24
commit cfe47f5
Showing
18 changed files
with
167 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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",@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",@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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 - . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 - . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 - . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters