]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/elf/Mips/rel-dynamic-05.test
Vendor import of lld trunk r233088:
[FreeBSD/FreeBSD.git] / test / elf / Mips / rel-dynamic-05.test
1 # Conditions:
2 #   a) Linking a non-shared executable file.
3 #   b) Relocations' targets are symbols defined in the shared object.
4 #   c) Relocations modify a read-only section.
5 #   d) The first symbol is referenced by R_MIPS32 relocation only
6 #   e) The second symbol is referenced by R_MIPS_32 and R_MIPS26 relocations.
7 #   f) The third symbol is referenced by R_MIPS26 and R_MIPS_32 relocations.
8 # Check:
9 #   a) There should be no R_MIPS_REL32 relocations.
10 #   b) Linker creates PLT entries for all three relocations.
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-readobj -dt -r -s %t.exe | FileCheck -check-prefix=PLT %s
19
20 # PLT:      Section {
21 # PLT:        Index: 5
22 # PLT-NEXT:    Name: .rel.plt (31)
23 # PLT-NEXT:    Type: SHT_REL (0x9)
24 # PLT-NEXT:    Flags [ (0x2)
25 # PLT-NEXT:      SHF_ALLOC (0x2)
26 # PLT-NEXT:    ]
27 # PLT-NEXT:    Address: 0x400190
28 # PLT-NEXT:    Offset: 0x190
29 # PLT-NEXT:    Size: 24
30 # PLT-NEXT:    Link: 3
31 # PLT-NEXT:    Info: 0
32 # PLT-NEXT:    AddressAlignment: 4
33 # PLT-NEXT:    EntrySize: 8
34 # PLT-NEXT:  }
35 # PLT-NEXT:  Section {
36 # PLT-NEXT:    Index: 6
37 # PLT-NEXT:    Name: .plt (40)
38 # PLT-NEXT:    Type: SHT_PROGBITS (0x1)
39 # PLT-NEXT:    Flags [ (0x6)
40 # PLT-NEXT:      SHF_ALLOC (0x2)
41 # PLT-NEXT:      SHF_EXECINSTR (0x4)
42 # PLT-NEXT:    ]
43 # PLT-NEXT:    Address: 0x4001B0
44 # PLT-NEXT:    Offset: 0x1B0
45 # PLT-NEXT:    Size: 80
46 # PLT-NEXT:    Link: 0
47 # PLT-NEXT:    Info: 0
48 # PLT-NEXT:    AddressAlignment: 16
49 # PLT-NEXT:    EntrySize: 0
50 # PLT-NEXT:  }
51
52 # PLT:      Relocations [
53 # PLT-NEXT:   Section (5) .rel.plt {
54 # PLT-NEXT:     0x402008 R_MIPS_JUMP_SLOT T1 0x0
55 # PLT-NEXT:     0x40200C R_MIPS_JUMP_SLOT T2 0x0
56 # PLT-NEXT:     0x402010 R_MIPS_JUMP_SLOT T3 0x0
57 # PLT-NEXT:   }
58 # PLT-NEXT: ]
59
60 # PLT:      DynamicSymbols [
61 # PLT-NEXT:   Symbol {
62 # PLT-NEXT:     Name: @ (0)
63 # PLT-NEXT:     Value: 0x0
64 # PLT-NEXT:     Size: 0
65 # PLT-NEXT:     Binding: Local (0x0)
66 # PLT-NEXT:     Type: None (0x0)
67 # PLT-NEXT:     Other: 0
68 # PLT-NEXT:     Section: Undefined (0x0)
69 # PLT-NEXT:   }
70 # PLT-NEXT:   Symbol {
71 # PLT-NEXT:     Name: T1@ (1)
72 # PLT-NEXT:     Value: 0x4001D0
73 # PLT-NEXT:     Size: 0
74 # PLT-NEXT:     Binding: Global (0x1)
75 # PLT-NEXT:     Type: Function (0x2)
76 # PLT-NEXT:     Other: 8
77 # PLT-NEXT:     Section: Undefined (0x0)
78 # PLT-NEXT:   }
79 # PLT-NEXT:   Symbol {
80 # PLT-NEXT:     Name: T2@ (4)
81 # PLT-NEXT:     Value: 0x4001E0
82 # PLT-NEXT:     Size: 0
83 # PLT-NEXT:     Binding: Global (0x1)
84 # PLT-NEXT:     Type: Function (0x2)
85 # PLT-NEXT:     Other: 8
86 # PLT-NEXT:     Section: Undefined (0x0)
87 # PLT-NEXT:   }
88 # PLT-NEXT:   Symbol {
89 # PLT-NEXT:     Name: T3@ (7)
90 # PLT-NEXT:     Value: 0x4001F0
91 # PLT-NEXT:     Size: 0
92 # PLT-NEXT:     Binding: Global (0x1)
93 # PLT-NEXT:     Type: Function (0x2)
94 # PLT-NEXT:     Other: 8
95 # PLT-NEXT:     Section: Undefined (0x0)
96 # PLT-NEXT:   }
97 # PLT-NEXT: ]
98
99 # so.o
100 ---
101 FileHeader:
102   Class:   ELFCLASS32
103   Data:    ELFDATA2LSB
104   Type:    ET_REL
105   Machine: EM_MIPS
106   Flags:   [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
107
108 Sections:
109 - Name:         .text
110   Type:         SHT_PROGBITS
111   Size:         0x0C
112   AddressAlign: 16
113   Flags:        [SHF_EXECINSTR, SHF_ALLOC]
114
115 Symbols:
116   Global:
117     - Name: T1
118       Section: .text
119       Type: STT_FUNC
120       Value: 0x0
121       Size: 4
122     - Name: T2
123       Section: .text
124       Type: STT_FUNC
125       Value: 0x4
126       Size: 4
127     - Name: T3
128       Section: .text
129       Type: STT_FUNC
130       Value: 0x8
131       Size: 4
132
133 # o.o
134 ---
135 FileHeader: !FileHeader
136   Class: ELFCLASS32
137   Data: ELFDATA2LSB
138   Type: ET_REL
139   Machine: EM_MIPS
140   Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
141
142 Sections:
143 - Name: .text
144   Type: SHT_PROGBITS
145   Size: 0x08
146   AddressAlign: 16
147   Flags: [SHF_EXECINSTR, SHF_ALLOC]
148
149 - Name: .rel.text
150   Type: SHT_REL
151   Info: .text
152   AddressAlign: 4
153   Relocations:
154     # There is no branch relocation for T1.
155     - Offset: 0x00
156       Symbol: T1
157       Type: R_MIPS_32
158     # The R_MIPS_32 relocation for T2 might produce R_MIPS_REL32 ...
159     - Offset: 0x00
160       Symbol: T2
161       Type: R_MIPS_32
162     # ... but R_MIPS_26 creates PLT entry and makes R_MIPS_REL32 redundant.
163     - Offset: 0x04
164       Symbol: T2
165       Type: R_MIPS_26
166     # Create PLT entry for T3 symbol.
167     - Offset: 0x00
168       Symbol: T3
169       Type: R_MIPS_26
170     # Take in account existing PLT entry and do not create R_MIPS_REL32.
171     - Offset: 0x04
172       Symbol: T3
173       Type: R_MIPS_32
174
175 Symbols:
176   Global:
177     - Name: T0
178       Section: .text
179       Type: STT_FUNC
180       Value: 0x0
181       Size: 8
182     - Name: T1
183       Type: STT_FUNC
184     - Name: T2
185       Type: STT_FUNC
186     - Name: T3
187       Type: STT_FUNC
188 ...