summaryrefslogtreecommitdiff
path: root/test/elf/Mips/pc23-range.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/elf/Mips/pc23-range.test')
-rw-r--r--test/elf/Mips/pc23-range.test56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/elf/Mips/pc23-range.test b/test/elf/Mips/pc23-range.test
new file mode 100644
index 0000000000000..7166176c46288
--- /dev/null
+++ b/test/elf/Mips/pc23-range.test
@@ -0,0 +1,56 @@
+# Check that LLD shows an error if ADDIUPC immediate is out of range.
+
+# RUN: yaml2obj -format=elf %s > %t-obj
+# RUN: lld -flavor gnu -target mipsel -o %t-exe %t-obj 2>&1 | FileCheck %s
+
+# CHECK: The addiupc instruction immediate 0x02000008 is out of range
+
+!ELF
+FileHeader: !FileHeader
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [ EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2,
+ EF_MIPS_MICROMIPS ]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Content: "0000000080780100"
+# ^ PC23: 1 << 2 = 4 => T0 + 4 - 4 = T0
+ AddressAlign: 16
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+
+- Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+ AddressAlign: 0x04
+ Size: 0x4000000
+
+- Name: .rel.text
+ Type: SHT_REL
+ Info: .text
+ AddressAlign: 4
+ Relocations:
+ - Offset: 4
+ Symbol: T0
+ Type: R_MICROMIPS_PC23_S2
+
+Symbols:
+ Global:
+ - Name: __start
+ Section: .text
+ Type: STT_FUNC
+ Size: 8
+ Other: [ STO_MIPS_MICROMIPS ]
+ - Name: TZ
+ Section: .data
+ Type: STT_FUNC
+ Value: 0
+ Size: 0x2000000
+ - Name: T0
+ Section: .data
+ Type: STT_FUNC
+ Value: 0x2000000
+ Size: 4