Skip to content

Commit a2ef046

Browse files
authored
[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.
1 parent 9546b5d commit a2ef046

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ using namespace llvm::support::endian;
4040
using namespace lld;
4141
using namespace lld::elf;
4242

43+
// This function is explicity instantiated in ARM.cpp, don't do it here to avoid
44+
// warnings with MSVC.
45+
extern template void ObjFile<ELF32LE>::importCmseSymbols();
46+
extern template void ObjFile<ELF32BE>::importCmseSymbols();
47+
extern template void ObjFile<ELF64LE>::importCmseSymbols();
48+
extern template void ObjFile<ELF64BE>::importCmseSymbols();
49+
4350
bool InputFile::isInGroup;
4451
uint32_t InputFile::nextGroupId;
4552

@@ -315,6 +322,13 @@ template <class ELFT> static void doParseFile(InputFile *file) {
315322
// Add symbols in File to the symbol table.
316323
void elf::parseFile(InputFile *file) { invokeELFT(doParseFile, file); }
317324

325+
// This function is explicity instantiated in ARM.cpp. Mark it extern here,
326+
// to avoid warnings when building with MSVC.
327+
extern template void ObjFile<ELF32LE>::importCmseSymbols();
328+
extern template void ObjFile<ELF32BE>::importCmseSymbols();
329+
extern template void ObjFile<ELF64LE>::importCmseSymbols();
330+
extern template void ObjFile<ELF64BE>::importCmseSymbols();
331+
318332
template <class ELFT> static void doParseArmCMSEImportLib(InputFile *file) {
319333
cast<ObjFile<ELFT>>(file)->importCmseSymbols();
320334
}

lld/ELF/InputFiles.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ template <class ELFT> class ObjFile : public ELFFileBase {
289289
void initSectionsAndLocalSyms(bool ignoreComdats);
290290
void postParse();
291291
void importCmseSymbols();
292-
void redirectCmseSymbols();
293292

294293
private:
295294
void initializeSections(bool ignoreComdats,

0 commit comments

Comments
 (0)