File: gc-sections-with-provide.s

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,999,584 kB
  • sloc: cpp: 6,951,724; ansic: 1,486,157; asm: 913,598; python: 232,059; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,079; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,430; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (60 lines) | stat: -rw-r--r-- 1,222 bytes parent folder | download | duplicates (5)
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
# REQUIRES: x86

# This test verifies that garbage-collection is correctly garbage collecting
# unused sections when the symbol of the unused section is only referred by
# an unused PROVIDE symbol.

# RUN: rm -rf %t && split-file %s %t && cd %t
# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
# RUN: ld.lld -o a_nogc a.o -T script.t
# RUN: llvm-nm a_nogc | FileCheck -check-prefix=NOGC %s
# RUN: ld.lld -o a_gc a.o --gc-sections --print-gc-sections -T script.t | FileCheck --check-prefix=GC_LINK %s
# RUN: llvm-nm a_gc | FileCheck -check-prefix=GC %s

NOGC-NOT: another_unused
NOGC: another_used
NOGC: bar
NOGC: baz
NOGC: baz_ref
NOGC: foo
NOGC-NOT: unused
NOGC: used

GC_LINK: removing unused section a.o:(.text.bar)

GC-NOT: another_unused
GC: another_used
GC-NOT: bar
GC: baz
GC: baz_ref
GC: foo
GC-NOT: unused
GC: used

#--- a.s
.global _start
_start:
 call foo
 call used

.section .text.foo,"ax",@progbits
foo:
 nop

.section .text.bar,"ax",@progbits
.global bar
bar:
 nop

.section .text.baz,"ax",@progbits
.global baz
baz:
 nop


#--- script.t
PROVIDE(unused = bar + used);
PROVIDE(used = another_used);
PROVIDE(baz_ref = baz);
PROVIDE(another_used = baz_ref);
PROVIDE(another_unused = unused + bar + 0x1);