aboutsummaryrefslogtreecommitdiffstats
path: root/test/MC/PowerPC
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2013-07-01 18:19:56 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2013-07-01 18:19:56 +0000
commit222e781d92541017c3a9c5dd40cb52e334cdb86f (patch)
tree447201dbddf7e9e60aebc77bec1abf475904a848 /test/MC/PowerPC
parent62c1baf8b58a40d37f56a5431214e6514e42970f (diff)
downloadexternal_llvm-222e781d92541017c3a9c5dd40cb52e334cdb86f.zip
external_llvm-222e781d92541017c3a9c5dd40cb52e334cdb86f.tar.gz
external_llvm-222e781d92541017c3a9c5dd40cb52e334cdb86f.tar.bz2
[PowerPC] Fix @got references to local symbols
A @got reference must always result in a relocation, so that the linker has a chance to set up the GOT entry, even if the symbol happens to be local. Add a PPCELFObjectWriter::ExplicitRelSym routine that enforces a relocation to be emitted for GOT references. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185353 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/MC/PowerPC')
-rw-r--r--test/MC/PowerPC/ppc64-fixup-explicit.s46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/MC/PowerPC/ppc64-fixup-explicit.s b/test/MC/PowerPC/ppc64-fixup-explicit.s
new file mode 100644
index 0000000..217e057
--- /dev/null
+++ b/test/MC/PowerPC/ppc64-fixup-explicit.s
@@ -0,0 +1,46 @@
+
+# RUN: llvm-mc -triple powerpc64-unknown-unknown --show-encoding %s | FileCheck %s
+
+# RUN: llvm-mc -triple powerpc64-unknown-unknown -filetype=obj %s | \
+# RUN: llvm-readobj -r | FileCheck %s -check-prefix=REL
+
+# GOT references must result in explicit relocations
+# even if the target symbol is local.
+
+target:
+
+# CHECK: addi 4, 3, target@GOT # encoding: [0x38,0x83,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target@GOT, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16 target 0x0
+ addi 4, 3, target@got
+
+# CHECK: ld 1, target@GOT(2) # encoding: [0xe8,0x22,A,0bAAAAAA00]
+# CHECK-NEXT: # fixup A - offset: 2, value: target@GOT, kind: fixup_ppc_half16ds
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_DS target 0x0
+ ld 1, target@got(2)
+
+# CHECK: addis 3, 2, target@got@ha # encoding: [0x3c,0x62,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target@got@ha, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_HA target 0x0
+ addis 3, 2, target@got@ha
+
+# CHECK: addi 4, 3, target@got@l # encoding: [0x38,0x83,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target@got@l, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_LO target 0x0
+ addi 4, 3, target@got@l
+
+# CHECK: addis 3, 2, target@got@h # encoding: [0x3c,0x62,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target@got@h, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_HI target 0x0
+ addis 3, 2, target@got@h
+
+# CHECK: lwz 1, target@got@l(3) # encoding: [0x80,0x23,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target@got@l, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_LO target 0x0
+ lwz 1, target@got@l(3)
+
+# CHECK: ld 1, target@got@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00]
+# CHECK-NEXT: # fixup A - offset: 2, value: target@got@l, kind: fixup_ppc_half16ds
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_GOT16_LO_DS target 0x0
+ ld 1, target@got@l(3)
+