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
| # RUN: yaml2obj --docnum=1 %s > %t
# RUN: llvm-objdump --reloc %t > %t1
# RUN: llvm-objdump -r %t > %t2
# RUN: cmp %t1 %t2
# RUN: FileCheck %s --input-file=%t1
# CHECK: RELOCATION RECORDS FOR [.text]:
# CHECK-NEXT: 0000000000000001 R_X86_64_32 glob1
# CHECK-NEXT: 0000000000000001 R_X86_64_32S glob2
# CHECK-NEXT: 0000000000000002 R_X86_64_64 loc1
# CHECK-NEXT: 0000000000000001 R_X86_64_32 glob1+1
# CHECK-NEXT: 0000000000000001 R_X86_64_32S glob2+2
# CHECK-NEXT: 0000000000000002 R_X86_64_64 loc1+3
--- !ELF
FileHeader: !FileHeader
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Content: "0000000000000000"
AddressAlign: 16
Flags: [SHF_ALLOC]
- Name: .rel.text
Type: SHT_REL
Info: .text
AddressAlign: 4
Relocations:
- Offset: 0x1
Symbol: glob1
Type: R_X86_64_32
- Offset: 0x1
Symbol: glob2
Type: R_X86_64_32S
- Offset: 0x2
Symbol: loc1
Type: R_X86_64_64
- Name: .rela.text
Type: SHT_RELA
Link: .symtab
Info: .text
AddressAlign: 4
Relocations:
- Offset: 0x1
Addend: 1
Symbol: glob1
Type: R_X86_64_32
- Offset: 0x1
Addend: 2
Symbol: glob2
Type: R_X86_64_32S
- Offset: 0x2
Addend: 3
Symbol: loc1
Type: R_X86_64_64
Symbols:
- Name: loc1
- Name: loc2
- Name: glob1
Section: .text
Value: 0x0
Size: 4
Binding: STB_GLOBAL
- Name: glob2
Binding: STB_GLOBAL
## Check we report an error if the relocated section identified by the
## sh_info field of a relocation section is invalid.
# RUN: yaml2obj --docnum=2 %s > %t2
# RUN: not llvm-objdump --reloc %t2 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=ERR
# ERR: error: '[[FILE]]': section (1): unable to get a relocation target: invalid section index: 255
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .rela.foo
Type: SHT_RELA
Info: 0xFF
Relocations:
- Offset: 0x1
Type: R_X86_64_NONE
|