[lld] 164a02d - [ELF]: --icf: don't fold sections referencing sections with LCDA after D84610

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 13:42:32 PDT 2020


Author: Fangrui Song
Date: 2020-08-07T13:42:25-07:00
New Revision: 164a02d0fa461c623446bb5e3ee15516bcfad13c

URL: https://github.com/llvm/llvm-project/commit/164a02d0fa461c623446bb5e3ee15516bcfad13c
DIFF: https://github.com/llvm/llvm-project/commit/164a02d0fa461c623446bb5e3ee15516bcfad13c.diff

LOG: [ELF]: --icf: don't fold sections referencing sections with LCDA after D84610

Added: 
    

Modified: 
    lld/ELF/ICF.cpp
    lld/test/ELF/icf-eh-frame.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index c9d922f558dc..f3c477c1d2c2 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -468,9 +468,10 @@ template <class ELFT> void ICF<ELFT>::run() {
   //
   // If two .gcc_except_table have identical semantics (usually identical
   // content with PC-relative encoding), we will lose folding opportunity.
+  uint32_t uniqueId = 0;
   for (Partition &part : partitions)
     part.ehFrame->iterateFDEWithLSDA<ELFT>(
-        [&](InputSection &s) { s.eqClass[0] = 1; });
+        [&](InputSection &s) { s.eqClass[0] = ++uniqueId; });
 
   // Collect sections to merge.
   for (InputSectionBase *sec : inputSections) {

diff  --git a/lld/test/ELF/icf-eh-frame.s b/lld/test/ELF/icf-eh-frame.s
index e90df5f96d9f..0b895ec8cc2c 100644
--- a/lld/test/ELF/icf-eh-frame.s
+++ b/lld/test/ELF/icf-eh-frame.s
@@ -41,3 +41,10 @@ _Z1dv:
 .section .gcc_except_table,"a", at progbits
 ## The actual content does not matter.
 .Lexception0:
+
+## .rodata.Z1[ab]v reference .text.Z1[ab]v. Dont fold them.
+.section .rodata.Z1av,"a", at progbits
+  .long .text.Z1av - .
+
+.section .rodata.Z1bv,"a", at progbits
+  .long .text.Z1bv - .


        


More information about the llvm-commits mailing list