emit-relocs.s
2.93 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
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
# RUN: ld.lld --emit-relocs %t1.o -o %t
# RUN: llvm-readobj --symbols -r -S %t | FileCheck %s
## Check single dash form.
# RUN: ld.lld -emit-relocs %t1.o -o %t1
# RUN: llvm-readobj --symbols -r -S %t1 | FileCheck %s
## Check alias.
# RUN: ld.lld -q %t1.o -o %t2
# RUN: llvm-readobj --symbols -r -S %t2 | FileCheck %s
# CHECK: Section {
# CHECK: Index: 2
# CHECK: Name: .rela.text
# CHECK-NEXT: Type: SHT_RELA
# CHECK-NEXT: Flags [
# CHECK-NEXT: SHF_INFO_LINK
# CHECK-NEXT: ]
# CHECK: Relocations [
# CHECK-NEXT: Section ({{.*}}) .rela.text {
# CHECK-NEXT: 0x201122 R_X86_64_32 .text 0x1
# CHECK-NEXT: 0x201127 R_X86_64_PLT32 fn 0xFFFFFFFFFFFFFFFC
# CHECK-NEXT: 0x20112E R_X86_64_32 .text 0xD
# CHECK-NEXT: 0x201133 R_X86_64_PLT32 fn2 0xFFFFFFFFFFFFFFFC
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: Symbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
# CHECK-NEXT: Type: None
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: bar
# CHECK-NEXT: Value: 0x201121
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
# CHECK-NEXT: Type: None
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: .text
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: foo
# CHECK-NEXT: Value: 0x20112D
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
# CHECK-NEXT: Type: None
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: .text
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x201120
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
# CHECK-NEXT: Type: Section
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: .text
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
# CHECK-NEXT: Type: Section
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: .comment
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: fn
# CHECK-NEXT: Value: 0x201120
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global
# CHECK-NEXT: Type: Function
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: .text
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: fn2
# CHECK-NEXT: Value: 0x20112C
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global
# CHECK-NEXT: Type: Function
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: .text
# CHECK-NEXT: }
# CHECK-NEXT: ]
.section .text.fn,"ax",@progbits,unique,0
.globl fn
.type fn,@function
fn:
nop
bar:
movl $bar, %edx
callq fn@PLT
nop
.section .text.fn2,"ax",@progbits,unique,1
.globl fn2
.type fn2,@function
fn2:
nop
foo:
movl $foo, %edx
callq fn2@PLT
nop