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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
| # RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.coff-i386 \
# RUN: | FileCheck %s -check-prefix COFF-i386
# COFF-i386: file format COFF-i386
# COFF-i386: Disassembly of section .text:
# COFF-i386: 0: 83 ec 0c subl $12, %esp
# COFF-i386: 3: c7 44 24 08 00 00 00 00 movl $0, 8(%esp)
# COFF-i386: b: c7 04 24 00 00 00 00 movl $0, (%esp)
# COFF-i386: e: IMAGE_REL_I386_DIR32 L_.str
# COFF-i386: 12: e8 00 00 00 00 calll 0
# COFF-i386: 13: IMAGE_REL_I386_REL32 _puts
# COFF-i386: 17: e8 00 00 00 00 calll 0
# COFF-i386: 18: IMAGE_REL_I386_REL32 _SomeOtherFunction
# COFF-i386: 1c: 8b 44 24 08 movl 8(%esp), %eax
# COFF-i386: 20: 83 c4 0c addl $12, %esp
# COFF-i386: 23: c3 ret
# RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.coff-x86-64 \
# RUN: | FileCheck %s -check-prefix COFF-x86-64
# COFF-x86-64: file format COFF-x86-64
# COFF-x86-64: Disassembly of section .text:
# COFF-x86-64: 0: 48 83 ec 28 subq $40, %rsp
# COFF-x86-64: 4: c7 44 24 24 00 00 00 00 movl $0, 36(%rsp)
# COFF-x86-64: c: 48 8d 0d 00 00 00 00 leaq (%rip), %rcx
# COFF-x86-64: f: IMAGE_REL_AMD64_REL32 L.str
# COFF-x86-64: 13: e8 00 00 00 00 callq 0
# COFF-x86-64: 14: IMAGE_REL_AMD64_REL32 puts
# COFF-x86-64: 18: e8 00 00 00 00 callq 0
# COFF-x86-64: 19: IMAGE_REL_AMD64_REL32 SomeOtherFunction
# COFF-x86-64: 1d: 8b 44 24 24 movl 36(%rsp), %eax
# COFF-x86-64: 21: 48 83 c4 28 addq $40, %rsp
# COFF-x86-64: 25: c3 ret
# RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.macho-i386 \
# RUN: | FileCheck %s -check-prefix MACHO-i386
# MACHO-i386: file format Mach-O 32-bit i386
# MACHO-i386: Disassembly of section __TEXT,__text:
# MACHO-i386: _main:
# MACHO-i386: 0: 83 ec 0c subl $12, %esp
# MACHO-i386: 3: c7 44 24 08 00 00 00 00 movl $0, 8(%esp)
# MACHO-i386: b: c7 04 24 24 00 00 00 movl $36, (%esp)
# MACHO-i386: e: GENERIC_RELOC_VANILLA __cstring
# MACHO-i386: 12: e8 1f 00 00 00 calll 31
# MACHO-i386: 13: GENERIC_RELOC_VANILLA __jump_table
# MACHO-i386: 17: e8 15 00 00 00 calll 21
# MACHO-i386: 18: GENERIC_RELOC_VANILLA __jump_table
# MACHO-i386: 1c: 8b 44 24 08 movl 8(%esp), %eax
# MACHO-i386: 20: 83 c4 0c addl $12, %esp
# MACHO-i386: 23: c3 ret
# RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.macho-x86-64 \
# RUN: | FileCheck %s -check-prefix MACHO-x86-64
# MACHO-x86-64: file format Mach-O 64-bit x86-64
# MACHO-x86-64: Disassembly of section __TEXT,__text:
# MACHO-x86-64: _main:
# MACHO-x86-64: 0: 48 83 ec 08 subq $8, %rsp
# MACHO-x86-64: 4: c7 44 24 04 00 00 00 00 movl $0, 4(%rsp)
# MACHO-x86-64: c: 48 8d 3d 00 00 00 00 leaq (%rip), %rdi
# MACHO-x86-64: f: X86_64_RELOC_SIGNED L_.str
# MACHO-x86-64: 13: e8 00 00 00 00 callq 0
# MACHO-x86-64: 14: X86_64_RELOC_BRANCH _puts
# MACHO-x86-64: 18: 30 c0 xorb %al, %al
# MACHO-x86-64: 1a: e8 00 00 00 00 callq 0
# MACHO-x86-64: 1b: X86_64_RELOC_BRANCH _SomeOtherFunction
# MACHO-x86-64: 1f: 8b 44 24 04 movl 4(%rsp), %eax
# MACHO-x86-64: 23: 48 83 c4 08 addq $8, %rsp
# MACHO-x86-64: 27: c3 ret
# RUN: yaml2obj -docnum=1 %s > %t.elf-i386
# RUN: llvm-objdump -d -r %t.elf-i386 | FileCheck %s -check-prefix ELF-i386
# ELF-i386: file format ELF32-i386
# ELF-i386: Disassembly of section .text:
# ELF-i386: main:
# ELF-i386: 0: 83 ec 0c subl $12, %esp
# ELF-i386: 3: c7 44 24 08 00 00 00 00 movl $0, 8(%esp)
# ELF-i386: b: c7 04 24 00 00 00 00 movl $0, (%esp)
# ELF-i386: e: R_386_32 .rodata.str1.1
# ELF-i386: 12: e8 fc ff ff ff calll -4
# ELF-i386: 13: R_386_PC32 puts
# ELF-i386: 17: e8 fc ff ff ff calll -4
# ELF-i386: 18: R_386_PC32 SomeOtherFunction
# ELF-i386: 1c: 8b 44 24 08 movl 8(%esp), %eax
# ELF-i386: 20: 83 c4 0c addl $12, %esp
# ELF-i386: 23: c3 ret
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_386
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Content: 83EC0CC744240800000000C7042400000000E8FCFFFFFFE8FCFFFFFF8B44240883C40CC3
- Name: .rodata.str1.1
Type: SHT_PROGBITS
- Name: .rel.text
Type: SHT_REL
Info: .text
Relocations:
- Offset: 0x000000000000000E
Symbol: .rodata.str1.1
Type: R_386_32
- Offset: 0x0000000000000013
Symbol: puts
Type: R_386_PC32
- Offset: 0x0000000000000018
Symbol: SomeOtherFunction
Type: R_386_PC32
Symbols:
- Name: .rodata.str1.1
Type: STT_SECTION
Section: .rodata.str1.1
- Name: main
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
- Name: SomeOtherFunction
Binding: STB_GLOBAL
- Name: puts
Binding: STB_GLOBAL
# RUN: yaml2obj -docnum=2 %s > %t.elf-x86-64
# RUN: llvm-objdump -d -r %t.elf-x86-64 | FileCheck %s -check-prefix ELF-x86-64
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Content: 4883EC08C744240400000000BF00000000E80000000030C0E8000000008B4424044883C408C3
- Name: .rodata.str1.1
Type: SHT_PROGBITS
- Name: .rela.text
Type: SHT_RELA
Info: .text
Relocations:
- Offset: 0x000000000000000D
Symbol: .rodata.str1.1
Type: R_X86_64_32S
- Offset: 0x0000000000000012
Symbol: puts
Type: R_X86_64_PC32
Addend: -4
- Offset: 0x0000000000000019
Symbol: SomeOtherFunction
Type: R_X86_64_PC32
Addend: -4
Symbols:
- Name: .rodata.str1.1
Type: STT_SECTION
Section: .rodata.str1.1
- Name: main
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
- Name: SomeOtherFunction
Binding: STB_GLOBAL
- Name: puts
Binding: STB_GLOBAL
# ELF-x86-64: file format ELF64-x86-64
# ELF-x86-64: Disassembly of section .text:
# ELF-x86-64: main:
# ELF-x86-64: 0: 48 83 ec 08 subq $8, %rsp
# ELF-x86-64: 4: c7 44 24 04 00 00 00 00 movl $0, 4(%rsp)
# ELF-x86-64: c: bf 00 00 00 00 movl $0, %edi
# ELF-x86-64: d: R_X86_64_32S .rodata.str1.1
# ELF-x86-64: 11: e8 00 00 00 00 callq 0
# ELF-x86-64: 12: R_X86_64_PC32 puts-4
# ELF-x86-64: 16: 30 c0 xorb %al, %al
# ELF-x86-64: 18: e8 00 00 00 00 callq 0
# ELF-x86-64: 19: R_X86_64_PC32 SomeOtherFunction-4
# ELF-x86-64: 1d: 8b 44 24 04 movl 4(%rsp), %eax
# ELF-x86-64: 21: 48 83 c4 08 addq $8, %rsp
# ELF-x86-64: 25: c3 ret
|