File: sort2.s

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (45 lines) | stat: -rw-r--r-- 1,589 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tfile1.o

# RUN: echo "SECTIONS { .abc : { *(SORT(.foo.*) .a* .a* SORT(.bar.*) .b*) } }" > %t1.script
# RUN: ld.lld -o %t1 --script %t1.script %tfile1.o
# RUN: llvm-readelf -x .abc %t1 | FileCheck %s

## Sections matched by patterns between two SORT are sorted separately by input order.
## Note, GNU ld has a strange behavior with more than one SORT* https://sourceware.org/pipermail/binutils/2020-November/114083.html
## In the absence of SORT, our multi-pattern behavior matches GNU ld.
# CHECK:      Hex dump of section '.abc'
# CHECK-NEXT: 0x00000000 01020306 05040708 090b0c0a

# RUN: echo "SECTIONS { \
# RUN:   .abc : { *(SORT(.foo.* EXCLUDE_FILE (*file1.o) .bar.*) .a* SORT(.bar.*) .b*) } \
# RUN:  }" > %t2.script
# RUN: ld.lld -o %t2 --script %t2.script %tfile1.o
# RUN: llvm-readelf -x .abc %t2 | FileCheck %s

## Non-SORT patterns are sorted by --sort-section, breaking tie by input order.
# RUN: ld.lld -o %t4 --script %t1.script --sort-section=name %tfile1.o
# RUN: llvm-readelf -x .abc %t4 | FileCheck %s --check-prefix=CHECK2

# CHECK2:      Hex dump of section '.abc'
# CHECK2-NEXT: 0x00000000 01020304 05060708 090a0b0c

.text
.globl _start
_start:

.section .foo.2,"a"; .byte 2
.section .foo.3,"a"; .byte 3
.section .foo.1,"a"; .byte 1

.section .a6,"a"; .byte 6
.section .a5,"a"; .byte 5
.section .a4,"a"; .byte 4

.section .bar.7,"a"; .byte 7
.section .bar.9,"a"; .byte 9
.section .bar.8,"a"; .byte 8

.section .b11,"a"; .byte 11
.section .b12,"a"; .byte 12
.section .b10,"a"; .byte 10