xref: /llvm-project/lld/test/ELF/gc-sections-lsda.s (revision 6a1235211dab51855d51481daf4099c96221c4bf)
1# REQUIRES: x86
2# RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
3
4## Discard an unused .gcc_except_table in a COMDAT group or having SHF_LINK_ORDER
5## if the associated text section is discarded.
6
7# RUN: ld.lld --gc-sections --print-gc-sections -u _Z3foov %t.o -o /dev/null | \
8# RUN:   FileCheck %s --implicit-check-not=.gcc_except_table
9
10# CHECK:      removing unused section {{.*}}.o:(.text._Z6comdatv)
11# CHECK-NEXT: removing unused section {{.*}}.o:(.text._Z9linkorderv)
12# CHECK-NEXT: removing unused section {{.*}}.o:(.gcc_except_table._Z6comdatv)
13# CHECK-NEXT: removing unused section {{.*}}.o:(.gcc_except_table._Z9linkorderv)
14
15## An unused non-group non-SHF_LINK_ORDER .gcc_except_table is not discarded.
16
17# RUN: ld.lld --gc-sections --print-gc-sections -u _Z6comdatv -u _Z9linkorderv %t.o -o /dev/null | \
18# RUN:   FileCheck /dev/null --implicit-check-not=.gcc_except_table
19
20## If the text sections are live, the .gcc_except_table sections are retained as
21## well because they are referenced by .eh_frame pieces.
22
23# RUN: ld.lld --gc-sections --print-gc-sections -u _Z3foov -u _Z6comdatv -u _Z9linkorderv %t.o -o /dev/null | \
24# RUN:   FileCheck %s --check-prefix=KEEP
25
26# KEEP-NOT: .gcc_except_table
27
28.section .text._Z3foov,"ax",@progbits
29.globl _Z3foov
30_Z3foov:
31  .cfi_startproc
32  ret
33  .cfi_lsda 0x1b,.Lexception0
34  .cfi_endproc
35
36.section .text._Z6comdatv,"axG",@progbits,_Z6comdatv,comdat
37.globl _Z6comdatv
38_Z6comdatv:
39  .cfi_startproc
40  ret
41  .cfi_lsda 0x1b,.Lexception1
42  .cfi_endproc
43
44.section .text._Z9linkorderv,"ax",@progbits
45.globl _Z9linkorderv
46_Z9linkorderv:
47  .cfi_startproc
48  ret
49  .cfi_lsda 0x1b,.Lexception2
50  .cfi_endproc
51
52.section .gcc_except_table._Z3foov,"a",@progbits
53.Lexception0:
54  .byte 255
55
56.section .gcc_except_table._Z6comdatv,"aG",@progbits,_Z6comdatv,comdat
57.Lexception1:
58  .byte 255
59
60.section .gcc_except_table._Z9linkorderv,"ao",@progbits,_Z9linkorderv
61.Lexception2:
62  .byte 255
63