]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/elf/Mips/rel-dynamic-03.test
Vendor import of lld trunk r233088:
[FreeBSD/FreeBSD.git] / test / elf / Mips / rel-dynamic-03.test
1 # REQUIRES: mips
2
3 # Conditions:
4 #   a) Linking a non-shared executable file.
5 #   b) Relocations' target is a symbol defined in the shared object.
6 #   c) The target symbol is referenced by both branch (R_MIPS_26)
7 #      and regular (R_MIPS_32) relocations.
8 # Check:
9 #   a) There should be no R_MIPS_REL32 relocation.
10 #   b) Linker creates a single PLT entry.
11 #   c) STO_MIPS_PLT flag in the dynamic symbol table for symbols require
12 #      a pointer equality.
13 #
14 # RUN: yaml2obj -format=elf -docnum 1 %s > %t-so.o
15 # RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t-so.o
16 # RUN: yaml2obj -format=elf -docnum 2 %s > %t-o.o
17 # RUN: lld -flavor gnu -target mipsel -e T0 -o %t.exe %t-o.o %t.so
18 # RUN: llvm-objdump -disassemble %t.exe | FileCheck -check-prefix=PLT %s
19 # RUN: llvm-readobj -dt -r %t.exe | FileCheck -check-prefix=PLT-SYM %s
20
21 # PLT: Disassembly of section .plt:
22 # PLT-NEXT: .plt:
23 # PLT-NEXT:   400160:  40 00 1c 3c  lui     $gp, 64
24 # PLT-NEXT:   400164:  00 20 99 8f  lw      $25, 8192($gp)
25 # PLT-NEXT:   400168:  00 20 9c 27  addiu   $gp, $gp, 8192
26 # PLT-NEXT:   40016c:  23 c0 1c 03  subu    $24, $24, $gp
27 # PLT-NEXT:   400170:  21 78 e0 03  move    $15, $ra
28 # PLT-NEXT:   400174:  82 c0 18 00  srl     $24, $24, 2
29 # PLT-NEXT:   400178:  09 f8 20 03  jalr    $25
30 # PLT-NEXT:   40017c:  fe ff 18 27  addiu   $24, $24, -2
31 #
32 # PLT-NEXT:   400180:  40 00 0f 3c  lui     $15, 64
33 # PLT-NEXT:   400184:  08 20 f9 8d  lw      $25, 8200($15)
34 # PLT-NEXT:   400188:  08 00 20 03  jr      $25
35 # PLT-NEXT:   40018c:  08 20 f8 25  addiu   $24, $15, 8200
36 #
37 # PLT-SYM:      Relocations [
38 # PLT-SYM-NEXT:   Section (5) .rel.plt {
39 # PLT-SYM-NEXT:     0x402008 R_MIPS_JUMP_SLOT T1 0x0
40 # PLT-SYM-NEXT:   }
41 # PLT-SYM-NEXT: ]
42
43 # PLT-SYM:      Name: T1@ (1)
44 # PLT-SYM-NEXT: Value: 0x400180
45 # PLT-SYM-NEXT: Size: 0
46 # PLT-SYM-NEXT: Binding: Global (0x1)
47 # PLT-SYM-NEXT: Type: Function (0x2)
48 # PLT-SYM-NEXT: Other: 8
49 # PLT-SYM-NEXT: Section: Undefined (0x0)
50
51 # so.o
52 ---
53 FileHeader:
54   Class:   ELFCLASS32
55   Data:    ELFDATA2LSB
56   Type:    ET_REL
57   Machine: EM_MIPS
58   Flags:   [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
59
60 Sections:
61 - Name:         .text
62   Type:         SHT_PROGBITS
63   Size:         0x0C
64   AddressAlign: 16
65   Flags:        [SHF_EXECINSTR, SHF_ALLOC]
66
67 Symbols:
68   Global:
69     - Name: T1
70       Section: .text
71       Type: STT_FUNC
72       Value: 0x0
73       Size: 4
74
75 # o.o
76 ---
77 FileHeader: !FileHeader
78   Class: ELFCLASS32
79   Data: ELFDATA2LSB
80   Type: ET_REL
81   Machine: EM_MIPS
82   Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
83
84 Sections:
85 - Name: .text
86   Type: SHT_PROGBITS
87   Size:  0x08
88   AddressAlign: 16
89   Flags: [SHF_EXECINSTR, SHF_ALLOC]
90
91 - Name: .data
92   Type: SHT_PROGBITS
93   Size:  0x08
94   AddressAlign: 16
95   Flags: [SHF_WRITE, SHF_ALLOC]
96
97 - Name: .rel.text
98   Type: SHT_REL
99   Info: .text
100   AddressAlign: 4
101   Relocations:
102     - Offset: 0x04
103       Symbol: T1
104       Type: R_MIPS_26
105
106 - Name: .rel.data
107   Type: SHT_REL
108   Info: .data
109   AddressAlign: 4
110   Relocations:
111     - Offset: 0x04
112       Symbol: T1
113       Type: R_MIPS_32
114
115 Symbols:
116   Global:
117     - Name: T0
118       Section: .text
119       Type: STT_FUNC
120       Value: 0x0
121       Size: 8
122     - Name: T1
123       Type: STT_FUNC
124     - Name: D0
125       Section: .data
126       Type: STT_OBJECT
127       Value: 0x0
128       Size: 8
129 ...