File: linkorder.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 (83 lines) | stat: -rw-r--r-- 3,130 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o

## Contiguous SHF_LINK_ORDER sections.
# RUN: echo 'SECTIONS { .rodata : {BYTE(0) *(.rodata*) BYTE(4)} \
# RUN:   .text : {*(.text.bar) *(.text.foo)} }' > %t.lds
# RUN: ld.lld -T %t.lds %t.o -o %t
# RUN: llvm-readelf -S -x .rodata -x .text %t | FileCheck %s

# CHECK:      [ 1] .rodata   {{.*}} AL 3
# CHECK:      [ 3] .text     {{.*}} AX 0
# CHECK:      Hex dump of section '.rodata':
# CHECK-NEXT: 00030102 04
# CHECK:      Hex dump of section '.text':
# CHECK-NEXT: 0201

# RUN: echo 'SECTIONS { .rodata : {BYTE(0) *(.rodata*) BYTE(4)} \
# RUN:  .text : {*(.text.foo) *(.text.bar)} }' > %t1.lds
# RUN: ld.lld -T %t1.lds %t.o -o %t1
# RUN: llvm-readelf -S -x .rodata -x .text %t1 | FileCheck --check-prefix=CHECK1 %s

# CHECK1:      [ 1] .rodata   {{.*}} AL 3
# CHECK1:      [ 3] .text     {{.*}} AX 0
# CHECK1:      Hex dump of section '.rodata':
# CHECK1-NEXT: 00010302 04
# CHECK1:      Hex dump of section '.text':
# CHECK1-NEXT: 0102

## Adjacent input sections descriptions are contiguous.
## Orphan section .text.bar precedes .text.foo. However, don't swap the order of .rodata.*
## because they are in different InputSectionDescriptions.
# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) *(.rodata.bar)} }' > %t2.lds
# RUN: ld.lld -T %t2.lds %t.o -o %t2
# RUN: llvm-readelf -S -x .rodata %t2 | FileCheck --check-prefix=CHECK2 %s

# CHECK2:      [ 1] .rodata   {{.*}} AL 5
# CHECK2:      [ 4] .text.bar {{.*}} AX 0
# CHECK2-NEXT: [ 5] .text.foo {{.*}} AX 0
# CHECK2:      Hex dump of section '.rodata':
# CHECK2-NEXT: 010302

## Non-contiguous SHF_LINK_ORDER sections, separated by a BYTE.
# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) BYTE(0) *(.rodata.bar)} }' > %t3.lds
# RUN: ld.lld -T %t3.lds %t.o -o %t3
# RUN: llvm-readelf -S -x .rodata %t3 | FileCheck --check-prefix=CHECK3 %s

# CHECK3:      [ 1] .rodata   {{.*}} AL 5
# CHECK3:      [ 4] .text.bar {{.*}} AX 0
# CHECK3:      [ 5] .text.foo {{.*}} AX 0
# CHECK3:      Hex dump of section '.rodata':
# CHECK3-NEXT: 01000302

## Non-contiguous SHF_LINK_ORDER sections, separated by a non-SHF_LINK_ORDER section.
# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) *(.text) *(.rodata.bar)} }' > %t4.lds
# RUN: ld.lld -T %t4.lds %t.o -o %t4
# RUN: llvm-readelf -x .rodata %t4 | FileCheck --check-prefix=CHECK4 %s

# CHECK4:      Hex dump of section '.rodata':
# CHECK4-NEXT: 01cccccc 0302

## Non-contiguous SHF_LINK_ORDER sections, separated by a symbol assignment.
# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) a = .; *(.rodata.bar)} }' > %t5.lds
# RUN: ld.lld -T %t5.lds %t.o -o %t5
# RUN: llvm-readelf -S -x .rodata %t5 | FileCheck --check-prefix=CHECK2 %s

.global _start
_start:

.section .ro,"a"
.byte 0

.section .text.bar,"a",@progbits
.byte 2
.section .text.foo,"a",@progbits
.byte 1
.section .rodata.foo,"ao",@progbits,.text.foo
.byte 1
## If the two .rodata.bar sections are in the same InputSectionDescription,
## 03 (sh_link!=0) will be ordered before 02 (sh_link=0).
.section .rodata.bar,"a",@progbits
.byte 2
.section .rodata.bar,"ao",@progbits,.text.bar
.byte 3