brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 196fc73 Raw
40 lines · plain
1# REQUIRES: x862## SHF_GNU_RETAIN is a generic feature defined in the OS specific range. The3## flag marks a section as a GC root.4 5# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o6# RUN: ld.lld --gc-sections --print-gc-sections %t.o -o %t | count 07# RUN: llvm-readobj -hS %t | FileCheck %s8# RUN: ld.lld -r -e _start --gc-sections --print-gc-sections %t.o -o %t.ro | count 09# RUN: llvm-readobj -hS %t.ro | FileCheck %s10 11# CHECK:      Name: .retain12# CHECK-NEXT: Type: SHT_PROGBITS13# CHECK-NEXT: Flags [14# CHECK-NEXT:   SHF_ALLOC15# CHECK-NEXT:   SHF_GNU_RETAIN16# CHECK-NEXT: ]17 18# RUN: llvm-mc -filetype=obj -triple=x86_64 --defsym NONALLOC=1 %s -o %t1.o19# RUN: not ld.lld --gc-sections %t1.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR20 21# ERR: error: {{.*}}.o:(.nonalloc): sh_link points to discarded section {{.*}}.o:(.discard)22 23.global _start24_start:25 26.section .retain,"aR",@progbits27.quad .foo28 29.section .foo,"a",@progbits30.quad 031 32.ifdef NONALLOC33.section .discard,"a",@progbits34 35## With SHF_GNU_RETAIN, .nonalloc is retained while its linked-to section36## .discard is discarded, so there will be an error.37.section .nonalloc,"oR",@progbits,.discard38.quad .text39.endif40