1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# Check microMIPS LA25 stubs creation when PIC code
# is called from non-PIC routines.
# Build executable from pic and non-pic code.
# RUN: yaml2obj -format=elf -docnum 1 %s > %t-npic.o
# RUN: yaml2obj -format=elf -docnum 2 %s > %t-pic.o
# RUN: yaml2obj -format=elf -docnum 3 %s > %t-main.o
# RUN: lld -flavor gnu -target mipsel -e glob -o %t.exe \
# RUN: %t-npic.o %t-pic.o %t-main.o
# RUN: llvm-readobj -t %t.exe | FileCheck -check-prefix=SYM %s
# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=ASM %s
# SYM: Name: loc (13)
# SYM-NEXT: Value: 0x400135
# SYM: Name: T1N (1)
# SYM-NEXT: Value: 0x400111
# SYM: Name: T1 (5)
# SYM-NEXT: Value: 0x400121
# SYM: Name: glob (8)
# SYM-NEXT: Value: 0x400125
# ASM: Contents of section .text:
# ASM-NEXT: 400110 00000000 00000000 00000000 00000000
# ASM-NEXT: 400120 00000000 00000000 00000000 10f04900
# 0x100049 << 2 == 0x400125 (jalx glob) --^
# ASM-NEXT: 400130 00000000 20f49200 00000000 20f48800
# ^-- 0x100049 << 2 == 0x400124 (jal glob)
# 0x100044 << 2 == 0x400110 (jal T1N) --^
# ASM-NEXT: 400140 00000000 20f4a800 00000000 00000000
# ^-- 0x100054 << 2 == 0x400150 (jal T1 stub)
# ASM-NEXT: 400150 b9414000 20d49000 39332101 00000000
# ^-- j 0x400120 (T1)
# npic.o
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2,
EF_MIPS_CPIC, EF_MIPS_MICROMIPS ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Size: 0x04
AddressAlign: 16
Flags: [SHF_EXECINSTR, SHF_ALLOC]
Symbols:
Global:
- Name: T1N
Section: .text
Type: STT_FUNC
Value: 0x0
Size: 4
Other: [ STO_MIPS_MICROMIPS ]
# pic.o
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2,
EF_MIPS_CPIC, EF_MIPS_PIC, EF_MIPS_MICROMIPS ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Size: 0x04
AddressAlign: 16
Flags: [SHF_EXECINSTR, SHF_ALLOC]
Symbols:
Global:
- Name: T1
Section: .text
Type: STT_FUNC
Value: 0x0
Size: 4
Other: [ STO_MIPS_MICROMIPS ]
# main.o
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2,
EF_MIPS_CPIC, EF_MIPS_MICROMIPS ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x04
Content: '000000000000000000f400000000000000f400000000000000f400000000000000f4000000000000'
# jal loc jal glob jal T1N jal T1
- Name: .rel.text
Type: SHT_REL
Link: .symtab
AddressAlign: 0x04
Info: .text
Relocations:
- Offset: 0x08
Symbol: .text
Type: R_MICROMIPS_26_S1
- Offset: 0x10
Symbol: glob
Type: R_MICROMIPS_26_S1
- Offset: 0x18
Symbol: T1N
Type: R_MICROMIPS_26_S1
- Offset: 0x20
Symbol: T1
Type: R_MICROMIPS_26_S1
Symbols:
Local:
- Name: loc
Section: .text
Value: 0x10
Size: 0x18
Other: [ STO_MIPS_MICROMIPS ]
- Name: .text
Type: STT_SECTION
Section: .text
Global:
- Name: glob
Section: .text
Size: 0x10
Other: [ STO_MIPS_MICROMIPS ]
- Name: T1
- Name: T1N
...
|