53 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o3# RUN: echo 'SECTIONS { .text : { *(.text*) } }' > %t1.script4 5## Sections within the same output section can be freely folded.6# RUN: ld.lld %t.o --script %t1.script --icf=all --print-icf-sections -o %t | FileCheck --check-prefix=ICF1 %s7# RUN: llvm-readelf -S %t | FileCheck --check-prefix=SEC1 %s --implicit-check-not=.text8 9# ICF1: selected section {{.*}}.o:(.text.foo0)10# ICF1-NEXT: removing identical section {{.*}}.o:(.text.foo1)11# ICF1-NEXT: removing identical section {{.*}}.o:(.text.bar0)12# ICF1-NEXT: removing identical section {{.*}}.o:(.text.bar1)13 14# SEC1: .text PROGBITS 0000000000000000 001000 00000115 16## Sections with different output sections cannot be folded. Without the17## linker script, .text.foo* and .text.bar* go to the same output section18## .text and they will be folded.19# RUN: echo 'SECTIONS { .text.foo : {*(.text.foo*)} .text.bar : {*(.text.bar*)} }' > %t2.script20# RUN: ld.lld %t.o --script %t2.script --icf=all --print-icf-sections -o %t | FileCheck --check-prefix=ICF2 %s21# RUN: llvm-readelf -S %t | FileCheck --check-prefix=SEC2 %s22 23# ICF2: selected section {{.*}}.o:(.text.foo0)24# ICF2-NEXT: removing identical section {{.*}}.o:(.text.foo1)25# ICF2-NEXT: selected section {{.*}}.o:(.text.bar0)26# ICF2-NEXT: removing identical section {{.*}}.o:(.text.bar1)27 28# SEC2: .text.foo PROGBITS 0000000000000000 001000 00000129# SEC2-NEXT: .text.bar PROGBITS 0000000000000001 001001 00000130 31## .text.bar* are orphan sections.32# RUN: echo 'SECTIONS { .text.foo : {*(.text.foo*)} }' > %t3.script33# RUN: ld.lld %t.o -T %t3.script --icf=all --print-icf-sections -o %t3 | FileCheck --check-prefix=ICF3 %s34# RUN: llvm-readelf -S %t3 | FileCheck --check-prefix=SEC3 %s35 36# ICF3: selected section {{.*}}.o:(.text.foo0)37# ICF3-NEXT: removing identical section {{.*}}.o:(.text.foo1)38 39# SEC3: Name Type Address Off Size40# SEC3: .text.foo PROGBITS 0000000000000000 001000 00000141# SEC3-NEXT: .text PROGBITS 0000000000000004 001004 00000042# SEC3-NEXT: .text.bar0 PROGBITS 0000000000000004 001004 00000143# SEC3-NEXT: .text.bar1 PROGBITS 0000000000000005 001005 00000144 45.section .text.foo0,"ax"46ret47.section .text.foo1,"ax"48ret49.section .text.bar0,"ax"50ret51.section .text.bar1,"ax"52ret53