2 ## Test that -z dead-reloc-in-nonalloc= can customize the tombstone value we
3 ## use for an absolute relocation referencing a discarded symbol.
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
8 # RUN: llvm-objdump -s %t | FileCheck %s --check-prefixes=COMMON,AA
9 ## 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 -
13 # COMMON: Contents of section .debug_addr:
14 # COMMON-NEXT: 0000 [[ADDR:[0-9a-f]+]] 00000000 00000000 00000000
16 # AA: Contents of section .debug_info:
17 # AA-NEXT: 0000 [[ADDR]] 00000000 aaaaaaaa 00000000
18 # AA: Contents of section .not_debug:
19 # AA-NEXT: 0000 bbbbbbbb
21 ## 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: llvm-objdump -s %tzero | FileCheck %s --check-prefixes=COMMON,ZERO
25 # ZERO: Contents of section .debug_info:
26 # ZERO-NEXT: 0000 {{[0-9a-f]+}}000 00000000 00000000 00000000
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 -
32 ## If a section matches multiple option. The last option wins.
33 # 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 -
36 ## Test all possible invalid cases.
37 # RUN: not ld.lld -z dead-reloc-in-nonalloc= 2>&1 | FileCheck %s --check-prefix=USAGE
38 # RUN: not ld.lld -z dead-reloc-in-nonalloc=a= 2>&1 | FileCheck %s --check-prefix=USAGE
39 # RUN: not ld.lld -z dead-reloc-in-nonalloc==0 2>&1 | FileCheck %s --check-prefix=USAGE
41 # USAGE: error: -z dead-reloc-in-nonalloc=: expected <section_glob>=<value>
43 # RUN: not ld.lld -z dead-reloc-in-nonalloc=a=-1 2>&1 | FileCheck %s --check-prefix=NON-INTEGER
45 # NON-INTEGER: error: -z dead-reloc-in-nonalloc=: expected a non-negative integer, but got '-1'
47 # RUN: not ld.lld -z dead-reloc-in-nonalloc='['=0 2>&1 | FileCheck %s --check-prefix=INVALID
49 # INVALID: error: -z dead-reloc-in-nonalloc=: invalid glob pattern, unmatched '[': [
55 ## .text.1 will be folded by ICF.
67 ## Test a non-.debug_ section.