aboutsummaryrefslogtreecommitdiff
path: root/test/old-elf/Mips/rel-dynamic-01-micro.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/old-elf/Mips/rel-dynamic-01-micro.test')
-rw-r--r--test/old-elf/Mips/rel-dynamic-01-micro.test201
1 files changed, 201 insertions, 0 deletions
diff --git a/test/old-elf/Mips/rel-dynamic-01-micro.test b/test/old-elf/Mips/rel-dynamic-01-micro.test
new file mode 100644
index 000000000000..56dd7dfdeccd
--- /dev/null
+++ b/test/old-elf/Mips/rel-dynamic-01-micro.test
@@ -0,0 +1,201 @@
+# REQUIRES: mips
+
+# Conditions:
+# a) Linking a non-shared executable file.
+# b) Relocations' targets are symbols defined in the shared object.
+# Check:
+# a) Emitting R_MIPS_COPY, R_MIPS_JUMP_SLOT relocations.
+# b) PLT entries creation.
+# c) STO_MIPS_PLT flag in the dynamic symbol table for symbols require
+# a pointer equality.
+#
+# RUN: yaml2obj -format=elf -docnum 1 %s > %t-so.o
+# RUN: lld -flavor old-gnu -target mipsel -shared -o %t.so %t-so.o
+# RUN: yaml2obj -format=elf -docnum 2 %s > %t-o.o
+# RUN: lld -flavor old-gnu -target mipsel -e T0 -o %t.exe %t-o.o %t.so
+# RUN: llvm-objdump -d -mattr=micromips %t.exe | FileCheck -check-prefix=DIS %s
+# RUN: llvm-readobj -dt -r %t.exe | FileCheck -check-prefix=PLT-SYM %s
+
+# DIS: Disassembly of section .plt:
+# DIS-NEXT: .plt:
+# DIS-NEXT: 4001b0: 80 79 94 07 addiupc $3, 7760
+# DIS-NEXT: 4001b4: 23 ff 00 00 lw $25, 0($3)
+# DIS-NEXT: 4001b8: 35 05 subu16 $2, $2, $3
+# DIS-NEXT: 4001ba: 25 25 srl16 $2, $2, 2
+# DIS-NEXT: 4001bc: 02 33 fe ff addiu $24, $2, -2
+# DIS-NEXT: 4001c0: ff 0d move $15, $ra
+# DIS-NEXT: 4001c2: f9 45 jalrs16 $25
+# DIS-NEXT: 4001c4: 83 0f move $gp, $3
+# DIS-NEXT: 4001c6: 00 0c nop
+
+# DIS-NEXT: 4001c8: 00 79 90 07 addiupc $2, 7744
+# DIS-NEXT: 4001cc: 22 ff 00 00 lw $25, 0($2)
+# DIS-NEXT: 4001d0: 99 45 jr16 $25
+# DIS-NEXT: 4001d2: 02 0f move $24, $2
+
+# DIS-NEXT: 4001d4: 00 79 8e 07 addiupc $2, 7736
+# DIS-NEXT: 4001d8: 22 ff 00 00 lw $25, 0($2)
+# DIS-NEXT: 4001dc: 99 45 jr16 $25
+# DIS-NEXT: 4001de: 02 0f move $24, $2
+
+# PLT-SYM: Relocations [
+# PLT-SYM-NEXT: Section (5) .rel.dyn {
+# PLT-SYM-NEXT: 0x402020 R_MIPS_COPY D1 0x0
+# PLT-SYM-NEXT: }
+# PLT-SYM-NEXT: Section (6) .rel.plt {
+# PLT-SYM-NEXT: 0x402008 R_MIPS_JUMP_SLOT T3 0x0
+# PLT-SYM-NEXT: 0x40200C R_MIPS_JUMP_SLOT T1 0x0
+# PLT-SYM-NEXT: }
+# PLT-SYM-NEXT: ]
+
+# PLT-SYM: DynamicSymbols [
+# PLT-SYM-NEXT: Symbol {
+# PLT-SYM-NEXT: Name: @ (0)
+# PLT-SYM-NEXT: Value: 0x0
+# PLT-SYM-NEXT: Size: 0
+# PLT-SYM-NEXT: Binding: Local (0x0)
+# PLT-SYM-NEXT: Type: None (0x0)
+# PLT-SYM-NEXT: Other: 0
+# PLT-SYM-NEXT: Section: Undefined (0x0)
+# PLT-SYM-NEXT: }
+# PLT-SYM-NEXT: Symbol {
+# PLT-SYM-NEXT: Name: D1@ (1)
+# PLT-SYM-NEXT: Value: 0x{{[0-9A-F]+}}
+# PLT-SYM-NEXT: Size: 8
+# PLT-SYM-NEXT: Binding: Global (0x1)
+# PLT-SYM-NEXT: Type: Object (0x1)
+# PLT-SYM-NEXT: Other: 0
+# PLT-SYM-NEXT: Section: .bss
+# PLT-SYM-NEXT: }
+# PLT-SYM-NEXT: Symbol {
+# PLT-SYM-NEXT: Name: T1@ (4)
+# PLT-SYM-NEXT: Value: 0x{{[0-9A-F]+}}
+# PLT-SYM-NEXT: Size: 0
+# PLT-SYM-NEXT: Binding: Global (0x1)
+# PLT-SYM-NEXT: Type: Function (0x2)
+# PLT-SYM-NEXT: Other: 8
+# PLT-SYM-NEXT: Section: Undefined (0x0)
+# PLT-SYM-NEXT: }
+# PLT-SYM-NEXT: Symbol {
+# PLT-SYM-NEXT: Name: T3@ (7)
+# PLT-SYM-NEXT: Value: 0x0
+# PLT-SYM-NEXT: Size: 0
+# PLT-SYM-NEXT: Binding: Global (0x1)
+# PLT-SYM-NEXT: Type: Function (0x2)
+# PLT-SYM-NEXT: Other: 0
+# PLT-SYM-NEXT: Section: Undefined (0x0)
+# PLT-SYM-NEXT: }
+# PLT-SYM-NEXT: ]
+
+# so.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32,
+ EF_MIPS_ARCH_32R2, EF_MIPS_MICROMIPS]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 0x0C
+ AddressAlign: 16
+ Flags: [SHF_EXECINSTR, SHF_ALLOC]
+
+- Name: .data
+ Type: SHT_PROGBITS
+ Size: 0x08
+ AddressAlign: 16
+ Flags: [SHF_WRITE, SHF_ALLOC]
+
+Symbols:
+ Global:
+ - Name: T1
+ Section: .text
+ Type: STT_FUNC
+ Value: 0x0
+ Size: 4
+ Other: [ STO_MIPS_MICROMIPS ]
+ - Name: T3
+ Section: .text
+ Type: STT_FUNC
+ Value: 0x8
+ Size: 4
+ Other: [ STO_MIPS_MICROMIPS ]
+ - Name: D1
+ Section: .data
+ Type: STT_OBJECT
+ Value: 0x0
+ Size: 8
+
+# o.o
+---
+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
+ Size: 0x08
+ AddressAlign: 16
+ Flags: [SHF_EXECINSTR, SHF_ALLOC]
+
+- Name: .data
+ Type: SHT_PROGBITS
+ Size: 0x08
+ AddressAlign: 16
+ Flags: [SHF_WRITE, SHF_ALLOC]
+
+- Name: .rel.text
+ Type: SHT_REL
+ Info: .text
+ AddressAlign: 4
+ Relocations:
+ - Offset: 0x04
+ Symbol: T3
+ Type: R_MICROMIPS_26_S1
+
+- Name: .rel.data
+ Type: SHT_REL
+ Info: .data
+ AddressAlign: 4
+ Relocations:
+ - Offset: 0x00
+ Symbol: T1
+ Type: R_MICROMIPS_HI16
+ - Offset: 0x00
+ Symbol: T1
+ Type: R_MICROMIPS_LO16
+ - Offset: 0x04
+ Symbol: D1
+ Type: R_MICROMIPS_HI16
+ - Offset: 0x04
+ Symbol: D1
+ Type: R_MICROMIPS_LO16
+
+Symbols:
+ Global:
+ - Name: T0
+ Section: .text
+ Type: STT_FUNC
+ Value: 0x0
+ Size: 8
+ Other: [ STO_MIPS_MICROMIPS ]
+ - Name: T1
+ Type: STT_FUNC
+ - Name: T3
+ Type: STT_FUNC
+ - Name: D0
+ Section: .data
+ Type: STT_OBJECT
+ Value: 0x0
+ Size: 8
+ - Name: D1
+ Type: STT_OBJECT
+...