52 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t && split-file %s %t && cd %t3# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o4# RUN: ld.lld a.o --gc-sections --script nokeep.t -o a5# RUN: llvm-objdump --section-headers a | FileCheck --check-prefix=NOKEEP %s6# RUN: ld.lld a.o --gc-sections --script keep.t -o a7# RUN: llvm-objdump --section-headers a | FileCheck --check-prefix=KEEP %s8 9# NOKEEP: Sections:10# NOKEEP-NEXT: Idx Name Size11# NOKEEP-NEXT: 0 0000000012# NOKEEP-NEXT: 1 .text 0000000413# NOKEEP-NEXT: 2 .keep1 0000000014 15# KEEP: Sections:16# KEEP-NEXT: Idx Name Size17# KEEP-NEXT: 0 0000000018# KEEP-NEXT: 1 .text 0000000419# KEEP-NEXT: 2 .keep1 0000000420# KEEP-NEXT: 3 .keep2 0000000421 22#--- a.s23.global _start24_start:25 .long 126 27.section .keep1, "a"28keep1:29 .long 230 31.section .keep2, "a"32keep2:33 .long 334 35#--- nokeep.t36SECTIONS {37 .text : { *(.text) }38 OVERLAY 0x1000 : AT ( 0x4000 ) {39 .keep1 { *(.keep1) }40 .keep2 { *(.keep2) }41 }42}43 44#--- keep.t45SECTIONS {46 .text : { *(.text) }47 OVERLAY 0x1000 : AT ( 0x4000 ) {48 .keep1 { KEEP(*(.keep1)) }49 .keep2 { KEEP(*(.keep2)) }50 }51}52