1# REQUIRES: x86 2 3# This test verifies that garbage-collection is correctly garbage collecting 4# unused sections when the symbol of the unused section is only referred by 5# an unused PROVIDE symbol. 6 7# RUN: rm -rf %t && split-file %s %t && cd %t 8# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o 9# RUN: ld.lld -o a_nogc a.o -T script.t 10# RUN: llvm-nm a_nogc | FileCheck -check-prefix=NOGC %s 11# RUN: ld.lld -o a_gc a.o --gc-sections --print-gc-sections -T script.t | FileCheck --check-prefix=GC_LINK %s 12# RUN: llvm-nm a_gc | FileCheck -check-prefix=GC %s 13 14NOGC-NOT: another_unused 15NOGC: another_used 16NOGC: bar 17NOGC: baz 18NOGC: baz_ref 19NOGC: foo 20NOGC-NOT: unused 21NOGC: used 22 23GC_LINK: removing unused section a.o:(.text.bar) 24 25GC-NOT: another_unused 26GC: another_used 27GC-NOT: bar 28GC: baz 29GC: baz_ref 30GC: foo 31GC-NOT: unused 32GC: used 33 34#--- a.s 35.global _start 36_start: 37 call foo 38 call used 39 40.section .text.foo,"ax",@progbits 41foo: 42 nop 43 44.section .text.bar,"ax",@progbits 45.global bar 46bar: 47 nop 48 49.section .text.baz,"ax",@progbits 50.global baz 51baz: 52 nop 53 54 55#--- script.t 56PROVIDE(unused = bar + "used"); 57PROVIDE("used" = another_used); 58PROVIDE(baz_ref = baz); 59PROVIDE(another_used = baz_ref); 60PROVIDE(another_unused = unused + bar + 0x1); 61