summaryrefslogtreecommitdiff
path: root/test/elf/Mips/hilo16-2.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/elf/Mips/hilo16-2.test')
-rw-r--r--test/elf/Mips/hilo16-2.test68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/elf/Mips/hilo16-2.test b/test/elf/Mips/hilo16-2.test
new file mode 100644
index 0000000000000..68cb26eec7881
--- /dev/null
+++ b/test/elf/Mips/hilo16-2.test
@@ -0,0 +1,68 @@
+# REQUIRES: mips
+
+# Check handling of HI16 and LO16 relocations for regular symbol.
+#
+# R_MIPS_HI16: (AHL + S) - (short)(AHL + S)
+# R_MIPS_LO16: AHL + S
+# where AHL = (AHI << 16) + ALO
+#
+# RUN: llvm-mc -triple=mipsel -filetype=obj -o=%t-obj %s
+# RUN: lld -flavor gnu -target mipsel -e glob1 -o %t-exe %t-obj
+# RUN: llvm-objdump -t -disassemble %t-exe | FileCheck %s
+
+# CHECK: Disassembly of section .text:
+# CHECK: glob1:
+# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64
+# CHECK-NEXT: {{[0-9a-f]+}}: 71 01 08 85 lh $8, 369($8)
+# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64
+# CHECK-NEXT: {{[0-9a-f]+}}: 6f 01 08 85 lh $8, 367($8)
+# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64
+# CHECK-NEXT: {{[0-9a-f]+}}: 6f 03 08 85 lh $8, 879($8)
+# CHECK-NEXT: {{[0-9a-f]+}}: 40 00 08 3c lui $8, 64
+# CHECK-NEXT: {{[0-9a-f]+}}: 71 ff 08 85 lh $8, -143($8)
+# CHECK-NEXT: {{[0-9a-f]+}}: 42 00 08 3c lui $8, 66
+# CHECK-NEXT: {{[0-9a-f]+}}: 6f 01 08 85 lh $8, 367($8)
+# CHECK-NEXT: {{[0-9a-f]+}}: 3e 00 08 3c lui $8, 62
+# CHECK-NEXT: {{[0-9a-f]+}}: 71 01 08 85 lh $8, 369($8)
+# CHECK-NEXT: {{[0-9a-f]+}}: 40 02 08 3c lui $8, 576
+# CHECK-NEXT: {{[0-9a-f]+}}: 6f 01 08 85 lh $8, 367($8)
+# CHECK-NEXT: {{[0-9a-f]+}}: 40 fe 08 3c lui $8, 65088
+# CHECK-NEXT: {{[0-9a-f]+}}: 71 01 08 85 lh $8, 369($8)
+
+# CHECK: SYMBOL TABLE:
+# CHECK: {{[0-9a-f]+}} g F .text 00000040 glob1
+# CHECK: {{[0-9a-f]+}} g F .text 00000004 glob2
+
+ .global glob1
+ .ent glob1
+glob1:
+ lui $t0,%hi(glob2+0x1)
+ lh $t0,%lo(glob2+0x1)($t0)
+
+ lui $t0,%hi(glob2+(-0x1))
+ lh $t0,%lo(glob2+(-0x1))($t0)
+
+ lui $t0,%hi(glob2+0x1ff)
+ lh $t0,%lo(glob2+0x1ff)($t0)
+
+ lui $t0,%hi(glob2+(-0x1ff))
+ lh $t0,%lo(glob2+(-0x1ff))($t0)
+
+ lui $t0,%hi(glob2+0x1ffff)
+ lh $t0,%lo(glob2+0x1ffff)($t0)
+
+ lui $t0,%hi(glob2+(-0x1ffff))
+ lh $t0,%lo(glob2+(-0x1ffff))($t0)
+
+ lui $t0,%hi(glob2+0x1ffffff) # truncate
+ lh $t0,%lo(glob2+0x1ffffff)($t0)
+
+ lui $t0,%hi(glob2+(-0x1ffffff)) # truncate
+ lh $t0,%lo(glob2+(-0x1ffffff))($t0)
+ .end glob1
+
+ .global glob2
+ .ent glob2
+glob2:
+ nop
+ .end glob2