[lld] 5f4d7b2 - [ELF] Improve --icf=safe diagnostic

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 5 09:37:44 PST 2021


Author: Fangrui Song
Date: 2021-02-05T09:37:37-08:00
New Revision: 5f4d7b2f0ab2f7a8395077572e140ae5c5d1f60b

URL: https://github.com/llvm/llvm-project/commit/5f4d7b2f0ab2f7a8395077572e140ae5c5d1f60b
DIFF: https://github.com/llvm/llvm-project/commit/5f4d7b2f0ab2f7a8395077572e140ae5c5d1f60b.diff

LOG: [ELF] Improve --icf=safe diagnostic

The current diagnostic has confused users. The new wording is adapted from one suggested by Ian Lance Taylor.

Differential Revision: https://reviews.llvm.org/D95917

Added: 
    

Modified: 
    lld/ELF/InputFiles.cpp
    lld/test/ELF/icf-safe.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index a23491d62dc8..0f6afadd9bff 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -592,8 +592,12 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats) {
         if (sec.sh_link != 0)
           this->addrsigSec = &sec;
         else if (config->icf == ICFLevel::Safe)
-          warn(toString(this) + ": --icf=safe is incompatible with object "
-                                "files created using objcopy or ld -r");
+          warn(toString(this) +
+               ": --icf=safe conservatively ignores "
+               "SHT_LLVM_ADDRSIG [index " +
+               Twine(i) +
+               "] with sh_link=0 "
+               "(likely created using objcopy or ld -r)");
       }
       this->sections[i] = &InputSection::discarded;
       continue;

diff  --git a/lld/test/ELF/icf-safe.s b/lld/test/ELF/icf-safe.s
index 2ced78fbcdc1..c71e2674c89a 100644
--- a/lld/test/ELF/icf-safe.s
+++ b/lld/test/ELF/icf-safe.s
@@ -89,7 +89,7 @@
 # ALL-EXPORT:   removing identical section {{.*}}:(.text.non_addrsig2)
 # ALL-EXPORT-NOT: selected section
 
-# OBJCOPY: --icf=safe is incompatible with object files created using objcopy or ld -r
+# OBJCOPY: --icf=safe conservatively ignores SHT_LLVM_ADDRSIG [index [[#]]] with sh_link=0 (likely created using objcopy or ld -r)
 
 .section .text.f1,"ax", at progbits
 .globl f1


        


More information about the llvm-commits mailing list