summaryrefslogtreecommitdiff
path: root/test/elf/Mips/rel-dynamic-05.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/elf/Mips/rel-dynamic-05.test')
-rw-r--r--test/elf/Mips/rel-dynamic-05.test188
1 files changed, 188 insertions, 0 deletions
diff --git a/test/elf/Mips/rel-dynamic-05.test b/test/elf/Mips/rel-dynamic-05.test
new file mode 100644
index 0000000000000..3bfbd3f6efdbc
--- /dev/null
+++ b/test/elf/Mips/rel-dynamic-05.test
@@ -0,0 +1,188 @@
+# Conditions:
+# a) Linking a non-shared executable file.
+# b) Relocations' targets are symbols defined in the shared object.
+# c) Relocations modify a read-only section.
+# d) The first symbol is referenced by R_MIPS32 relocation only
+# e) The second symbol is referenced by R_MIPS_32 and R_MIPS26 relocations.
+# f) The third symbol is referenced by R_MIPS26 and R_MIPS_32 relocations.
+# Check:
+# a) There should be no R_MIPS_REL32 relocations.
+# b) Linker creates PLT entries for all three relocations.
+# 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 gnu -target mipsel -shared -o %t.so %t-so.o
+# RUN: yaml2obj -format=elf -docnum 2 %s > %t-o.o
+# RUN: lld -flavor gnu -target mipsel -e T0 -o %t.exe %t-o.o %t.so
+# RUN: llvm-readobj -dt -r -s %t.exe | FileCheck -check-prefix=PLT %s
+
+# PLT: Section {
+# PLT: Index: 5
+# PLT-NEXT: Name: .rel.plt (31)
+# PLT-NEXT: Type: SHT_REL (0x9)
+# PLT-NEXT: Flags [ (0x2)
+# PLT-NEXT: SHF_ALLOC (0x2)
+# PLT-NEXT: ]
+# PLT-NEXT: Address: 0x400190
+# PLT-NEXT: Offset: 0x190
+# PLT-NEXT: Size: 24
+# PLT-NEXT: Link: 3
+# PLT-NEXT: Info: 0
+# PLT-NEXT: AddressAlignment: 4
+# PLT-NEXT: EntrySize: 8
+# PLT-NEXT: }
+# PLT-NEXT: Section {
+# PLT-NEXT: Index: 6
+# PLT-NEXT: Name: .plt (40)
+# PLT-NEXT: Type: SHT_PROGBITS (0x1)
+# PLT-NEXT: Flags [ (0x6)
+# PLT-NEXT: SHF_ALLOC (0x2)
+# PLT-NEXT: SHF_EXECINSTR (0x4)
+# PLT-NEXT: ]
+# PLT-NEXT: Address: 0x4001B0
+# PLT-NEXT: Offset: 0x1B0
+# PLT-NEXT: Size: 80
+# PLT-NEXT: Link: 0
+# PLT-NEXT: Info: 0
+# PLT-NEXT: AddressAlignment: 16
+# PLT-NEXT: EntrySize: 0
+# PLT-NEXT: }
+
+# PLT: Relocations [
+# PLT-NEXT: Section (5) .rel.plt {
+# PLT-NEXT: 0x402008 R_MIPS_JUMP_SLOT T1 0x0
+# PLT-NEXT: 0x40200C R_MIPS_JUMP_SLOT T2 0x0
+# PLT-NEXT: 0x402010 R_MIPS_JUMP_SLOT T3 0x0
+# PLT-NEXT: }
+# PLT-NEXT: ]
+
+# PLT: DynamicSymbols [
+# PLT-NEXT: Symbol {
+# PLT-NEXT: Name: @ (0)
+# PLT-NEXT: Value: 0x0
+# PLT-NEXT: Size: 0
+# PLT-NEXT: Binding: Local (0x0)
+# PLT-NEXT: Type: None (0x0)
+# PLT-NEXT: Other: 0
+# PLT-NEXT: Section: Undefined (0x0)
+# PLT-NEXT: }
+# PLT-NEXT: Symbol {
+# PLT-NEXT: Name: T1@ (1)
+# PLT-NEXT: Value: 0x4001D0
+# PLT-NEXT: Size: 0
+# PLT-NEXT: Binding: Global (0x1)
+# PLT-NEXT: Type: Function (0x2)
+# PLT-NEXT: Other: 8
+# PLT-NEXT: Section: Undefined (0x0)
+# PLT-NEXT: }
+# PLT-NEXT: Symbol {
+# PLT-NEXT: Name: T2@ (4)
+# PLT-NEXT: Value: 0x4001E0
+# PLT-NEXT: Size: 0
+# PLT-NEXT: Binding: Global (0x1)
+# PLT-NEXT: Type: Function (0x2)
+# PLT-NEXT: Other: 8
+# PLT-NEXT: Section: Undefined (0x0)
+# PLT-NEXT: }
+# PLT-NEXT: Symbol {
+# PLT-NEXT: Name: T3@ (7)
+# PLT-NEXT: Value: 0x4001F0
+# PLT-NEXT: Size: 0
+# PLT-NEXT: Binding: Global (0x1)
+# PLT-NEXT: Type: Function (0x2)
+# PLT-NEXT: Other: 8
+# PLT-NEXT: Section: Undefined (0x0)
+# PLT-NEXT: }
+# PLT-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_32]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 0x0C
+ AddressAlign: 16
+ Flags: [SHF_EXECINSTR, SHF_ALLOC]
+
+Symbols:
+ Global:
+ - Name: T1
+ Section: .text
+ Type: STT_FUNC
+ Value: 0x0
+ Size: 4
+ - Name: T2
+ Section: .text
+ Type: STT_FUNC
+ Value: 0x4
+ Size: 4
+ - Name: T3
+ Section: .text
+ Type: STT_FUNC
+ Value: 0x8
+ Size: 4
+
+# 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_32]
+
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+ Size: 0x08
+ AddressAlign: 16
+ Flags: [SHF_EXECINSTR, SHF_ALLOC]
+
+- Name: .rel.text
+ Type: SHT_REL
+ Info: .text
+ AddressAlign: 4
+ Relocations:
+ # There is no branch relocation for T1.
+ - Offset: 0x00
+ Symbol: T1
+ Type: R_MIPS_32
+ # The R_MIPS_32 relocation for T2 might produce R_MIPS_REL32 ...
+ - Offset: 0x00
+ Symbol: T2
+ Type: R_MIPS_32
+ # ... but R_MIPS_26 creates PLT entry and makes R_MIPS_REL32 redundant.
+ - Offset: 0x04
+ Symbol: T2
+ Type: R_MIPS_26
+ # Create PLT entry for T3 symbol.
+ - Offset: 0x00
+ Symbol: T3
+ Type: R_MIPS_26
+ # Take in account existing PLT entry and do not create R_MIPS_REL32.
+ - Offset: 0x04
+ Symbol: T3
+ Type: R_MIPS_32
+
+Symbols:
+ Global:
+ - Name: T0
+ Section: .text
+ Type: STT_FUNC
+ Value: 0x0
+ Size: 8
+ - Name: T1
+ Type: STT_FUNC
+ - Name: T2
+ Type: STT_FUNC
+ - Name: T3
+ Type: STT_FUNC
+...