[Lldb-commits] [lldb] fbef6c5 - [lldb] Declare extern template instantiation to fix linking issues.

Jordan Rupprecht via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 9 18:47:16 PDT 2020


Author: Jordan Rupprecht
Date: 2020-07-09T18:43:53-07:00
New Revision: fbef6c55bc2f349110bd601b716889d73e101c92

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

LOG: [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).

Added: 
    

Modified: 
    lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
    lldb/source/Plugins/Process/POSIX/NativeProcessELF.h

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
index 84798bd004b5..117d12101a0b 100644
--- a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
+++ b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
@@ -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) {

diff  --git a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h
index 4fb513baebf0..dcfa9290ff50 100644
--- a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h
+++ b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h
@@ -48,6 +48,14 @@ class NativeProcessELF : public NativeProcessProtocol {
   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
\ No newline at end of file
+#endif


        


More information about the lldb-commits mailing list