[lld] c4ca39e - [ELF] Fix .rela.llvm.call-graph-profile detection after D104080
    Fangrui Song via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Jun 24 15:21:33 PDT 2021
    
    
  
Author: Fangrui Song
Date: 2021-06-24T15:21:28-07:00
New Revision: c4ca39e0f54ba81eefe8d48e25f7d71bbe49d952
URL: https://github.com/llvm/llvm-project/commit/c4ca39e0f54ba81eefe8d48e25f7d71bbe49d952
DIFF: https://github.com/llvm/llvm-project/commit/c4ca39e0f54ba81eefe8d48e25f7d71bbe49d952.diff
LOG: [ELF] Fix .rela.llvm.call-graph-profile detection after D104080
A SHT_SYMTAB section's sh_info is the number of local symbols.
sh_info may coincide with the section header index of SHT_LLVM_CALL_GRAPH_PROFILE.
Added: 
    
Modified: 
    lld/ELF/InputFiles.cpp
Removed: 
    
################################################################################
diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 77636af6e1fb..8a986d404792 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -669,15 +669,13 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats) {
       continue;
     const Elf_Shdr &sec = objSections[i];
 
-    if (cgProfileSectionIndex && sec.sh_info == cgProfileSectionIndex) {
-      if (sec.sh_type == SHT_RELA)
-        cgProfileRela = CHECK(getObj().relas(sec), this);
-      else
-        warn(toString(this) + ": unsupported call graph section type");
-    }
-
-    if (sec.sh_type == SHT_REL || sec.sh_type == SHT_RELA)
+    if (sec.sh_type == SHT_REL || sec.sh_type == SHT_RELA) {
       this->sections[i] = createInputSection(sec);
+      if (cgProfileSectionIndex && sec.sh_info == cgProfileSectionIndex) {
+        if (sec.sh_type == SHT_RELA)
+          cgProfileRela = CHECK(getObj().relas(sec), this);
+      }
+    }
 
     // A SHF_LINK_ORDER section with sh_link=0 is handled as if it did not have
     // the flag.
        
    
    
More information about the llvm-commits
mailing list