aboutsummaryrefslogtreecommitdiff
path: root/test/ELF/arm-sbrel32.s
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-05-22 19:44:12 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-05-22 19:44:12 +0000
commitc53addf38e24e4dafe992aafb3ae928bfa8fdb0a (patch)
tree5a8f08e745d2dbfdd66c9e4838a8b7eeb7f0453f /test/ELF/arm-sbrel32.s
parent2dcc0c5ee66570f02392d1fbf29f573fa47258f8 (diff)
Notes
Diffstat (limited to 'test/ELF/arm-sbrel32.s')
-rw-r--r--test/ELF/arm-sbrel32.s39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/ELF/arm-sbrel32.s b/test/ELF/arm-sbrel32.s
new file mode 100644
index 000000000000..7f12717195a9
--- /dev/null
+++ b/test/ELF/arm-sbrel32.s
@@ -0,0 +1,39 @@
+// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: ld.lld %t -o %t2 2>&1
+// RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s
+// REQUIRES: arm
+
+// Test the R_ARM_SBREL32 relocation which calculates the offset of the Symbol
+// from the static base. We define the static base to be the address of the
+// segment containing the symbol
+ .text
+ .syntax unified
+
+ .globl _start
+ .p2align 2
+ .type _start,%function
+_start:
+ .fnstart
+ bx lr
+
+ .long foo(sbrel)
+ .long foo2(sbrel)
+ .long foo3(sbrel)
+ .long foo4(sbrel)
+// RW segment starts here
+ .data
+ .p2align 4
+foo: .word 10
+foo2: .word 20
+
+ .bss
+foo3: .space 4
+foo4: .space 4
+
+// CHECK: Disassembly of section .text:
+// CHECK-NEXT: _start:
+// CHECK-NEXT: 11000: 1e ff 2f e1 bx lr
+// CHECK: 11004: 00 00 00 00 .word 0x00000000
+// CHECK-NEXT: 11008: 04 00 00 00 .word 0x00000004
+// CHECK-NEXT: 1100c: 08 00 00 00 .word 0x00000008
+// CHECK-NEXT: 11010: 0c 00 00 00 .word 0x0000000c