File: icf-output-sections.s

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-6~deb10u4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,418,792 kB
  • sloc: cpp: 5,290,827; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,900; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,892; xml: 953; cs: 573; fortran: 539
file content (52 lines) | stat: -rw-r--r-- 2,344 bytes parent folder | download | duplicates (33)
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
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
# RUN: echo 'SECTIONS { .text : { *(.text*) } }' > %t1.script

## Sections within the same output section can be freely folded.
# RUN: ld.lld %t.o --script %t1.script --icf=all --print-icf-sections -o %t | FileCheck --check-prefix=ICF1 %s
# RUN: llvm-readelf -S %t | FileCheck --check-prefix=SEC1 %s --implicit-check-not=.text

# ICF1:      selected section {{.*}}.o:(.text.foo0)
# ICF1-NEXT:   removing identical section {{.*}}.o:(.text.foo1)
# ICF1-NEXT:   removing identical section {{.*}}.o:(.text.bar0)
# ICF1-NEXT:   removing identical section {{.*}}.o:(.text.bar1)

# SEC1: .text   PROGBITS 0000000000000000 001000 000001

## Sections with different output sections cannot be folded. Without the
## linker script, .text.foo* and .text.bar* go to the same output section
## .text and they will be folded.
# RUN: echo 'SECTIONS { .text.foo : {*(.text.foo*)} .text.bar : {*(.text.bar*)} }' > %t2.script
# RUN: ld.lld %t.o --script %t2.script --icf=all --print-icf-sections -o %t | FileCheck --check-prefix=ICF2 %s
# RUN: llvm-readelf -S %t | FileCheck --check-prefix=SEC2 %s

# ICF2:      selected section {{.*}}.o:(.text.foo0)
# ICF2-NEXT:   removing identical section {{.*}}.o:(.text.foo1)
# ICF2-NEXT: selected section {{.*}}.o:(.text.bar0)
# ICF2-NEXT:   removing identical section {{.*}}.o:(.text.bar1)

# SEC2:      .text.foo   PROGBITS 0000000000000000 001000 000001
# SEC2-NEXT: .text.bar   PROGBITS 0000000000000001 001001 000001

## .text.bar* are orphan sections.
# RUN: echo 'SECTIONS { .text.foo : {*(.text.foo*)} }' > %t3.script
# RUN: ld.lld %t.o -T %t3.script --icf=all --print-icf-sections -o %t3 | FileCheck --check-prefix=ICF3 %s
# RUN: llvm-readelf -S %t3 | FileCheck --check-prefix=SEC3 %s

# ICF3:      selected section {{.*}}.o:(.text.foo0)
# ICF3-NEXT:   removing identical section {{.*}}.o:(.text.foo1)

# SEC3:      Name        Type     Address          Off    Size
# SEC3:      .text.foo   PROGBITS 0000000000000000 001000 000001
# SEC3-NEXT: .text       PROGBITS 0000000000000004 001004 000000
# SEC3-NEXT: .text.bar0  PROGBITS 0000000000000004 001004 000001
# SEC3-NEXT: .text.bar1  PROGBITS 0000000000000005 001005 000001

.section .text.foo0,"ax"
ret
.section .text.foo1,"ax"
ret
.section .text.bar0,"ax"
ret
.section .text.bar1,"ax"
ret