81 lines · plain
1# REQUIRES: x862## Test an absolute relocation referencing an undefined or DSO symbol, relocating3## a non-SHF_ALLOC section. Also test -z dead-reloc-in-nonalloc=.4 5# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o6# RUN: echo '.globl bar; bar = 42' | llvm-mc -filetype=obj -triple=x86_64 - -o %tabs.o7# 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 %t9# RUN: llvm-objdump -s %t | FileCheck %s --check-prefixes=COMMON,AA10## 0xaaaaaaaa == 286331153011# 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 -13 14# COMMON: Contents of section .debug_addr:15# COMMON-NEXT: 0000 [[ADDR:[0-9a-f]+]] 00000000 00000000 0000000016 17# AA: Contents of section .debug_info:18# AA-NEXT: 0000 [[ADDR]] 00000000 aaaaaaaa 0000000019# AA: Contents of section .not_debug:20# AA-NEXT: 0000 bbbbbbbb 2a000000 00000000 .21 22## Specifying zero can get a behavior similar to GNU ld.23# RUN: ld.lld --icf=all -z dead-reloc-in-nonalloc=.debug_info=0 %t.o %tabs.o -o %tzero24# RUN: llvm-objdump -s %tzero | FileCheck %s --check-prefixes=COMMON,ZERO25 26# ZERO: Contents of section .debug_info:27# ZERO-NEXT: 0000 {{[0-9a-f]+}}000 00000000 00000000 0000000028 29## Glob works.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 -32 33## If a section matches multiple option. The last option wins.34# RUN: ld.lld --icf=all -z dead-reloc-in-nonalloc='.debug_info=1' \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.o38# RUN: ld.lld -shared -soname=t1.so %t1.o -o %t1.so39# RUN: ld.lld --gc-sections %t.o %t1.so -o %tso40# RUN: llvm-objdump -s %tso | FileCheck %s --check-prefix=SHARED41 42# SHARED: Contents of section .not_debug:43# SHARED-NEXT: 0000 08000000 00000000 00000000 .44 45## Test all possible invalid cases.46# RUN: not ld.lld -z dead-reloc-in-nonalloc= 2>&1 | FileCheck %s --check-prefix=USAGE47# RUN: not ld.lld -z dead-reloc-in-nonalloc=a= 2>&1 | FileCheck %s --check-prefix=USAGE48# RUN: not ld.lld -z dead-reloc-in-nonalloc==0 2>&1 | FileCheck %s --check-prefix=USAGE49 50# USAGE: error: -z dead-reloc-in-nonalloc=: expected <section_glob>=<value>51 52# RUN: not ld.lld -z dead-reloc-in-nonalloc=a=-1 2>&1 | FileCheck %s --check-prefix=NON-INTEGER53 54# NON-INTEGER: error: -z dead-reloc-in-nonalloc=: expected a non-negative integer, but got '-1'55 56# RUN: not ld.lld -z dead-reloc-in-nonalloc='['=0 2>&1 | FileCheck %s --check-prefix=INVALID57 58# INVALID: error: -z dead-reloc-in-nonalloc=: invalid glob pattern, unmatched '[': [59 60.globl _start61_start:62 ret63 64## .text.1 will be folded by ICF or discarded by --gc-sections.65.section .text.1,"ax"66 ret67 68.section .debug_addr69 .quad .text+870 .quad .text.1+871 72.section .debug_info73 .quad .text+874 .quad .text.1+875 76## Test a non-.debug_ section.77.section .not_debug78 .long .text.1+879 80 .quad bar81