File: sort2.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (45 lines) | stat: -rw-r--r-- 1,589 bytes parent folder | download | duplicates (21)
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