File: linkorder-linked-to.s

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (74 lines) | stat: -rw-r--r-- 2,666 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
# REQUIRES: x86
## Test how we set the sh_link field of a SHF_LINK_ORDER output section.
## Additionally, test that in a relocatable link, SHF_LINK_ORDER sections are
## not combined. Combining them will arbitrarily choose a single output
## section, losing tracking of correct dependencies.

# RUN: llvm-mc -filetype=obj --triple=x86_64 %s -o %t.o

## In the absence of a SECTIONS command.
# RUN: ld.lld %t.o -o %t
# RUN: llvm-readelf -S -x foo %t | FileCheck --check-prefixes=EXE,EXE-HEX %s
# RUN: ld.lld %t.o -o %t.ro -r
# RUN: llvm-readelf -S %t.ro | FileCheck --check-prefix=REL %s

## A non-relocatable link places readonly sections before read-executable sections.
# EXE:      [Nr] Name     {{.*}} Flg Lk
# EXE-NEXT: [ 0]
# EXE-NEXT: [ 1] foo      {{.*}}  AL  2
# EXE-NEXT: [ 2] .text    {{.*}}  AX  0

## An implementation detail: foo is moved after its linked-to section (orphan).
# REL:      [Nr] Name     {{.*}} Flg Lk
# REL-NEXT: [ 0]
# REL-NEXT: [ 1] .text    {{.*}}  AX  0
# REL-NEXT: [ 2] .text.f1 {{.*}}  AX  0
# REL-NEXT: [ 3] foo      {{.*}}  AL  2
# REL-NEXT: [ 4] .text.f2 {{.*}}  AX  0
# REL-NEXT: [ 5] foo      {{.*}}  AL  4

## A SECTIONS command combines .text.*
# RUN: echo 'SECTIONS { .text : { *(.text.f1) *(.text.f2) } }' > %t1.lds
# RUN: ld.lld -T %t1.lds %t.o -o %t1
# RUN: llvm-readelf -S -x foo %t1 | FileCheck --check-prefixes=EXE,EXE-HEX %s
# RUN: ld.lld -T %t1.lds %t.o -o %t1.ro -r
# RUN: llvm-readelf -S -x foo %t1.ro | FileCheck --check-prefix=REL1 %s

# REL1:      [Nr] Name    {{.*}} Flg Lk
# REL1-NEXT: [ 0]
# REL1-NEXT: [ 1] .text   {{.*}}  AX  0
# REL1-NEXT: [ 2] foo     {{.*}}  AL  1

## A SECTIONS command separates .text.*
# RUN: echo 'SECTIONS { .text.f1 : { *(.text.f1) } .text.f2 : { *(.text.f2) } }' > %t2.lds
# RUN: ld.lld -T %t2.lds %t.o -o %t2
# RUN: llvm-readelf -S -x foo %t2 | FileCheck --check-prefixes=EXE2,EXE-HEX %s
# RUN: ld.lld -T %t2.lds %t.o -o %t2.ro -r
# RUN: llvm-readelf -S %t2.ro | FileCheck --check-prefixes=REL2 %s

# EXE2:      [Nr] Name     {{.*}} Flg Lk
# EXE2-NEXT: [ 0]
# EXE2-NEXT: [ 1] foo      {{.*}}  AL  2
# EXE2-NEXT: [ 2] .text.f1 {{.*}}  AX  0
# EXE2-NEXT: [ 3] .text.f2 {{.*}}  AX  0

# REL2:      [Nr] Name     {{.*}} Flg Lk
# REL2-NEXT: [ 0]
# REL2-NEXT: [ 1] .text.f1 {{.*}}  AX  0
# REL2-NEXT: [ 2] .text.f2 {{.*}}  AX  0
# REL2-NEXT: [ 3] .text    {{.*}}  AX  0
# REL2-NEXT: [ 4] foo      {{.*}}  AL  1
# REL2-NEXT: [ 5] foo      {{.*}}  AL  2

# EXE-HEX:      Hex dump of section 'foo':
# EXE-HEX-NEXT: 0102

.section .text.f1,"ax",@progbits
ret
.section .text.f2,"ax",@progbits
ret

.section foo,"ao",@progbits,.text.f2
.byte 2
.section foo,"ao",@progbits,.text.f1
.byte 1