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
|
# REQUIRES: mips
# Check handling of R_MICROMIPS_26_S1 relocation.
# Build shared library
# RUN: yaml2obj -format=elf -docnum 1 %s > %t-so.o
# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t-so.o
# Build executable
# RUN: yaml2obj -format=elf -docnum 2 %s > %t-o.o
# RUN: llvm-readobj -relocations %t-o.o | \
# RUN: FileCheck -check-prefix=OBJ-REL %s
# RUN: lld -flavor gnu -target mipsel -e glob -o %t.exe %t-o.o %t.so
# RUN: llvm-readobj -relocations %t.exe | FileCheck -check-prefix=EXE-REL %s
# RUN: llvm-objdump -section-headers %t.exe | FileCheck -check-prefix=EXE %s
# RUN: llvm-objdump -s -d -mattr=micromips %t.exe | \
# RUN: FileCheck -check-prefix=DIS %s
# Object file has three R_MICROMIPS_26_S1 relocations
# OBJ-REL: Relocations [
# OBJ-REL-NEXT: Section (2) .rel.text {
# OBJ-REL-NEXT: 0x8 R_MICROMIPS_26_S1 loc 0x0
# OBJ-REL-NEXT: 0x10 R_MICROMIPS_26_S1 glob 0x0
# OBJ-REL-NEXT: 0x18 R_MICROMIPS_26_S1 T1 0x0
# OBJ-REL-NEXT: }
# OBJ-REL-NEXT: ]
# Executable file has the only relocation for external symbol
# EXE-REL: Relocations [
# EXE-REL-NEXT: Section (5) .rel.plt {
# EXE-REL-NEXT: 0x402008 R_MIPS_JUMP_SLOT T1 0x0
# EXE-REL-NEXT: }
# EXE-REL-NEXT: ]
# EXE: Sections:
# EXE: Idx Name Size Address Type
# EXE: 6 .plt 00000024 0000000000400160 TEXT DATA
# EXE: 10 .got.plt 0000000c 0000000000402000 DATA
# DIS: Disassembly of section .plt:
# DIS-NEXT: .plt:
# DIS-NEXT: 400160: 80 79 a8 07 addiupc $3, 7840
# DIS-NEXT: 400164: 23 ff 00 00 lw $25, 0($3)
# DIS-NEXT: 400168: 35 05 subu16 $2, $2, $3
# DIS-NEXT: 40016a: 25 25 srl16 $2, $2, 2
# DIS-NEXT: 40016c: 02 33 fe ff addiu $24, $2, -2
# DIS-NEXT: 400170: ff 0d move $15, $ra
# DIS-NEXT: 400172: f9 45 jalrs16 $25
# DIS-NEXT: 400174: 83 0f move $gp, $3
# DIS-NEXT: 400176: 00 0c nop
# DIS-NEXT: 400178: 00 79 a4 07 addiupc $2, 7824
# DIS-NEXT: 40017c: 22 ff 00 00 lw $25, 0($2)
# DIS-NEXT: 400180: 99 45 jr16 $25
# DIS-NEXT: 400182: 02 0f move $24, $2
# DIS: Contents of section .text:
# DIS-NEXT: 400184 09f82003 00000000 2400ca0c 00000000 .. .....$.......
# DIS-NEXT: 400194 2000c20c 00000000 2000bc0c 00000000 ....... .......
# 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
# o.o
---
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
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x04
Content: '09F82003000000000400000C000000000000000C000000000000000C00000000'
- Name: .rel.text
Type: SHT_REL
Link: .symtab
AddressAlign: 0x04
Info: .text
Relocations:
- Offset: 0x08
Symbol: loc
Type: R_MICROMIPS_26_S1
- Offset: 0x10
Symbol: glob
Type: R_MICROMIPS_26_S1
- Offset: 0x18
Symbol: T1
Type: R_MICROMIPS_26_S1
Symbols:
Local:
- Name: loc
Section: .text
Value: 0x10
Other: [ STO_MIPS_MICROMIPS ]
- Name: .text
Type: STT_SECTION
Section: .text
Global:
- Name: glob
Section: .text
Other: [ STO_MIPS_MICROMIPS ]
- Name: T1
...
|