brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.6 KiB · 5381532 Raw
177 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64 %S/Inputs/shared.s -o %ta.o3# RUN: ld.lld -shared -soname=ta %ta.o -o %ta.so4 5# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o6# RUN: llvm-objcopy %t1.o %t1copy.o7# RUN: llvm-objcopy --localize-symbol=h1 %t1.o %t1changed.o8# RUN: ld.lld -r %t1.o -o %t1reloc.o9# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-safe.s -o %t2.o10# RUN: ld.lld %t1.o %t2.o -o %t2 --icf=safe --print-icf-sections --export-dynamic | FileCheck %s11# RUN: ld.lld %t1copy.o %t2.o -o %t2 --icf=safe --print-icf-sections | FileCheck %s12# RUN: ld.lld %t1.o %t2.o -o %t3 --icf=safe --print-icf-sections -shared | FileCheck --check-prefix=EXPORT %s13## Exported symbols are suppressed for ICF when dynamic linking is enabled.14# RUN: ld.lld %t1.o %t2.o %ta.so -o %t3 --icf=safe --print-icf-sections --export-dynamic | FileCheck --check-prefix=EXPORT %s15# RUN: ld.lld %t1.o %t2.o -o %t2 --icf=all --print-icf-sections | FileCheck --check-prefix=ALL %s16# RUN: ld.lld %t1.o %t2.o %ta.so -o %t2 --icf=all --print-icf-sections --export-dynamic | FileCheck --check-prefix=ALL-EXPORT %s17# RUN: ld.lld %t1changed.o -o %t4 --icf=safe 2>&1 | FileCheck --check-prefix=SH_LINK_0 %s18# RUN: ld.lld %t1reloc.o -o %t4 --icf=safe 2>&1 | FileCheck --check-prefix=SH_LINK_0 %s19 20# CHECK-NOT:  {{.}}21# CHECK:      selected section {{.*}}:(.rodata.h3)22# CHECK-NEXT:   removing identical section {{.*}}:(.rodata.h4)23# CHECK-NEXT: selected section {{.*}}:(.text.f3)24# CHECK-NEXT:   removing identical section {{.*}}:(.text.f4)25# CHECK-NEXT: selected section {{.*}}:(.rodata.g3)26# CHECK-NEXT:   removing identical section {{.*}}:(.rodata.g4)27# CHECK-NEXT: selected section {{.*}}:(.rodata.l3)28# CHECK-NEXT:   removing identical section {{.*}}:(.rodata.l4)29# CHECK-NEXT: selected section {{.*}}:(.text)30# CHECK-NEXT:   removing identical section {{.*}}:(.text)31# CHECK-NOT:  {{.}}32 33# With --icf=all address-significance implies keep-unique only for rodata, not34# text.35# ALL-NOT:  {{.}}36# ALL:      selected section {{.*}}:(.rodata.h3)37# ALL-NEXT:   removing identical section {{.*}}:(.rodata.h4)38# ALL-NEXT: selected section {{.*}}:(.text.f3)39# ALL-NEXT:   removing identical section {{.*}}:(.text.f4)40# ALL-NEXT: selected section {{.*}}:(.text.f1)41# ALL-NEXT:   removing identical section {{.*}}:(.text.f2)42# ALL-NEXT:   removing identical section {{.*}}:(.text.non_addrsig1)43# ALL-NEXT:   removing identical section {{.*}}:(.text.non_addrsig2)44# ALL-NEXT: selected section {{.*}}:(.rodata.g3)45# ALL-NEXT:   removing identical section {{.*}}:(.rodata.g4)46# ALL-NEXT: selected section {{.*}}:(.rodata.l3)47# ALL-NEXT:   removing identical section {{.*}}:(.rodata.l4)48# ALL-NEXT: selected section {{.*}}:(.text)49# ALL-NEXT:   removing identical section {{.*}}:(.text)50# ALL-NOT:  {{.}}51 52# llvm-mc normally emits an empty .text section into every object file. Since53# nothing actually refers to it via a relocation, it doesn't have any associated54# symbols (thus nor can anything refer to it via a relocation, making it safe to55# merge with the empty section in the other input file). Here we check that the56# only two sections merged are the two empty sections and the sections with only57# STB_LOCAL or STV_HIDDEN symbols. The dynsym entries should have prevented58# anything else from being merged.59# EXPORT-NOT:  {{.}}60# EXPORT:      selected section {{.*}}:(.rodata.h3)61# EXPORT-NEXT:   removing identical section {{.*}}:(.rodata.h4)62# EXPORT-NEXT: selected section {{.*}}:(.rodata.l3)63# EXPORT-NEXT:   removing identical section {{.*}}:(.rodata.l4)64# EXPORT-NOT:  {{.}}65 66# If --icf=all is specified when exporting we can also merge the exported text67# sections, but not the exported rodata.68# ALL-EXPORT-NOT:  {{.}}69# ALL-EXPORT:      selected section {{.*}}:(.rodata.h3)70# ALL-EXPORT-NEXT:   removing identical section {{.*}}:(.rodata.h4)71# ALL-EXPORT-NEXT: selected section {{.*}}:(.text.f3)72# ALL-EXPORT-NEXT:   removing identical section {{.*}}:(.text.f4)73# ALL-EXPORT-NEXT: selected section {{.*}}:(.text.f1)74# ALL-EXPORT-NEXT:   removing identical section {{.*}}:(.text.f2)75# ALL-EXPORT-NEXT:   removing identical section {{.*}}:(.text.non_addrsig1)76# ALL-EXPORT-NEXT:   removing identical section {{.*}}:(.text.non_addrsig2)77# ALL-EXPORT-NEXT: selected section {{.*}}:(.rodata.l3)78# ALL-EXPORT-NEXT:   removing identical section {{.*}}:(.rodata.l4)79# ALL-EXPORT-NEXT: selected section {{.*}}:(.text)80# ALL-EXPORT-NEXT:   removing identical section {{.*}}:(.text)81# ALL-EXPORT-NOT:  {{.}}82 83# SH_LINK_0: --icf=safe conservatively ignores SHT_LLVM_ADDRSIG [index [[#]]] with sh_link=0 (likely created using objcopy or ld -r)84 85.globl _start86_start:87 88.section .text.f1,"ax",@progbits89.globl f190f1:91ret92 93.section .text.f2,"ax",@progbits94.globl f295f2:96ret97 98.section .text.f3,"ax",@progbits99.globl f3100f3:101ud2102 103.section .text.f4,"ax",@progbits104.globl f4105f4:106ud2107 108.section .rodata.g1,"a",@progbits109.globl g1110g1:111.byte 1112 113.section .rodata.g2,"a",@progbits114.globl g2115g2:116.byte 1117 118.section .rodata.g3,"a",@progbits119.globl g3120g3:121.byte 2122 123.section .rodata.g4,"a",@progbits124.globl g4125g4:126.byte 2127 128.section .rodata.l1,"a",@progbits129l1:130.byte 3131 132.section .rodata.l2,"a",@progbits133l2:134.byte 3135 136.section .rodata.l3,"a",@progbits137l3:138.byte 4139 140.section .rodata.l4,"a",@progbits141l4:142.byte 4143 144.section .rodata.h1,"a",@progbits145.globl h1146.hidden h1147h1:148.byte 5149 150.section .rodata.h2,"a",@progbits151.globl h2152.hidden h2153h2:154.byte 5155 156.section .rodata.h3,"a",@progbits157.globl h3158.hidden h3159h3:160.byte 6161 162.section .rodata.h4,"a",@progbits163.globl h4164.hidden h4165h4:166.byte 6167 168.addrsig169.addrsig_sym f1170.addrsig_sym f2171.addrsig_sym g1172.addrsig_sym g2173.addrsig_sym l1174.addrsig_sym l2175.addrsig_sym h1176.addrsig_sym h2177