[lld] a2ef046 - [LLD][ELF] Import `ObjFile::importCmseSymbols` at call site (#68025)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 07:12:15 PDT 2023


Author: Alexandre Ganea
Date: 2023-10-03T10:12:09-04:00
New Revision: a2ef046a2d19eef297defa613d17283c46361fcb

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

LOG: [LLD][ELF] Import `ObjFile::importCmseSymbols` at call site (#68025)

Before this patch, with MSVC I was seeing:
```
[304/334] Building CXX object tools\lld\ELF\CMakeFiles\lldELF.dir\InputFiles.cpp.obj
C:\git\llvm-project\lld\ELF\InputFiles.h(327): warning C4661: 'void lld::elf::ObjFile<llvm::object::ELF32LE>::importCmseSymbols(void)': no suitable definition provided for explicit template instantiation request
C:\git\llvm-project\lld\ELF\InputFiles.h(291): note: see declaration of 'lld::elf::ObjFile<llvm::object::ELF32LE>::importCmseSymbols'
C:\git\llvm-project\lld\ELF\InputFiles.h(327): warning C4661: 'void lld::elf::ObjFile<llvm::object::ELF32LE>::redirectCmseSymbols(void)': no suitable definition provided for explicit template instantiation request
C:\git\llvm-project\lld\ELF\InputFiles.h(292): note: see declaration of 'lld::elf::ObjFile<llvm::object::ELF32LE>::redirectCmseSymbols'
```
This patch removes `redirectCmseSymbols` which is not defined. And it
imports `importCmseSymbols` in InputFiles.cpp, because it is already
explicitly instantiated in ARM.cpp.

Added: 
    

Modified: 
    lld/ELF/InputFiles.cpp
    lld/ELF/InputFiles.h

Removed: 
    


################################################################################
diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index fa0731854689b94..a2c83adc18f54f0 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -40,6 +40,13 @@ using namespace llvm::support::endian;
 using namespace lld;
 using namespace lld::elf;
 
+// This function is explicity instantiated in ARM.cpp, don't do it here to avoid
+// warnings with MSVC.
+extern template void ObjFile<ELF32LE>::importCmseSymbols();
+extern template void ObjFile<ELF32BE>::importCmseSymbols();
+extern template void ObjFile<ELF64LE>::importCmseSymbols();
+extern template void ObjFile<ELF64BE>::importCmseSymbols();
+
 bool InputFile::isInGroup;
 uint32_t InputFile::nextGroupId;
 
@@ -315,6 +322,13 @@ template <class ELFT> static void doParseFile(InputFile *file) {
 // Add symbols in File to the symbol table.
 void elf::parseFile(InputFile *file) { invokeELFT(doParseFile, file); }
 
+// This function is explicity instantiated in ARM.cpp. Mark it extern here,
+// to avoid warnings when building with MSVC.
+extern template void ObjFile<ELF32LE>::importCmseSymbols();
+extern template void ObjFile<ELF32BE>::importCmseSymbols();
+extern template void ObjFile<ELF64LE>::importCmseSymbols();
+extern template void ObjFile<ELF64BE>::importCmseSymbols();
+
 template <class ELFT> static void doParseArmCMSEImportLib(InputFile *file) {
   cast<ObjFile<ELFT>>(file)->importCmseSymbols();
 }

diff  --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index cc658bdc231988e..41c2ba4e307b36b 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -289,7 +289,6 @@ template <class ELFT> class ObjFile : public ELFFileBase {
   void initSectionsAndLocalSyms(bool ignoreComdats);
   void postParse();
   void importCmseSymbols();
-  void redirectCmseSymbols();
 
 private:
   void initializeSections(bool ignoreComdats,


        


More information about the llvm-commits mailing list