[lldb] Declare extern template instantiation to fix linking issues.

NativeProcessELF::GetELFImageInfoAddress<...>() is declared in NativeProcessELF.h, but only defined in NativeProcessELF.cpp. Via some optimized builds (e.g. thinlto), this instantiation may be removed when it is used in a different TU (NativeProcessELFTest.cpp).
This commit is contained in:
Jordan Rupprecht 2020-07-09 18:38:49 -07:00
parent 57f2a789ca
commit fbef6c55bc
2 changed files with 14 additions and 1 deletions

View File

@ -107,6 +107,11 @@ lldb::addr_t NativeProcessELF::GetELFImageInfoAddress() {
return LLDB_INVALID_ADDRESS;
}
template lldb::addr_t NativeProcessELF::GetELFImageInfoAddress<
llvm::ELF::Elf32_Ehdr, llvm::ELF::Elf32_Phdr, llvm::ELF::Elf32_Dyn>();
template lldb::addr_t NativeProcessELF::GetELFImageInfoAddress<
llvm::ELF::Elf64_Ehdr, llvm::ELF::Elf64_Phdr, llvm::ELF::Elf64_Dyn>();
template <typename T>
llvm::Expected<SVR4LibraryInfo>
NativeProcessELF::ReadSVR4LibraryInfo(lldb::addr_t link_map_addr) {

View File

@ -48,6 +48,14 @@ protected:
llvm::Optional<lldb::addr_t> m_shared_library_info_addr;
};
// Explicitly declare the two 32/64 bit templates that NativeProcessELF.cpp will
// define. This allows us to keep the template definition here and usable
// elsewhere.
extern template lldb::addr_t NativeProcessELF::GetELFImageInfoAddress<
llvm::ELF::Elf32_Ehdr, llvm::ELF::Elf32_Phdr, llvm::ELF::Elf32_Dyn>();
extern template lldb::addr_t NativeProcessELF::GetELFImageInfoAddress<
llvm::ELF::Elf64_Ehdr, llvm::ELF::Elf64_Phdr, llvm::ELF::Elf64_Dyn>();
} // namespace lldb_private
#endif
#endif