xref: /llvm-project/lld/test/ELF/linkerscript/overwrite-sections-discard.test (revision 899fdf548eee427fe08e462955e6f817ca949730)
1# REQUIRES: x86
2# RUN: split-file %s %t
3# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
4
5## /DISCARD/ specified by OVERWRITE_SECTIONS can discard sections as well.
6
7# RUN: ld.lld %t/overwrite.lds -T %t/main.lds %t/a.o -o %t1 2>&1 | count 0
8# RUN: llvm-readelf -S -l %t1 | FileCheck %s
9# RUN: ld.lld %t/overwrite.lds %t/overwrite.lds -T %t/main.lds %t/a.o -o %t1 2>&1 | count 0
10# RUN: llvm-readelf -S -l %t1 | FileCheck %s
11
12# CHECK:     Name
13# CHECK-NOT: .data
14
15#--- a.s
16.globl _start
17_start:
18
19.section .data.1,"aw"; .byte 1
20.section .data.2,"aw"; .byte 2
21
22#--- main.lds
23SECTIONS {
24  /DISCARD/ : { *(.data.1) }
25}
26
27#--- overwrite.lds
28OVERWRITE_SECTIONS {
29  /DISCARD/ : { *(.data.2) }
30}
31