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. 4 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 - 12 13# COMMON: Contents of section .debug_addr: 14# COMMON-NEXT: 0000 [[ADDR:[0-9a-f]+]] 00000000 00000000 00000000 15 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 20 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 24 25# ZERO: Contents of section .debug_info: 26# ZERO-NEXT: 0000 {{[0-9a-f]+}}000 00000000 00000000 00000000 27 28## 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 - 31 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 - 35 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 40 41# USAGE: error: -z dead-reloc-in-nonalloc=: expected <section_glob>=<value> 42 43# RUN: not ld.lld -z dead-reloc-in-nonalloc=a=-1 2>&1 | FileCheck %s --check-prefix=NON-INTEGER 44 45# NON-INTEGER: error: -z dead-reloc-in-nonalloc=: expected a non-negative integer, but got '-1' 46 47# RUN: not ld.lld -z dead-reloc-in-nonalloc='['=0 2>&1 | FileCheck %s --check-prefix=INVALID 48 49# INVALID: error: -z dead-reloc-in-nonalloc=: invalid glob pattern: [ 50 51.globl _start 52_start: 53 ret 54 55## .text.1 will be folded by ICF. 56.section .text.1,"ax" 57 ret 58 59.section .debug_addr 60 .quad .text+8 61 .quad .text.1+8 62 63.section .debug_info 64 .quad .text+8 65 .quad .text.1+8 66 67## Test a non-.debug_ section. 68.section .not_debug 69 .long .text.1+8 70