1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64 -save-temp-labels %s -o %t.o 3 4# RUN: ld.lld --discard-locals %t.o -o %tlocal 5# RUN: llvm-readelf -s %tlocal | FileCheck --check-prefixes=DISCARD-LOCALS,DISCARD-LOCALS-NOGC %s 6 7## --gc-sections can discard symbols relative to GCed sections (including STT_SECTION). 8# RUN: ld.lld --discard-locals --gc-sections %t.o -o %tlocal.gc 9# RUN: llvm-readelf -s %tlocal.gc | FileCheck --check-prefix=DISCARD-LOCALS %s 10 11# RUN: ld.lld --discard-all %t.o -o %tall 12# RUN: llvm-readelf -s %tall | FileCheck --check-prefix=DISCARD-ALL %s 13 14# RUN: ld.lld --discard-all --gc-sections %t.o -o %tall.gc 15# RUN: llvm-readelf -s %tall.gc | FileCheck --check-prefix=DISCARD-ALL %s 16 17## --discard-locals removes local symbols which start with ".L" 18# DISCARD-LOCALS: 0: {{0+}} 0 NOTYPE LOCAL DEFAULT UND 19# DISCARD-LOCALS-NEXT: NOTYPE LOCAL DEFAULT {{.*}} used 20# DISCARD-LOCALS-NEXT: NOTYPE LOCAL DEFAULT {{.*}} unused 21# DISCARD-LOCALS-NOGC-NEXT: NOTYPE LOCAL DEFAULT {{.*}} unused_gc 22# DISCARD-LOCALS-NEXT: NOTYPE GLOBAL DEFAULT {{.*}} _start 23 24## --discard-all removes all regular local symbols. 25# DISCARD-ALL: 0: {{0+}} 0 NOTYPE LOCAL DEFAULT UND 26# DISCARD-ALL-NEXT: NOTYPE GLOBAL DEFAULT {{.*}} _start 27 28.globl _start 29_start: 30 call text@plt 31 jmp .Lused@plt 32 call used@plt 33 34.section text,"ax" 35.Lunused: 36.Lused: 37unused: 38used: 39 40.section gc,"ax" 41.Lunused_gc: 42unused_gc: 43 ret 44