1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tfile1.o
3# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/exclude-multiple1.s -o %tfile2.o
4# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/exclude-multiple2.s -o %tfile3.o
5# RUN: echo "SECTIONS { \
6# RUN:   .foo : { *(.foo.1 EXCLUDE_FILE (*file1.o) .foo.2 EXCLUDE_FILE (*file2.o) .foo.3) } \
7# RUN:  }" > %t1.script
8# RUN: ld.lld -script %t1.script %tfile1.o %tfile2.o %tfile3.o -o %t1.o
9# RUN: llvm-objdump -s %t1.o | FileCheck %s
10
11## Sections from %tfile1 precede sections from %tfile2 and %tfile3.
12## In each file, the sections are added in the original order.
13# CHECK:      Contents of section .foo:
14# CHECK-NEXT:  03000000 00000000 01000000 00000000
15# CHECK-NEXT:  04000000 00000000 05000000 00000000
16# CHECK-NEXT:  07000000 00000000 08000000 00000000
17# CHECK-NEXT:  09000000 00000000
18# CHECK-NEXT: Contents of section .foo.2:
19# CHECK-NEXT:  02000000 00000000
20# CHECK-NEXT: Contents of section .foo.3:
21# CHECK-NEXT:  06000000 00000000
22
23# RUN: echo "SECTIONS { .foo : { *(EXCLUDE_FILE (*file1.o) EXCLUDE_FILE (*file2.o) .foo.3) } }" > %t2.script
24# RUN: not ld.lld -script %t2.script %tfile1.o %tfile2.o %tfile3.o -o /dev/null 2>&1 | \
25# RUN:   FileCheck %s --check-prefix=ERR
26# ERR: section pattern is expected
27
28# RUN: echo "SECTIONS { .foo : { *(EXCLUDE_FILE (*file1.o)) } }" > %t3.script
29# RUN: not ld.lld -script %t3.script %tfile1.o %tfile2.o %tfile3.o -o /dev/null 2>&1 | \
30# RUN:   FileCheck %s --check-prefix=ERR
31
32.section .foo.2,"a"
33 .quad 2
34
35## %tfile1.o(.foo.3) precedes %tfile.o(.foo.1) in the output section.
36.section .foo.3,"a"
37 .quad 3
38
39.section .foo.1,"a"
40 .quad 1
41