1
1
# REQUIRES: x86
2
- ## Test that -z dead-reloc-in-nonalloc= can customize the tombstone value we
3
- ## use for an absolute relocation referencing a discarded symbol .
2
+ ## Test an absolute relocation referencing an undefined or DSO symbol, relocating
3
+ ## a non-SHF_ALLOC section. Also test -z dead-reloc-in-nonalloc= .
4
4
5
5
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
6
- # RUN: ld.lld --icf=all -z dead-reloc-in-nonalloc=.debug_info=0xaaaaaaaa \
7
- # RUN: -z dead-reloc-in-nonalloc=.not_debug=0xbbbbbbbb %t.o -o %t
6
+ # RUN: echo '.globl bar; bar = 42' | llvm-mc -filetype=obj -triple=x86_64 - -o %tabs.o
7
+ # RUN: ld.lld --gc-sections -z dead-reloc-in-nonalloc=.debug_info=0xaaaaaaaa \
8
+ # RUN: -z dead-reloc-in-nonalloc=.not_debug=0xbbbbbbbb %t.o %tabs.o -o %t
8
9
# RUN: llvm-objdump -s %t | FileCheck %s --check-prefixes=COMMON,AA
9
10
## 0xaaaaaaaa == 2863311530
10
- # RUN: ld.lld --icf=all -z dead-reloc-in-nonalloc=.debug_info=2863311530 \
11
- # RUN: -z dead-reloc-in-nonalloc=.not_debug=0xbbbbbbbb %t.o -o - | cmp %t -
11
+ # RUN: ld.lld --gc-sections -z dead-reloc-in-nonalloc=.debug_info=2863311530 \
12
+ # RUN: -z dead-reloc-in-nonalloc=.not_debug=0xbbbbbbbb %t.o %tabs.o -o - | cmp %t -
12
13
13
14
# COMMON: Contents of section .debug_addr:
14
15
# COMMON-NEXT: 0000 [[ADDR:[0-9a-f]+]] 00000000 00000000 00000000
15
16
16
17
# AA: Contents of section .debug_info:
17
18
# AA-NEXT: 0000 [[ADDR]] 00000000 aaaaaaaa 00000000
18
19
# AA: Contents of section .not_debug:
19
- # AA-NEXT: 0000 bbbbbbbb
20
+ # AA-NEXT: 0000 bbbbbbbb bbbbbbbb 00000000 .
20
21
21
22
## Specifying zero can get a behavior similar to GNU ld.
22
- # RUN: ld.lld --icf=all -z dead-reloc-in-nonalloc=.debug_info=0 %t.o -o %tzero
23
+ # RUN: ld.lld --icf=all -z dead-reloc-in-nonalloc=.debug_info=0 %t.o %tabs.o -o %tzero
23
24
# RUN: llvm-objdump -s %tzero | FileCheck %s --check-prefixes=COMMON,ZERO
24
25
25
26
# ZERO: Contents of section .debug_info:
26
27
# ZERO-NEXT: 0000 {{[0-9a-f]+}}000 00000000 00000000 00000000
27
28
28
29
## Glob works.
29
- # RUN: ld.lld --icf=all -z dead-reloc-in-nonalloc='.debug_i*=0xaaaaaaaa' \
30
- # RUN: -z dead-reloc-in-nonalloc='[.]not_debug=0xbbbbbbbb' %t.o -o - | cmp %t -
30
+ # RUN: ld.lld --gc-sections -z dead-reloc-in-nonalloc='.debug_i*=0xaaaaaaaa' \
31
+ # RUN: -z dead-reloc-in-nonalloc='[.]not_debug=0xbbbbbbbb' %t.o %tabs.o -o - | cmp %t -
31
32
32
33
## If a section matches multiple option. The last option wins.
33
34
# RUN: ld.lld --icf=all -z dead-reloc-in-nonalloc='.debug_info=1' \
34
- # RUN: -z dead-reloc-in-nonalloc='.debug_i*=0' %t.o -o - | cmp %tzero -
35
+ # RUN: -z dead-reloc-in-nonalloc='.debug_i*=0' %t.o %tabs.o -o - | cmp %tzero -
36
+
37
+ # RUN: llvm-mc -filetype=obj -triple=x86_64 %S/Inputs/shared.s -o %t1.o
38
+ # RUN: ld.lld -shared -soname=t1.so %t1.o -o %t1.so
39
+ # RUN: ld.lld --gc-sections %t.o %t1.so -o %tso
40
+ # RUN: llvm-objdump -s %tso | FileCheck %s --check-prefix=SHARED
41
+
42
+ # SHARED: Contents of section .not_debug:
43
+ # SHARED-NEXT: 0000 08000000 00000000 00000000 .
35
44
36
45
## Test all possible invalid cases.
37
46
# RUN: not ld.lld -z dead-reloc-in-nonalloc= 2>&1 | FileCheck %s --check-prefix=USAGE
52
61
_start:
53
62
ret
54
63
55
- ## .text.1 will be folded by ICF.
64
+ ## .text.1 will be folded by ICF or discarded by --gc-sections .
56
65
.section .text .1 ,"ax"
57
66
ret
58
67
@@ -67,3 +76,5 @@ _start:
67
76
## Test a non-.debug_ section.
68
77
.section .not_debug
69
78
.long .text .1 +8
79
+
80
+ .quad bar
0 commit comments