• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
2## -z keep-text-section-prefix separates text sections with prefix .text.hot,
3## .text.unknown, .text.unlikely, .text.startup, or .text.exit, in the absence
4## of a SECTIONS command.
5
6# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
7# RUN: ld.lld %t.o -o %t1
8# RUN: llvm-readelf -S %t1 | FileCheck --check-prefix=NOKEEP %s
9# RUN: ld.lld -z nokeep-text-section-prefix %t.o -o %t2
10# RUN: cmp %t1 %t2
11
12# RUN: ld.lld -z keep-text-section-prefix %t.o -o %t.keep
13# RUN: llvm-readelf -S %t.keep | FileCheck --check-prefix=KEEP %s
14
15# KEEP:      [ 1] .text
16# KEEP-NEXT: [ 2] .text.hot
17# KEEP-NEXT: [ 3] .text.unknown
18# KEEP-NEXT: [ 4] .text.split
19# KEEP-NEXT: [ 5] .text.startup
20# KEEP-NEXT: [ 6] .text.exit
21# KEEP-NEXT: [ 7] .text.unlikely
22
23# NOKEEP:    [ 1] .text
24# NOKEEP-NOT:     .text
25
26## With a SECTIONS command, orphan sections are created verbatim.
27## No grouping is performed for them.
28# RUN: echo 'SECTIONS {}' > %t.lds
29# RUN: ld.lld -T %t.lds -z keep-text-section-prefix %t.o -o %t.script
30# RUN: llvm-readelf -S %t.script | FileCheck --check-prefix=SCRIPT %s
31
32# SCRIPT:      .text
33# SCRIPT-NEXT: .text.f
34# SCRIPT-NEXT: .text.hot.f_hot
35# SCRIPT-NEXT: .text.unknown.f_unknown
36# SCRIPT-NEXT: .text.split.f_split
37# SCRIPT-NEXT: .text.startup.f_startup
38# SCRIPT-NEXT: .text.exit.f_exit
39# SCRIPT-NEXT: .text.unlikely.f_unlikely
40
41.globl _start
42_start:
43  ret
44
45.section .text.f,"ax"
46  nop
47
48.section .text.hot.f_hot,"ax"
49  nop
50
51.section .text.unknown.f_unknown,"ax"
52  nop
53
54.section .text.split.f_split,"ax"
55  nop
56
57.section .text.startup.f_startup,"ax"
58  nop
59
60.section .text.exit.f_exit,"ax"
61  nop
62
63.section .text.unlikely.f_unlikely,"ax"
64  nop
65