forked from OSchip/llvm-project
ELF: Do not ICF sections named with a C identifier.
A user program may enumerate sections named with a C identifier using __start_* and __stop_* symbols. We cannot ICF any such sections because that could change program semantics. Differential Revision: https://reviews.llvm.org/D47242 llvm-svn: 333054
This commit is contained in:
parent
fedae33efa
commit
7ab7f149b2
|
@ -188,6 +188,12 @@ static bool isEligible(InputSection *S) {
|
|||
if (S->Name == ".init" || S->Name == ".fini")
|
||||
return false;
|
||||
|
||||
// A user program may enumerate sections named with a C identifier using
|
||||
// __start_* and __stop_* symbols. We cannot ICF any such sections because
|
||||
// that could change program semantics.
|
||||
if (isValidCIdentifier(S->Name))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
||||
# RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections | count 0
|
||||
|
||||
.section foo,"ax",@progbits,unique,0
|
||||
.byte 42
|
||||
|
||||
.section foo,"ax",@progbits,unique,1
|
||||
.byte 42
|
|
@ -2,8 +2,8 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
||||
# RUN: ld.lld %t -o %t2 --icf=all --print-icf-sections | count 0
|
||||
|
||||
.section foo,"ax"
|
||||
.section .foo,"ax"
|
||||
.byte 42
|
||||
|
||||
.section bar,"ax"
|
||||
.section .bar,"ax"
|
||||
.byte 42
|
||||
|
|
Loading…
Reference in New Issue