1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tfile1.o 3 4# RUN: echo "SECTIONS { .abc : { *(SORT(.foo.*) .a* .a* SORT(.bar.*) .b*) } }" > %t1.script 5# RUN: ld.lld -o %t1 --script %t1.script %tfile1.o 6# RUN: llvm-readelf -x .abc %t1 | FileCheck %s 7 8## Sections matched by patterns between two SORT are sorted separately by input order. 9## Note, GNU ld has a strange behavior with more than one SORT* https://sourceware.org/pipermail/binutils/2020-November/114083.html 10## In the absence of SORT, our multi-pattern behavior matches GNU ld. 11# CHECK: Hex dump of section '.abc' 12# CHECK-NEXT: 0x00000000 01020306 05040708 090b0c0a 13 14# RUN: echo "SECTIONS { \ 15# RUN: .abc : { *(SORT(.foo.* EXCLUDE_FILE (*file1.o) .bar.*) .a* SORT(.bar.*) .b*) } \ 16# RUN: }" > %t2.script 17# RUN: ld.lld -o %t2 --script %t2.script %tfile1.o 18# RUN: llvm-readelf -x .abc %t2 | FileCheck %s 19 20## Non-SORT patterns are sorted by --sort-section, breaking tie by input order. 21# RUN: ld.lld -o %t4 --script %t1.script --sort-section=name %tfile1.o 22# RUN: llvm-readelf -x .abc %t4 | FileCheck %s --check-prefix=CHECK2 23 24# CHECK2: Hex dump of section '.abc' 25# CHECK2-NEXT: 0x00000000 01020304 05060708 090a0b0c 26 27.text 28.globl _start 29_start: 30 31.section .foo.2,"a"; .byte 2 32.section .foo.3,"a"; .byte 3 33.section .foo.1,"a"; .byte 1 34 35.section .a6,"a"; .byte 6 36.section .a5,"a"; .byte 5 37.section .a4,"a"; .byte 4 38 39.section .bar.7,"a"; .byte 7 40.section .bar.9,"a"; .byte 9 41.section .bar.8,"a"; .byte 8 42 43.section .b11,"a"; .byte 11 44.section .b12,"a"; .byte 12 45.section .b10,"a"; .byte 10 46