packed-relocs.test
5.85 KB
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
# The binary blobs in this file were created like this:
# llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu Inputs/elf-packed-relocs1.s -o - | obj2yaml | grep Content:
# RUN: yaml2obj -docnum 1 %s | llvm-readobj --relocations - | FileCheck --check-prefix=LLVM1 %s
# LLVM1: Section (1) .rela.dyn {
# LLVM1-NEXT: 0x1100 R_X86_64_RELATIVE - 0x0
# LLVM1-NEXT: 0x1180 R_X86_64_RELATIVE - 0x0
# LLVM1-NEXT: 0x1188 R_X86_64_64 sym1 0x0
# LLVM1-NEXT: 0x1190 R_X86_64_64 sym2 0x0
# LLVM1-NEXT: 0x1191 R_X86_64_64 sym1 0x8
# LLVM1-NEXT: 0x1193 R_X86_64_64 sym2 0xC
# LLVM1-NEXT: 0x1197 R_X86_64_64 sym1 0xA
# LLVM1-NEXT: 0x119F R_X86_64_64 sym2 0xA
# LLVM1-NEXT: }
# RUN: yaml2obj -docnum 1 %s | llvm-readelf -relocations - | FileCheck --check-prefix=GNU1 %s
# GNU1: Relocation section '.rela.dyn' at offset 0x40 contains 8 entries:
# GNU1: 0000000000001100 0000000000000008 R_X86_64_RELATIVE 0
# GNU1-NEXT: 0000000000001180 0000000000000008 R_X86_64_RELATIVE 0
# GNU1-NEXT: 0000000000001188 0000000100000001 R_X86_64_64 0000000000000000 sym1 + 0
# GNU1-NEXT: 0000000000001190 0000000200000001 R_X86_64_64 0000000000000000 sym2 + 0
# GNU1-NEXT: 0000000000001191 0000000100000001 R_X86_64_64 0000000000000000 sym1 + 8
# GNU1-NEXT: 0000000000001193 0000000200000001 R_X86_64_64 0000000000000000 sym2 + c
# GNU1-NEXT: 0000000000001197 0000000100000001 R_X86_64_64 0000000000000000 sym1 + a
# GNU1-NEXT: 000000000000119f 0000000200000001 R_X86_64_64 0000000000000000 sym2 + a
# elf-packed-relocs1.s
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Entry: 0x0000000000001000
Sections:
- Name: .rela.dyn
Type: SHT_ANDROID_RELA
Flags: [ SHF_ALLOC ]
Address: 0x00000000000001C8
Link: .symtab
AddressAlign: 0x0000000000000001
Content: 41505332088020020108800280010202088180808010818080802002080181808080100802818080802004020C7E048180808010088180808020
Symbols:
- Name: sym1
Binding: STB_GLOBAL
- Name: sym2
Binding: STB_GLOBAL
...
# RUN: yaml2obj -docnum 2 %s | llvm-readobj --relocations - | FileCheck --check-prefix=LLVM2 %s
# LLVM2: Section (1) .rel.dyn {
# LLVM2-NEXT: 0x1008 R_386_32 sym1 0x0
# LLVM2-NEXT: 0x1010 R_386_GOT32 sym2 0x0
# LLVM2-NEXT: 0x100C R_386_RELATIVE - 0x0
# LLVM2-NEXT: 0x1008 R_386_RELATIVE - 0x0
# LLVM2-NEXT: 0x1004 R_386_RELATIVE - 0x0
# LLVM2-NEXT: 0x1000 R_386_RELATIVE - 0x0
# LLVM2-NEXT: 0xFFC R_386_RELATIVE - 0x0
# LLVM2-NEXT: 0xFF8 R_386_RELATIVE - 0x0
# LLVM2-NEXT: 0xFF4 R_386_RELATIVE - 0x0
# LLVM2-NEXT: 0xFF0 R_386_RELATIVE - 0x0
# LLVM2-NEXT: }
# RUN: yaml2obj -docnum 2 %s | llvm-readelf -relocations - | FileCheck --check-prefix=GNU2 %s
# GNU2: Relocation section '.rel.dyn' at offset 0x34 contains 10 entries:
# GNU2: 00001008 00000101 R_386_32 00000000 sym1
# GNU2-NEXT: 00001010 00000203 R_386_GOT32 00000000 sym2
# GNU2-NEXT: 0000100c 00000008 R_386_RELATIVE
# GNU2-NEXT: 00001008 00000008 R_386_RELATIVE
# GNU2-NEXT: 00001004 00000008 R_386_RELATIVE
# GNU2-NEXT: 00001000 00000008 R_386_RELATIVE
# GNU2-NEXT: 00000ffc 00000008 R_386_RELATIVE
# GNU2-NEXT: 00000ff8 00000008 R_386_RELATIVE
# GNU2-NEXT: 00000ff4 00000008 R_386_RELATIVE
# GNU2-NEXT: 00000ff0 00000008 R_386_RELATIVE
# elf-packed-relocs2.s
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_386
Entry: 0x0000000000001000
Sections:
- Name: .rel.dyn
Type: SHT_ANDROID_REL
Flags: [ SHF_ALLOC ]
Address: 0x00000000000001C8
Link: .symtab
AddressAlign: 0x0000000000000001
Content: 415053320A80200202088102830408037C08
Symbols:
- Name: sym1
Binding: STB_GLOBAL
- Name: sym2
Binding: STB_GLOBAL
...
# RUN: yaml2obj -docnum 3 %s | llvm-readobj --relocations - | FileCheck --check-prefix=LLVM3 %s
#
# LLVM3: Section (1) .rela.dyn {
# LLVM3-NEXT: 0x1100 R_X86_64_RELATIVE - 0x0
# LLVM3-NEXT: 0x1180 R_X86_64_RELATIVE - 0x8
# LLVM3-NEXT: 0x1200 R_X86_64_64 sym1 0x0
# LLVM3-NEXT: 0x1208 R_X86_64_64 sym2 0x0
# LLVM3-NEXT: 0x1210 R_X86_64_64 sym1 0x0
# LLVM3-NEXT: 0x1218 R_X86_64_64 sym2 0x8
# LLVM3-NEXT: }
# RUN: yaml2obj -docnum 3 %s | llvm-readelf -relocations - | FileCheck --check-prefix=GNU3 %s
# GNU3: Relocation section '.rela.dyn' at offset 0x40 contains 6 entries:
# GNU3: 0000000000001100 0000000000000008 R_X86_64_RELATIVE 0
# GNU3-NEXT: 0000000000001180 0000000000000008 R_X86_64_RELATIVE 8
# GNU3-NEXT: 0000000000001200 0000000100000001 R_X86_64_64 0000000000000000 sym1 + 0
# GNU3-NEXT: 0000000000001208 0000000200000001 R_X86_64_64 0000000000000000 sym2 + 0
# GNU3-NEXT: 0000000000001210 0000000100000001 R_X86_64_64 0000000000000000 sym1 + 0
# GNU3-NEXT: 0000000000001218 0000000200000001 R_X86_64_64 0000000000000000 sym2 + 8
# elf-packed-relocs3.s
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Entry: 0x0000000000001000
Sections:
- Name: .rela.dyn
Type: SHT_ANDROID_RELA
Flags: [ SHF_ALLOC ]
Address: 0x00000000000001C8
Link: .symtab
AddressAlign: 0x0000000000000001
Content: 415053320680200208800208008001080802008001818080801008818080802002080881808080100008818080802008
Symbols:
- Name: sym1
Binding: STB_GLOBAL
- Name: sym2
Binding: STB_GLOBAL
...